Help implementing nodes

Im working on a couple of uavcan nodes for my bike, mainly

  • a handlebar node
  • a headlight node
  • a taillight node

The handlebar is connected to a couple of switches

  • front and read break lever sensors
  • throttle 0-100%
  • ignition button
  • turn signal sw
  • headlight lo/hi beam sw
  • horn button

How should I implement the uavcan protocol for the handlebar node?
Should send a heartbeat and a status message with something like

{
  int throttle,             // 0-100 %
  bit breakSensor      // 1 on 0 off
  bit signalLeft,         // 1 on 0 off
  bit signalRight,      // 1 on 0 off
  bit loBeam,            // 1 on 0 off
  bit hiBeam,            // 1 on 0 off
  bit loBeamAlt,        // 1 on 0 off
  bit hiBeamAlt,        // 1 on 0 off
  bit horn,                 // 1 on 0 off
}

and subscribe from the headlight and taillight node to handlebars status messages. Or should a send one message for each value? Is there standard message for esc’s to subscribe to for reading throttle value and break sensors.for example?

If standard datatypes is available, which of them should I use?

There is more than one way to do this. For this specific application, I expect that pretty much any approach will yield a satisfactory result (bikes are usually simpler than aircraft), but if you are interested in following good design principles, consider reading the Interface Design Guidelines:

Specifically, in this case, one important idea to internalize is that good interfaces are designed based on their business objective rather than the available means of implementation. The state variables you listed here may be coming from the same node but it doesn’t imply that they are sufficiently semantically related to be bundled into the same data transaction on the bus (that is, packed into the same topic):

The strategy for segregating your states into different topics depends on the overall architecture of your system so I am unable to describe the one best way to do this, but based on the information you provided, you may attain good results by using one topic per state with standard data types as follows:

Related signals could be grouped into bitmasks using either primitive integer types or custom types. Some of the rough examples to give you an idea:

# bike.BrakeLeverState.1.0
# The flag is true when the corresponding brake is active.
bool front
bool rear
@sealed
# bike.TurnSignalCtrl.1.0
int2 LEFT  = -1
int2 NONE  = 0
int2 RIGHT = +1
int2 state
@sealed
# bike.PropulsionCtrl.1.0
# This is a discriminated union, also known as a sum type.
@union
uavcan.primitive.Empty.1.0 ignition_off  # This option indicates that the ignition is OFF.
float16 throttle                         # This option indicates that the ignition is ON and sets the throttle.
@sealed

I recommend starting with standard data types at first.