News for hackers. Stuff that matters.
Re:Former Tesla Firmware Engineer Discusses the System by BugsJustFindMe on Friday August 24, 2018 @02:14PM (#17836702)
As a person who used to write navigation and control software for autonomous vehicles who occasionally gets downvoted for telling people that you really don't need a fancy RTOS for this stuff, you really don't need a fancy RTOS for this stuff. Linux is a very common platform for highly responsive robotic systems. I promise that their pid control isn't an Electron app.
Re:Former Tesla Firmware Engineer Discusses the System by agitator on Friday August 24, 2018 @08:28PM (#17838820)
As someone who worked on RTOS systems and now works on autonomy.

These things frighten me everyday. What frightens me even more, is the people who work on autonomy without a real grasp on determinism. It's unfortunate that the people who have the most high tech backgrounds (phds in computer vision AI, etc) applicable to autonomy, have never implemented safety critical autonomous systems outside of a research project that tested some aspect of detection or control in a test environment and had to only work once to get a paper published.

For general robotics linux is great. But there is an enormous difference between a robot roaming around your house bumping off walls, and a vehicle carrying a whole family at 70mph.

Most of the linux based systems I have worked with have some form of redundancy, whether it be other chips running linux, or ideally ECU's running an RTOS that perform monitoring, gating, and/or some level of safety fallback control. The RTOS based redundancies often are what provide ASILD. Trusting a single linux processor is what everyone does to get funding, but when you go out and test on public roads with human lives at stake, or start selling a product, you better have some quantitative guarantees other than "It's been fine so far..." That kind of stuff makes me angry.

Re:Former Tesla Firmware Engineer Discusses the System by crubier on Saturday August 25, 2018 @12:19AM (#17839515)
Having worked several years on critical embedded systems in aerospace, I would tend to agree with you.

But on the other hand, has any Tesla car ever had an accident because of this? At some point, "heavily tested and validated end to end in real-life conditions for years" and "formally proven on a simplified model using reasonable assumptions made by human engineers" become relatively close in terms of how much trust you can put in a system.

But somehow we tend to prefer to later. I am not sure if this paradigm is still relevant these days.

Re:Former Tesla Firmware Engineer Discusses the System by xg15 on Saturday August 25, 2018 @12:31PM (#17841439)
> "heavily tested and validated end to end in real-life conditions for years"

That seems like a more wordy way to state "It's been fine so far".

> "formally proven on a simplified model using reasonable assumptions made by human engineers"

I didn't know about that. What kind of formal proofs did they do? Did they involve the linux scheduler?

Re:Former Tesla Firmware Engineer Discusses the System by Qub3d on Saturday August 25, 2018 @01:28AM (#17839691)
Thankfully, the critical reactive components of the Tesla vehicles do seem to be run by an RTOS -- spesifically FreeRTOS [0].

[0]: https://youtu.be/KX_0c9R4Fng?t=8m47s

Re:Former Tesla Firmware Engineer Discusses the System by bluefeather on Saturday August 25, 2018 @02:05PM (#17841801)
SpaceX's Linux-based engine controllers at least have a decent amount of redundancy. They're all triple-redundant, and each of the three components consists of two cpu cores running in lockstep that are validated against each other as well.
Re:Former Tesla Firmware Engineer Discusses the System by kpil on Sunday August 26, 2018 @05:50AM (#17845134)
Signalling and train control systems typically have two independent implementations - full stack: hardware, os, software, different development teams.

I guess you'd need three separate implementations to achive some redundancy when you can't just slam the emergency brakes if the systems disagree.

(... For some reason, I find it higly demotivating that another team is doing the exact same thing. Maybe I just want to be a snowflake...)

Re:Former Tesla Firmware Engineer Discusses the System by BugsJustFindMe on Friday August 24, 2018 @08:34PM (#17838850)
You're making a lot of unwarranted negative assumptions and setting up a lot of strawmen here.
Re:Former Tesla Firmware Engineer Discusses the System by xg15 on Saturday August 25, 2018 @12:32PM (#17841441)
Which ones?
Re:Former Tesla Firmware Engineer Discusses the System by zachd1_618 on Friday August 24, 2018 @07:39PM (#17838640)
+1. I wrote some near flight software for an instrument using Ubuntu with a RT patch on modern hardware, in parallel with another team that took the traditional approach. Not to brag, but our “undeterministic” system ran far more reliably than the real time one that didn’t have the advantage of modern application libraries. Plus, even though we had that pesky operating system in the way, we ran on blazing fast modern architectures and were actually more deterministic than the slow as hell hardware we were benchmarking against.

I’ve seen the same pattern a few other times. Slow, hand built, rad hard systems CAN be more stable and demonstratively safer... but that is rarely the case and the effort required to get such a system right is orders of magnitude greater than using standard “undeterministic” systems. That engineering effort can be better spent innovating and building fundamentally more advanced solutions.

Just my experience. Just my opinion

Re:Former Tesla Firmware Engineer Discusses the System by dnbgfher on Friday August 24, 2018 @06:46PM (#17838374)
Having done just enough robotics stuff to have used linux before (though not controlling anything even kind of large), I find this an odd notion. It's not that I think linux would go wrong for this sort of thing often, but when dealing with things like rockets or self-driving cars I'd think you want more assurance than "well we haven't had it be slow yet."

I haven't messed with an RTOS before but have done some fooling around with scheduling on microcontrollers and I can see why linux is tempting for ease and speed. But we're talking rockets and self-driving cars. These things are expensive as hell, can easily kill people, or both. It seems like the exact sort of place you'd want to take the time and effort to be sure.

Re:Former Tesla Firmware Engineer Discusses the System by mlaretallack on Friday August 24, 2018 @02:23PM (#17836769)
Agree completely. Hard real time is possible with Linux, we use it for sub millisecond control of Traffic Lights. The only issue we ever hit is proving that the code running is the stuff we expected to run.
Re:Former Tesla Firmware Engineer Discusses the System by coldtea on Friday August 24, 2018 @03:00PM (#17837073)
>we use it for sub millisecond control of Traffic Lights

Why would anyone need "sub millisecond control of Traffic Lights"?

Traffic lights are mission critical systems, of course, but even millisecond precision should be more than enough, and possibly even 0.5x-1 second precision...

Re:Former Tesla Firmware Engineer Discusses the System by encoderer on Friday August 24, 2018 @03:55PM (#17837459)
The sub-millisecond precision ensures they can totally destroy your day with short left turn arrows and yellow lights.
Re:Former Tesla Firmware Engineer Discusses the System by xg15 on Saturday August 25, 2018 @12:35PM (#17841450)
Yes, some green phases definitely feel sub-millisecond.
Re:Former Tesla Firmware Engineer Discusses the System by dnautics on Friday August 24, 2018 @04:42PM (#17837760)
For legal reasons. Regs say that stop cycles have to meet minimum times in each state, if you're even off by a Tony bit you could potentially challenge it legally in court.
Re:Former Tesla Firmware Engineer Discusses the System by ams6110 on Friday August 24, 2018 @09:41PM (#17839080)
Bear in mind that the software only controls the cycle. The lights are electrically wired so that it is impossible for example to have "GREEN" illuminated in crossing directions. Or so I've read -- I don't work in traffic control software or hardware.
Re:Former Tesla Firmware Engineer Discusses the System by brbrodude on Friday August 24, 2018 @03:15PM (#17837177)
if it controls a ton of them, then small stuff could get them to be intolerably out of sync maybe? I'm just guessing :p
Re:Former Tesla Firmware Engineer Discusses the System by Cyph0n on Friday August 24, 2018 @06:43PM (#17838359)
The real question is: why do you need an entire OS kernel to control traffic lights?
Re:Former Tesla Firmware Engineer Discusses the System by noselasd on Friday August 24, 2018 @07:35PM (#17838623)
To communicate with all the other traffic lights and sensors at the other intersections on the road to optimize traffic flow.
Re:Former Tesla Firmware Engineer Discusses the System by Cyph0n on Friday August 24, 2018 @09:27PM (#17839045)
Yeah, I still think that's overkill, simply because the bulk of the computation is done on a remote server anyways. All you really need on the frontend is a TCP/IP stack to send telemetry and receive commands.

If the connection is lost, the exchange can just fallback to "naive" mode.

Re:Former Tesla Firmware Engineer Discusses the System by manmal on Saturday August 25, 2018 @01:16AM (#17839656)
I guess using off-the-shelf mass market hardware combined with a software stack anyone can design, setup, and implement is way easier and cheaper than a customized solution.
Re:Former Tesla Firmware Engineer Discusses the System by XorNot on Saturday August 25, 2018 @12:49AM (#17839605)
Consider the overhead of maintaining two entirely separate software stacks, with different libraries and controllers then? And the ongoing costs of discovering your "minimal" hardware can't accomodate a future improvement, compared to just using general compute at a marginal upfront cost, and then having everything else be familiar?
Re:Former Tesla Firmware Engineer Discusses the System by fidz on Friday August 24, 2018 @08:12PM (#17838756)
Such thing does exist? I thought traffict light only time-based on no sensor involved.
Re:Former Tesla Firmware Engineer Discusses the System by BinaryIdiot on Friday August 24, 2018 @08:39PM (#17838877)
Depends on the area but yeah many intersections use sensors (cameras, sometimes under the road pressure sensors, etc) to make anywhere from subtle to extreme changes based on traffic patterns. The under the road pressure sensor has been around for decades.

When I was a kid there was one light that, when you drove over the pressure sensor, it wouldn't really do much. But if you backed up and drove over it again it must have registered an additional car coming through and the light would almost immediately go through its light cycle to change. It was really interesting to see!

Nowadays I think it's mostly cameras? We have a light near my home and the left signal will literally never trigger unless someone is in one of the left lanes.

Re:Former Tesla Firmware Engineer Discusses the System by Cyph0n on Friday August 24, 2018 @09:25PM (#17839040)
It's not a pressure sensor, but an induction loop. Basically, there is a coil placed on the road that has a small AC current passed through it. When a car (metal) sits on top of the coil, the two "coils" couple, changing the overall inductance. A simple sensor can detect this change.
Re:Former Tesla Firmware Engineer Discusses the System by TheKarateKid on Saturday August 25, 2018 @01:24AM (#17839681)
The current is even able to pass through the tires?
Re:Former Tesla Firmware Engineer Discusses the System by Cyph0n on Saturday August 25, 2018 @02:26PM (#17841873)
No, the current passes through the coil, and the coil has no physical contact with the vehicle.

Look up inductive coupling. The basic idea is that a changing (AC) current in a conductor generates a changing magnetic field (Ampere's law). This changing magnetic field then induces a voltage in the second conductor (Faraday's law). This is the principle behind how transformers work.

Re:Former Tesla Firmware Engineer Discusses the System by Dreami on Saturday August 25, 2018 @03:12AM (#17839943)
As far as I understand, it's just electromagnetic waves. No current passing through to the car, but the coil can "register" a change in its magnetic field and can determine that it's a car and how fast it goes
Re:Former Tesla Firmware Engineer Discusses the System by vageli on Saturday August 25, 2018 @11:56AM (#17841297)
Can confirm. Also interesting to note that motorcycles often have trouble triggering these sensors (a common trick is to stick a heavy duty magnet underneath).
Re:Former Tesla Firmware Engineer Discusses the System by BinaryIdiot on Monday August 27, 2018 @03:00AM (#17849873)
Really interesting! Thanks for the correction!
Re:Former Tesla Firmware Engineer Discusses the System by mmt on Saturday August 25, 2018 @04:42AM (#17840132)
As a sibling comment noted, it's not a pressure sensor [1] but an induction loop.

The Wikipedia article https://en.wikipedia.org/wiki/Induction_loop#Vehicle_detecti... has fairly extensive details on modern implementation.

[1] These do exist for weight-in-motion systems, however.

Re:Former Tesla Firmware Engineer Discusses the System by Fnoord on Saturday August 25, 2018 @03:37AM (#17839994)
An OS has a kernel. TRON [1] equally fits your description. Which is IIRC what traditionally runs on traffic lights.

[1] https://en.wikipedia.org/wiki/TRON_project

Re:Former Tesla Firmware Engineer Discusses the System by arcticfox on Friday August 24, 2018 @02:34PM (#17836865)
> Agree completely. Hard real time is possible with Linux, we use it for sub millisecond control of Traffic Lights.

Out of curiosity, why do traffic light controls need to be that precise?

Re:Former Tesla Firmware Engineer Discusses the System by huehehue on Friday August 24, 2018 @03:05PM (#17837112)
Venturing a guess -- there's either some X% accuracy standard required by the government for who-knows-what reason, or it's for red light cameras and ticketing systems.

"Ironically, the biggest concern with red-light camera systems is that they are so precise. They measure a driver’s speed and exact location within a fraction of a second — but do not leave any wiggle room for the errors of traffic signals such as inconsistent yellow light times"[0]

If there's not an accuracy threshold for safety reasons, there's gotta be one when traffic ticketing revenue is on the line (also I guess determining fault at accidents, vehicular manslaughter cases, etc.)

[0] https://www.mercurynews.com/2014/06/06/red-light-cameras-how...

Re:Former Tesla Firmware Engineer Discusses the System by loourr on Friday August 24, 2018 @03:12PM (#17837156)
I don't actually know, but my guess is time drift with respect to other lights.
Re:Former Tesla Firmware Engineer Discusses the System by jackhack on Friday August 24, 2018 @03:18PM (#17837209)
resume-driven development?
Re:Former Tesla Firmware Engineer Discusses the System by lifeisstillgood on Friday August 24, 2018 @04:13PM (#17837568)
everything is revenue driven development
Re:Former Tesla Firmware Engineer Discusses the System by jethro_tell on Friday August 24, 2018 @06:20PM (#17838223)
he said resume, i.e. working with tech you want to use at your next gig not the tech you need at this gig.
Re:Former Tesla Firmware Engineer Discusses the System by lifeisstillgood on Saturday August 25, 2018 @07:04PM (#17843058)
could have sworn i read that right ... ah well

still, revenue driven development actually makes sense as a thing too ...

Re:Former Tesla Firmware Engineer Discusses the System by samstave on Friday August 24, 2018 @04:45PM (#17837769)
On a tangent, but still germane to the thread:

Why arent their efforts to create "autonomous only" traffic managment scenarios, where people drive into a given, known area, and the area then takes control of managing the traffic and vehicles. Such that you relinquish control of the vehicle to that area's control system, with your destination stated and then your vehicle is managed accordingly.

For example, a parking lot for a really large venue with an autonomous valet system.

YOu drive up and get out and then the system takes over your car and drives off iwth it and parks it and you recall it when needed...

Or managing traffic in a very heavily trafficed bottle-neck of a grid; such as the baybridge merging egress from SF financial district.

If you put in your destination, and join the group, all the cars could then be managed for getting onto the bridge more rapidiously ...

Autonomous doesnt need to drive me from SF to LA, but it would be great if an autonomous hive mind could get all the cars to up throughput in given situations, no?

Re:Former Tesla Firmware Engineer Discusses the System by forapurpose on Friday August 24, 2018 @05:05PM (#17837885)
That seems to match the right tool (AI driving) to the right job (well-defined, well-controlled situations).

I seem to recall that similar ideas go back to the early 1990s, at least, for highways: Drive your car to the entrance ramp, plug in your destination, and the autonomous system takes it from there.

But for many of these things, such as the Bay Bridge or a highway, it seems like there is a simpler solution: Put the cars on a train and take them across by rail. I suspect I'm not the first person to think of it so I wonder why it's never been done (i.e., what problem I'm overlooking).

Re:Former Tesla Firmware Engineer Discusses the System by chipotle_coyote on Friday August 24, 2018 @05:55PM (#17838111)
I suspect it's never been tried because the cost necessary to get from where we are now to there outweighs the potential benefit compared to more conventional transit solutions, carpooling, etc. Once automated driving gets to a point where it's possible to implement "autopilot-only" lanes (and doing so gets past the sociopolitical hurdles), I suspect those will come into play too, though.
Re:Former Tesla Firmware Engineer Discusses the System by coatmatter on Friday August 24, 2018 @07:17PM (#17838522)
Cars, or more specifically the way "we"* tend to (mis)use them (single occupancy mode) are an exponential major world problem.

* Full disclosure: I ride bicycles and only plan to ever live in localities where I won't need to purchase an entire car.

More cars, or even car-friendly tech will never be the solution for the issue of too many cars. See also "induced demand": https://en.wikipedia.org/wiki/Induced_demand

https://www.mrmoneymustache.com/2011/10/06/the-true-cost-of-...

https://carbusters.org/2011/09/08/are-cars-really-our-greate...

Re:Former Tesla Firmware Engineer Discusses the System by samstave on Friday August 24, 2018 @05:51PM (#17838098)
Ive been picturing the rail problem for some time as well.

Not just for cars, but also for cargo... just have a constant gondola-like conveyer that detaches a platform from the line to slow it enough to allow for cargo to get on, then re-zip-it backinto the line and speed it along, de-rail it once it hits its exit/location...

ideally though, in cities, there would be no surface streets and all cars would have their own level below that of bikes pedestrians.

What would SF look like if a superstructure was built above all streets and all pedestrian and bike traffic was moved up there? (sure, SF may be a poor example, so just select [city])

Look at Singapore's vast underground connecting malls between facilities. Those are pretty amazing.

I grade US urban/city planners rather poorly.

Re:Former Tesla Firmware Engineer Discusses the System by forapurpose on Saturday August 25, 2018 @12:41AM (#17839577)
> What would SF look like if a superstructure was built above all streets and all pedestrian and bike traffic was moved up there?

The street level would be dark and storefronts would become difficult to access. If the stores moved up to the 2nd floor (a massive transformation of real estate, probably greatly reducing available living space), what would go on the first level? Not many people would want to live in the dark.

Re:Former Tesla Firmware Engineer Discusses the System by samatman on Saturday August 25, 2018 @06:40AM (#17840338)
It's not a pure hypothetical, large parts of contemporary Chicago were built up a level.

The results are mostly "garden apartments" which are damp, dim, and slightly less expensive.

Re:Former Tesla Firmware Engineer Discusses the System by coatmatter on Friday August 24, 2018 @07:23PM (#17838563)
Underground space isn't unlimited.

Besides, the best integrated transport solution in the world already exists in places like Utrecht, Groningen and Assen thanks to reforms that started decades ago.

Re:Former Tesla Firmware Engineer Discusses the System by ummonk on Friday August 24, 2018 @06:28PM (#17838262)
If it were that easy to setup tech-based infrastructure, we would have had positive train control implemented years ago.
Re:Former Tesla Firmware Engineer Discusses the System by jacques_chester on Friday August 24, 2018 @06:50PM (#17838396)
Rio Tinto have spent more than a decade on autonomous freight trains.

On tracks they own.

With no other traffic than theirs.

And unlimited funding.

Re:Former Tesla Firmware Engineer Discusses the System by pouta on Friday August 24, 2018 @07:05PM (#17838467)
What is Rio Tinto? I'm curious because it is the name of a local city here in Porto.
Re:Former Tesla Firmware Engineer Discusses the System by coatmatter on Friday August 24, 2018 @07:09PM (#17838487)
One of the world's largest mining companies.

https://en.wikipedia.org/wiki/Rio_Tinto_Group

Re:Former Tesla Firmware Engineer Discusses the System by jacques_chester on Friday August 24, 2018 @07:27PM (#17838585)
BHP (largest mining company in the world) and Rio Tinto (second largest) are to parts of Australia as Google and Facebook are to the Bay Area.

And much less apologetic about wielding power.

Re:Former Tesla Firmware Engineer Discusses the System by nojvek on Saturday August 25, 2018 @02:50AM (#17839892)
Yep. Probably why Australia doesn’t churn out Tech behemoths. They’re too busy investing money to dig massive holes in the ground.
Re:Former Tesla Firmware Engineer Discusses the System by jacques_chester on Saturday August 25, 2018 @10:44AM (#17840970)
The dynamics of mine development show interesting parallels with tech, actually.

Lots of mines start from little companies searching for a possible ore body (the idea or market fit), then raising money to perform a closer survey (seed funding). If the closer geological work is promising they often obtain a lease (patents or other IP).

At this point it goes one of two ways. Either they raise enough money to start and operate the mine themselves (series A, B etc, leading to an IPO) or they sell the prospect to a major company.

Then the newly-minted millionaires, who know a lot about mining, invest in the next crop of junior miners.

So as with tech there are conceptual, exploratory, growth and liquidity phases, followed by a process of reinvestment.

I remember realising this when living in Perth and being frustrated that, with quite literally billions of dollars sloshing around the city looking to invest, you'd be hard-pressed to pitch anything smarter than a brochureware website to the local investment class.

There were other structural problems. Stock options are not A Thing for various legal reasons. Failure in starting a high-risk business is a bit of a black mark. There are VCs but so much of their money came from governments trying to jump-start a market that they were about as risk-taking as a loans officer at a bank (what government wants "10 MILLION WASTED ON PHONE APPS" as a headline?).

Meanwhile the super funds are collectively sitting on trillions of dollars[0] and investing an absurdly dumb fraction of it in the ASX. Putting just 0.5% of their holdings into VC would unlock tens of billions of dollars of potential investments.

For which, hey, VCs who lurk here and want to raise a fund: go talk to the Australian superannuation industry. It is a massive pool of underperforming cash languishing in the same dozen public companies and, because Australian law forces all Australians to set aside at least 9.5% of income for retirement, the industry will never stop having incoming funds. There will always be new money to raise[1] and it will probably the 2nd largest pool of pension investments sometime in the next 10-15 years.

I will accept finder's fees and/or massively remunerative job offers as reward for this insight.

[0] https://www.superannuation.asn.au/ArticleDocuments/269/Super...

[1] https://www.willistowerswatson.com/-/media/WTW/Images/Press/...

Re:Former Tesla Firmware Engineer Discusses the System by samstave on Friday August 24, 2018 @08:07PM (#17838739)
You're right. We should all just give up.

I mean, heck. If it were that easy to start a unicorn...

But seriously - I am not saying its easy, I'm just surprised that we haven't made much (publicly known about/announced) efforts along these lines.

I mean, we have TCP down pretty good - if we are simply thinking of cars as packets, a lot of the math should exist to ensure collision-less delivery?

Re:Former Tesla Firmware Engineer Discusses the System by exDM69 on Saturday August 25, 2018 @04:39AM (#17840127)
Well TCP doesn't do collision avoidance, it's a link layer thing. And on Ethernet, it is collision detection on the shared medium. Wireless does avoidance due to the hidden terminal problem.

Neither of these models is really analogous to cars on the road.

But applying collision detection and exponential back off in road traffic is a "fun" thought experiment.

A more apt model would be critical sections and semaphores from concurrent programming. Which is named after a collision avoidance scheme used to control trains. And we all know how difficult concurrent programming can be. I don't want traffic with deadlocks, starvation, busy waiting or live locks.

Re:Former Tesla Firmware Engineer Discusses the System by Pastrami on Friday August 24, 2018 @08:48PM (#17838923)
> if we are simply thinking of cars as packets

You better hope you don't get any dropped packets.

Re:Former Tesla Firmware Engineer Discusses the System by samstave on Friday August 24, 2018 @09:27PM (#17839044)
It's TCPizza delivery! much better than UDPizza - I never know when they cant locate my MAC.
Re:Former Tesla Firmware Engineer Discusses the System by ummonk on Sunday August 26, 2018 @12:50PM (#17846671)
Oh, we lost a car. No big deal, we'll just send another copy!
Re:Former Tesla Firmware Engineer Discusses the System by exDM69 on Saturday August 25, 2018 @04:48AM (#17840143)
Well this would mean collaboration between autonomous car manufacturers to build a common protocol. And this does not fit with their business model of getting massive investment on the grounds of potentially being the first player on the market.

I don't think there is any possibility of large scale autonomous driving without a shared control infrastructure. Autonomous driving will only work as long as autonomous cars are a small minority.

As soon as they stop being in the minority, some shared control infrastructure is necessary.

Case in point: 4 cars arriving in a no-lights 4 way intersection simultaneously will cause a deadlock. A tie breaking scheme requiring some form of communication is necessary.

Re:Former Tesla Firmware Engineer Discusses the System by xg15 on Saturday August 25, 2018 @12:44PM (#17841485)
Not just between car manufacturers, but also between the cars and the area conrol system. Basically, all car manufacturers whould have to agree on a common API that allows the control system to take over, with full access to sensors and drive controls. A manufacturer could not simply refuse to implement the API, because this would effectively make their cars unable to use certain parts of the road network.

Even if manufacturers would somehow manage to agree on an API, it could then be "abused" by competitors or accessory vendors to sell their own customized car assistants, which would instantly work with any car brand - without them having to negotiate with the manufacturers.

I fear we will sooner have a usable open IoT standard than manufacturers giving up that level of control.

Re:Former Tesla Firmware Engineer Discusses the System by coatmatter on Friday August 24, 2018 @07:06PM (#17838475)
Airport baggage systems are mostly automated.
Re:Former Tesla Firmware Engineer Discusses the System by mlaretallack on Friday August 24, 2018 @02:25PM (#17836790)
But I have to add we have a real embedded cortex checking everything, just in case ......
Re:Former Tesla Firmware Engineer Discusses the System by atomicthumbs on Friday August 24, 2018 @07:23PM (#17838554)
So what sort of interlocks do you have on top of that to prevent simultaneous greens?
Re:Former Tesla Firmware Engineer Discusses the System by amanaplanacanal on Friday August 24, 2018 @08:38PM (#17838870)
Traffic signals have hardware interlocks so that can never happen. I don't know if they are using mechanical relays or what, but you can't turn both sides green in software.
Re:Former Tesla Firmware Engineer Discusses the System by js2 on Friday August 24, 2018 @02:25PM (#17836787)
Also, an RTOS is susceptible to priority inversion[0] so it’s not necessarily a panacea.

0. which infamously occurred on the Mars Pathfinder. https://www.rapitasystems.com/blog/what-really-happened-to-t...

Re:Former Tesla Firmware Engineer Discusses the System by gapo on Friday August 24, 2018 @02:49PM (#17836988)
There are solutions to priority inversion. This is an old limitation that is now days even taught in school.

Any decent RTOS should have Priority inheritance that should avoid this.

Pointing to this one things as RTOS issue isn't really an accurate portrayal of current RTOS capabilities.

Re:Former Tesla Firmware Engineer Discusses the System by js2 on Friday August 24, 2018 @03:23PM (#17837243)
That’s good to know. Indeed, the Pathfinder’s OS (VxWorks) had priority inheritance but it wasn’t enabled on a particular mutex and enabling it was the fix.

Priority inversion had been known about since the 70s. Priority inheritance seems to have first been proposed in 1990:

https://www3.nd.edu/~dwang5/courses/spring18/papers/real-tim... (Priority Inheritance Protocols: An Approach to Real-Time Synchronization)

The Pathfinder engineers were apparently unaware of the priority inheritance option available in VxWorks until they had to debug the issue live from a few hundred million km away.

Re:Former Tesla Firmware Engineer Discusses the System by 8_hours_ago on Friday August 24, 2018 @03:22PM (#17837235)
Automotive ADAS systems generally require ASIL-D certification, which is much easier with an RTOS than Linux. I don't have much experience with real-time embedded Linux, but my understanding is that it is very difficult or impossible to certify to ASIL-D. Can someone correct me?
Re:Former Tesla Firmware Engineer Discusses the System by yitchelle on Friday August 24, 2018 @05:23PM (#17837970)
A RTOS helps because the vendor will usually provide the RTOS already certified for ASIL-D application. The rest of the software components will also need to reach ASIL-D, but getting the RTOS to ASIL-D makes things a little bit easier.
Re:Former Tesla Firmware Engineer Discusses the System by balp on Saturday August 25, 2018 @02:06AM (#17839786)
Usually this boils down to the ASIL-D RTOS systems are much smaller, e.g. much simpler to verify, leaving the developers of the systems above with much more job to verify there parts.

Also in my experience it might have been easier to reach the ASIL-D requirements, using a smarter combination of a Limiter on RTOS and using more generic code on something like linux for more of the code. This probably also would end up in more used and tested applications reaching more stability. (That's is partly outside ASIL-D).

Functional safety and ISO-26262 is much misunderstood in automotive development and architecture.

Also imho the certifications, well with out the safety case are kind of useless. You still have to make the assessment how you will find the problems with it in your use case. That might ever so slightly differ from what they certified. The automotive industry thou loves to have someone else to blame, e.g. the supplier of the RTOS, Compiler etc. Using Linux makes the blame game hard.

Re:Former Tesla Firmware Engineer Discusses the System by hatsubai on Monday August 27, 2018 @08:56AM (#17851159)
Agreed. I work on both vxWorks and Linux in the defense industry for a very popular armored fighting vehicle, and despite popular belief, the Linux kernel with the RT patch works well enough that both the cost of vxWorks and the issue of finding developers to maintain it isn't exactly justifiable anymore. Without going into too much detail, there have been a good few studies internally to show that our current fire control unit doesn't need the hard time precision it once required on legacy hardware, and all of the Linux ports with the RT patch perform just as well. The biggest hurdle, of course, is not exactly the performance. It's the certification process.
Re:Former Tesla Firmware Engineer Discusses the System by gascan on Friday August 24, 2018 @04:56PM (#17837833)
Is that like, you really don't need a fancy RTOS for this stuff 99.999% of the time, although sometimes you do? Or truly, despite the life safety element, there is never any need for RTOS.
Re:Former Tesla Firmware Engineer Discusses the System by BugsJustFindMe on Friday August 24, 2018 @06:17PM (#17838216)
In every application I can think of off the top of my head, but mostly in the ones that apply to Tesla, you truly don't, except when the law or a contract says otherwise. I'm sure there are exceptions for things that don't apply to Tesla (or for that matter SpaceX).

Here's what's inside of every autonomous vehicle ever made: a message-passing subsystem, sensors, fusers, navigation, dynamic control, actuator device drivers, and thruster device drivers.

Sensors measure things and emit readings. Your most expensive, highest frequency general purpose sensors emit new readings at something too fast for a human but hella slow for a computer, like 100Hz-5KHz. Your common sensors, a video camera for instance, don't get even close to that. These sensors are often connected, even today because milspec companies hate modernity, via RS-232 serial cables. For those younger than 30, RS-232 is what non-Apple computers used for non-keyboard/mouse peripherals prior to the introduction of the first iMac in 1998 because USB didn't really take off until then.

Sensors send their readings via the message-passing subsystem to fusers.

Fusers take the readings from the sensors and, hur hur, "fuse" them together into a description of where the vehicle is and what the environment is like. This usually involves something like a kalman filter. Fusing even your very fastest sensors, the 5KHz IMUs of the world, is just a small bit of math and basically takes no time at all.

Fusers send their fused states via the message-passing subsystem to navigation.

Navigation takes the fused sense of self and the world and decides which direction to head and how fast to go. The objective could be something like hitting route waypoints or it could be something like staying in a lane and not being rear-ended and avoiding obstacles. Car navigation probably doesn't act on new input more frequently than 100Hz, you certainly can't act on new input more frequently than 100Hz, and it takes basically no time at all.

Navigation sends its directives via the message-passing subsystem to dynamic control.

Dynamic control takes navigation's "which way" and "how fast" directives and turns them into more realistic short-term goals accounting for hysteresis and other physical limitations of the system like minimum turn radius. This is just a small bit of math and basically takes no time at all.

Dynamic control sends its directives via the message-passing subsystem to the actuator and thruster drivers.

Actuator drivers convert dynamic control's "go more left" message into trying to go more left.

Thruster drivers convert dynamic control's "go more fast" message into trying to go more fast.

Actuator and thruster drivers send readings (hopefully) from the actuators and thrusters, because those are also sensors, back to dynamic control and fusion.

Sensors feed into fusers, fusers feed into nav, nav feeds into dynamic control, dynamic control feeds into actuation and thrust. When you have new data, you do something new with it which is technically doing the same old thing with it and just producing new output.

Now there aren't that many sensors. There are way fewer fusers. There's only one navigation. There's probably only one dynamic control, though there could be a couple.

Anything else that I haven't already described, like Waymo's machine learning object classifying 4D mustache adding hotdog detectors, are just sensors and fusers sitting on their own computers feeding new lat/lng/heading/speed to navigation at a rate that is hella slow for a computer. And for sure Waymo's convolutional neural network middle-out jaywalking yoga mom detector takes a lot of processing, but it's running on its own computer, not competing for resources, and emitting its fused readings at some hella slow for a computer rate.

Re:Former Tesla Firmware Engineer Discusses the System by gmueckl on Saturday August 25, 2018 @04:01AM (#17840048)
Nice high level conceptual model of such a system. What you conveniently ignore is the complexity that is necessarily introduced by hard real time constraints, safety and all the reliable communication required.

This stuff really does get complex. A sensor controller will likely be on multiple cycles internally: one for oversampling the sensor hatdware and one for transmitting the (filtered/corrected/calibrated) results. A "fuser" as you call it (never heard that term before) needs to make sure that it does never act on stale sensor information (sensor malfunction, accumulated communication issues). Transmission errors need to be detected. Random bitflips in values that are stored in volatile memory for long time spans need to be checked and acted upon.

Every independent controller in such a system requires some kind of watchdog that needs to be reset periodically. Too many watchdog resets in a row indicate a failure and the affected system must shut down in a defined way. You need ways to deal with any combinations of controllers going belly up and avoid taking unsafe actions. For many systems transitioning into a totally inert safe mode is sufficient, but not always.

All of the hardware must constantly run self tests. That includes periodic CPU and memory tests (both volatile and non-volatile memory) and also all periphery that us involved. If, for example, a DAC is used to send a signal, the resulting signal must be read back by different hardware to check that the generated voltage is indeed correct.

Manually threading together all these different kinds of cycles and asynchronous events without a RTOS scheduler is hard and becomes error prone. The result is likely less resilient than a preemptively multithreaded firmware.

Re:Former Tesla Firmware Engineer Discusses the System by BugsJustFindMe on Saturday August 25, 2018 @08:21AM (#17840556)
I had a very mean line-by-line response, but then I deleted it because it wasn't in keeping with HN guidelines. I apologize for having written it even though you'll never read it. Instead I'll just say that literally nothing you've mentioned has anything to do with whether you choose to use Linux. Yes your serial lines will be noisy. Yes you have to write software. Yes you need specific domain knowledge to do it well. Nobody has ever said otherwise. None of that, none, has anything to do with the operating system.

An operating system, real time or otherwise, handles activating processes, IO, and interprocess messaging. That's it. You don't get magical serial line noise clearing pixies with it, and it doesn't make your actuators less drunk.

And...

> Manually threading together all these different kinds of cycles and asynchronous events without a RTOS scheduler is hard and becomes error prone.

You just said "getting input and sending output is way too hard for software on a Linux kernel." That's a crazy person statement. It turns out that Linux is, and has been for a loooong time, very good at doing operating system things like activating processes and interprocess messaging.

> The result is likely less resilient

Saying "likely" here suggests that you don't know what the result actually is. So what are you arguing? What was my statement?

Whatever assumption you're making that says "This. This right here is the reason why we definitely need an RTOS." Just don't make that assumption. That assumption is wrong.

Re:Former Tesla Firmware Engineer Discusses the System by gmueckl on Saturday August 25, 2018 @01:14PM (#17841605)
We need to both take a step back here and look at what we are saying. I am working on safety critical embedded software running mostly on small(ish) microcontrollers. It's the kind of environment where you're running either bare metal or an RTOS at best. There is simply no way to run anything else in this kind of very constrained hardware we have.

So to me, "you don't need an RTOS" means that you're running on bare metal. And that would be hard to pull off for the reasons that I outlined above. And I think this is where we ended up misunderstanding each other.

I enjoy the kinds of restricted RTOS environments that we use because their simplicity means that I can get a total understanding of what is going on quite easily.

This does not mean that Linux is completely inappropriate for real time tasks. I am sure that you could analyze and patch the kernel to match pretty high standards (others mentioned patches). Given the relative size and complexity of a Linux system, this is no simple task. But if you run it on appropriate hardware (not your run of the mill x86), I don't see why you couldn't get reliable realtime responses.

But safety essentially means that the software will not fail more often than once every x hours where x ranges between 10^5 and 10^8, depending on the level of safety required. Proving that for a complex system is hard. For example, how do you show that the essentially indeterministic pattern of dynamic memory allocations happening in a Linux system will never lead to memory exhaustion by fragmentation?

I know of no version of the Linux kernel (or GCC, for that matter) that got a functional safety certification. Safety standards are transitioning away from allowing positive track records as sufficient proof that a piece of software meets safety standards. Do-178 now only allows certified software AFAIK and I expect this to be carriedover into ISO 61508 and ISO 26262. This means a regulated development process, pretty strict coding standards, complete test coverage, full documentation, and so on also for all 3rd party software. Not sure how this transition is going to play out in practice.

Do you know any ASIL-C or ASIL-D (or SIL-2/SIL-3) software that is running on Linux? I am curious whether anybody managed to get that certified. I know that Linux is running on some class II medical equipment, but then, standards for these devices are inexplicably lower in practice in my experience.

Re:Former Tesla Firmware Engineer Discusses the System by planteen on Saturday August 25, 2018 @03:55PM (#17842307)
A common distinction is between hard real-time and soft real-time tasks. Hard realtime means that missing a deadline results in a complete failure of the system. A soft real-time deadline means that missing a deadline will not result in system failure. Many soft real-time problems are incorrectly and unnecessarily promoted to being described as hard real-time. This can lead to completely different system architectures and much longer development time.

A stock modern Linux kernel on almost any hardware platform will give millisecond level responses. Much of the old PREEMPT_RT patch set features from the old 2.6.x days for real-time response has been merged to the mainline kernel.

There are lots of problems in software where you are controlling something physical with a control loop from 1 to a couple hundred Hz. Many people assume a hard real-time deadlines are necessary for this sort of system, but through good system design practices it often is not necessary. For example, if something physical must be sampled with very low jitter, let some hardware do the sampling and latch it in a register and then let the software come in with a variance of hundreds of microseconds to get its work done. Once again, write the output to a latched register and let hardware worry about taking the shadow register with very low jitter.

Having worked on bare metal microcontrollers, to various RTOSes, to higher-performance embedded CPUs with Linux, I prefer Linux on higher-performance hardware. Obviously, this isn't always possible, especially in power constrained situations. But with Linux, when you suddenly need to have support for an arbitrary network protocol, a database, a filesystem, graphical output, etc. you can have something together in no time. It is often a monumental effort for such a task when bare metal or with a RTOS. It is often difficult to get the supporting software and libraries to build on an RTOS in the first place.

Re:Former Tesla Firmware Engineer Discusses the System by mikeash on Friday August 24, 2018 @10:45PM (#17839261)
Do you have a book where you just explain various things in this style? I’d buy it.
Re:Former Tesla Firmware Engineer Discusses the System by BugsJustFindMe on Friday August 24, 2018 @11:10PM (#17839315)
Interesting. I guess it's time for me to pick up another hobby!
Re:Former Tesla Firmware Engineer Discusses the System by jerkstate on Saturday August 25, 2018 @12:36AM (#17839563)
check out comma.ai for a mostly open-source implementation
Re:Former Tesla Firmware Engineer Discusses the System by BugsJustFindMe on Saturday August 25, 2018 @07:24AM (#17840426)
That's not the hobby I was talking about.
Re:Former Tesla Firmware Engineer Discusses the System by analognoise on Friday August 24, 2018 @06:45PM (#17838367)
I think in terms of missiles, so everything needs an RTOS. Or bare metal.
Re:Former Tesla Firmware Engineer Discusses the System by BugsJustFindMe on Friday August 24, 2018 @08:10PM (#17838752)
Have you written missile guidance or are you armchair speculating?
Re:Former Tesla Firmware Engineer Discusses the System by analognoise on Saturday August 25, 2018 @08:54AM (#17840624)
Guidance? No. Infrared detectors? Yes.
Re:Former Tesla Firmware Engineer Discusses the System by bpye on Friday August 24, 2018 @08:07PM (#17838737)
A Falcon 9 and a missile share a lot of qualities.
Re:Former Tesla Firmware Engineer Discusses the System by planteen on Saturday August 25, 2018 @11:39AM (#17841234)
Interesting talk you may be interested in: "Who needs a Real-Time Operating System (Not You!)" (2016)

https://kernel-recipes.org/en/2016/talks/who-needs-a-real-ti...

Re:Former Tesla Firmware Engineer Discusses the System by Keyframe on Friday August 24, 2018 @03:35PM (#17837311)
you really don't need a fancy RTOS for this stuff

maybe you don't, but genuinely curious how do you validate/guarantee scenarios then?

Re:Former Tesla Firmware Engineer Discusses the System by BugsJustFindMe on Friday August 24, 2018 @08:45PM (#17838909)
I suppose my best questions back to you might be:

1) What concrete guarantees do you think you get from a special RTOS?

2) Which of those guarantees are meaningful to the scenario?

3) How (by what mechanisms) do you think the special RTOS guarantees the things that it guarantees?

4) Which of those behaviors are something that only an RTOS can provide?

Re:Former Tesla Firmware Engineer Discusses the System by Keyframe on Friday August 24, 2018 @08:52PM (#17838938)
Among other things, determinism, since timing can be guaranteed (within a margin). RTOS will run with consistent timing, which is guaranteed and facilitated by control over tasks priority and checks whether timings are met. You could probably do that without a hard RTOS, but without any sort of formal guarantee. So, it might work all fine and dandy, until it doesn't. Doesn't should not exist in a hard RTOS by definition and proofing of it.
Re:Former Tesla Firmware Engineer Discusses the System by BugsJustFindMe on Friday August 24, 2018 @09:34PM (#17839063)
You don't need an RTOS to know that a system without extraneous background processes isn't doing extraneous background processing. Where precisely do you think think your timings are going? You're not also running a Minecraft server on the nav computer. Using Linux doesn't mean you also need to enable stupid PC things like search indexing or seti@home. Navigation isn't resource constrained. The only resource constrained component in the whole system is the computer vision module and it's going to be on its own processors, and the rate at which it can hand off new output is on far faaaarrrr longer timescales than your interprocess communication latency.
Re:Former Tesla Firmware Engineer Discusses the System by balp on Saturday August 25, 2018 @02:15AM (#17839799)
Yes, thata one of the RTOS thing, but almost always, when trying to build this down into what these timing limits are, they are kinda arbitrary, gut feeling put into a number. There are exceptions, yes, usally these exceptions as well are only for a limity subpart of the system. So for this using RTOS for everything is as stupid as not using RTOS, (or possibly even puting these parts into hardware, ASIC of FPGA) for these small subsystems. These timing used, also is mostly up to scheduler and Linux is possible to run with a scheduler that gives it similar capabilities ans most RTOS systems. It's a blury grey area at best.
Re:Former Tesla Firmware Engineer Discusses the System by planteen on Saturday August 25, 2018 @11:35AM (#17841218)
Yes, this is so true. When someone has a true jitter-sensitive task that needs to run on say microsecond or sub-microsecond accuracy, that is not for the realm of a high-performance CPU with caches even if it is on a RTOS. My first question is if that tight of a bound is truly necessary or just an over-specified requirement. If it is necessary, I say do that in hardware or on a simple microcontroller (e.g., Cortex-R) if that is truly your requirement.
Re:Former Tesla Firmware Engineer Discusses the System by coldtea on Friday August 24, 2018 @02:58PM (#17837052)
>I promise that their pid control isn't an Electron app.

Given all the wtf stuff in TFA, it might very well be...