[Kernel Panic 3.0] On the matter of State Machines

Applying for [Savvy, Make love, not war]

The SmartHjelm features a bleeding edge rear indicator light, which alerts other trafficants on the intentions of the cyclist.

In coordination with the other modules of the SmartHjelm ecosystem, this light is able to act as a left and right indicator, as well as indicating when the cyclist is braking, or has been in an accident. As a cyclist may be turning left or right at the same time as braking, this increases the complexity of the system quite a bit, and a robust solution based on a finite state machine has been implemented.

As shown, we can transition from an off state (the initial state), to blinking either left or right, showing a braking indicator, and blinking light or right while showing a braking indicator. There is also an accident state, which may be entered from any state.

The state machine runs on the rear Raspberry Pi on the SmartHjelm, and exposes a REST API for triggering state changes and publishes state changes on a WebSocket. This allows other modules to both control the state machine, and subscribe to the state of the machine. These state change events are triggered by multiple sources:

  • The rear Raspberry Pi runs an application which continuously measures accelerometer data, and triggers braking or accident events.
  • The native cellphone application allows the user to manually control the left and right blinking lights. The app also displays the braking and accident state, when the state machine is in either of these states.
  • The front Raspberry Pi has a front facing camera, and triggers the braking light as a warning to other trafficants in case of dangerous situations.
Triggering left/right signal indicator from native app

The entire system is available open source, and can be found here:

https://gitlab.com/kernel-panic-3.0/ariot2019/tree/master/features


Leave a Reply

Your e-mail address will not be published. Required fields are marked *