Communication

From Elcano Project Wiki
Revision as of 17:14, 21 April 2026 by Tfolsom (talk | contribs) (Introduction)
Jump to navigation Jump to search

Elcano CAN Commands

Introduction

Controller Area Network (CAN) is a standard introduced by Bosch in the 1980s. It is widely used to link automotive microprocessors and is required on all cars sold in North America and Europe. Physically there are four wires: Ground, 12V, CanHi and CanLo. A dominant bit means a significant difference between CanHi and CanLo; for a recessive bit the two lines are essentially the same. The interesting parts of a CAN packet are given in the table. The message ID is 11 bits, with low numbers getting priority. A CAN packet contains 0 to 8 bytes of data. The size of a CAN packet is larger, since CAN has significant error detection capability. CAN is a host-less network with most of the work done in hardware.

There are several nodes. One is Drive-by-Wire (DBW aka Low Level). A second is the Navigation computer (Nav). It was originally an Arduino and called High Level or Sensor Hub. In current design it is a Jetson Nano that works with a Pixhawk to find GPS and send motion instructions to DBW. Sensors such as camera and lidar will form another node, perhaps using a second Jetson Nano.


CAN ID Origin Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 Byte 8 Function


0x100 Nav 0x80 E-stop request
0x100 Nav 0x40 Manual/Auto
0x100 Nav 0x0X Forward/Reverse
0x101 Nav xx Goal reached
0x200 DBW 0x80 E-stop active
0x200 DBW 0x40 Manual/Auto
0x200 DBW 0x0X Forward/Reverse
0x350 Nav xx xx Drive Speed mm/s
0x350 Nav xx xx Brake
0x350 Nav xx xx Drive angle (10 times degrees)
0x400 DBW xx xx Actual Speed mm/s
0x400 DBW xx xx Actual angle (10 times degrees)
0x420 Lidar rr rr bb bb ww qq ss ss Obstacle Data
0x440 Sonar rr rr bb bb ww qq ss ss Obstacle Data
0x460 Camera rr rr bb bb ww qq ss ss Obstacle Data
0x480 Camera rr rr bb bb ww qq Cone Position
0x4A0 Camera xx xx yy yy zz zz Right road edge
0x4A1 Camera xx xx yy yy zz zz Left road edge
0x4C1 ? xx xx xx xx yy yy yy yy Goal 1 Position
0x4C2 ? xx xx xx xx yy yy yy yy Goal 2 Position
0x4C3 ? xx xx xx xx yy yy yy yy Goal 3 Position
0x4C4 ? xx xx xx xx yy yy yy yy Goal 4 Position
0x4C5 ? xx xx xx xx yy yy yy yy Goal 5 Position
0x4C1-0x4DF ? xx xx xx xx yy yy yy yy Waypoint Position

** Please be aware of the initial CAN-Bus baud rate. If you use MCP2515 module for testing, the baud rate needs to be set to twice the due CAN baud rate

Not all commands will be implemented. All data are given in integer; floating point is not used.

Command 0x100 and 0x200 (status change)

use Byte 1.

If bit 0x80 is set, emergency stop is active.

Bit 0x40 when set puts the trike in autonomous mode; reset puts it in manual mode.

If bit 0x04 is zero, the trike is going forward. When the receiver (0x50) sets bit 0x04, it is requesting reverse. Low Level responds with a 0x200 message with bit 0x04 set meaning that reverse is active, bit 0x02 set meaning that reverse is pending or bit 0x01 set meaning that reverse is not available.

The Receiver would output a 0x50 message only when the status changes. It expects to receive a 0x200 message for e-stop active shortly afterwards (maybe 100 ms), and will resend 0x50 until it receives a 0x200.

Waypoint Reached (CANID 0x101)

One byte

If 0x80 is set, all waypoints have been reached and the vehicle should stop.

Bit 0x01, 0x02: CAN ID for next waypoint (0x4C1 - 0x4DF).

DRIVE (CANID 0x350)

0x350 ComandedSpeed, Brake, ComandedSteerAngle

ID350 gives the command drive speed, brake and angle.

This utilizes 6 of the 8 data bytes

ComandedSpeed is a 16-bit signed integer giving the speed for the rear wheel in centimeters per second. It occupies data bytes 1 and 2. The value is the speed, in centimeters / second. Maximum value is 0x7FFF = 32767 cm/s = 730 mph.

Brake is a 16-bit signed integer giving signal to brake. Currently brake is only on or off, but could have pulses added later to be different levels of braking.

ComandedSteerAngle is a16-bit signed integer that specifies the steer angle (in degrees times 10) of the vehicle. Negative value indicates left; positive value indicates right; 0 is straight. It occupies data bytes 5 and 6. Maximum value is 1800; Minimum value is -1800. The trikes are not capable of turning more than ±30°, but other vehicles could be holomorphic.

e.g.  commanding 1.5 m/s with a 2.1° left turn gives

288 1500 -21 decimal
120 05 DC FF EB hex

ACTUAL (CANID 0x400)

0x400 ActualSpeed, ActualAngle

ID400 gives the reports the actual speed and angle from the low-level board to the high-level.

This utilizes 4 of the 8 data bytes

ActualSpeed is a 16-bit signed integer giving the speed for the rear wheel in centimeters per second. It occupies data bytes 1 and 2, formatted identically to ComandedSpeed in DRIVE(0x350) above.

ActualAngle is a16-bit signed integer that specifies the steer angle (in degrees times 10) of the vehicle. It occupies data bytes 5 and 6, formatted identically to ComandedSteerAngle in DRIVE(0x350) above.

Obstacle Data (0x420, 0x440, 0x460)

Uses 6 or 8 bytes

Bytes 1,2: Range to obstacle centroid in cm.

Bytes 3,4: Bearing to obstacle centroid in degrees times 10. Negative is left; positive is right.

Byte 5: Obstacle half-width in degrees times 10. If bearing is b and half-width is w, obstacle extends from b-w to b+w. For sensors with limited resolution, byte 5 gives the resolution. For example, a sonar that covers 30 degrees would set byte 5 to 150.

Byte 6: Quality of the signal/data. 0 = no data; 255 = highest quality

Bytes 7,8: Obstacle slant in degrees times 10 (optional). If omitted or 0, the obstacle is perpendicular to the bearing. Otherwise a negative angle indicates that the left side of the obstacle is closer, and a positive angle means the left side is farther than the centroid.

Cone Position (0x480)

Position of the next cone, using 6 bytes in the same format as obstacle data.

Byte 5 is the half-width of the cone at the base.

Road Edge (0x4A0, 0x4A1)

Estimated distance from vehicle edge to road edge in cm based on present trajectory.

Bytes 1,2: At present vehicle position

Bytes 3,4: At a near future position (to be defined)

Bytes 5,6: At a farther future position (to be defined)

Waypoint Positions (0x4C1 … 0x4DF)

Positions of waypoints. Input to Jetson Nano from user interface. They can be hard coded for now.

Bytes 1-4: East position in cm

Bytes 5-8 North position in cm.