Difference between revisions of "Communication"

From Elcano Project Wiki
Jump to navigation Jump to search
(Introduction)
(Introduction)
Line 347: Line 347:
  
 
|-
 
|-
| style="border:0.0007in solid #000000;padding-top:0in;padding-bottom:0in;padding-left:0.075in;padding-right:0.075in;"| 0x4C1-0x4DF
+
| style="border:0.0007in solid #000000;padding-top:0in;padding-bottom:0in;padding-left:0.075in;padding-right:0.075in;"| 0x4C0-0x4DF
 
| style="border:0.0007in solid #000000;padding-top:0in;padding-bottom:0in;padding-left:0.075in;padding-right:0.075in;"| ?
 
| style="border:0.0007in solid #000000;padding-top:0in;padding-bottom:0in;padding-left:0.075in;padding-right:0.075in;"| ?
 
| style="border:0.0007in solid #000000;padding-top:0in;padding-bottom:0in;padding-left:0.075in;padding-right:0.075in;"| xx
 
| style="border:0.0007in solid #000000;padding-top:0in;padding-bottom:0in;padding-left:0.075in;padding-right:0.075in;"| xx

Revision as of 18:08, 21 April 2026

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
0x250 Nav hh mm ss ss DD MM YY YY Set time
0x251 Nav ww xx xx xx yy zz zz zz Set Origin
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
0x4C0-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, operator or Nav computer requests reverse, DBW 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 Nav computer uses message 0x100 to request reverse or other status changes.

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).

Set Time (CANID 0x250)

Eight bytes. When GNNS is established, this command will be sent once. It will be used to set the real-time clock (RTC) to coordinated time. Local time will be used.

Byte 0x00: Hour (0-23).

Byte 0x01: Minute (0-59).

Byte 0x03-4: Millisecond (0-59999).

Byte 0x05: Day (1-31).

Byte 0x06: Month (1-12).

Byte 0x07: Year since 2000. (0-256).

Set Origin (CANID 0x251)

Eight bytes. This gives Latitude and Longitude of the origin. All GPS reedings are translated to cm from the origin and sent in CAN messages 0x4C0 to 0x4DF. The Set Origin command will normally be sent once at startup.

Byte 0x00 first 7 bits: Latitude (0-90) 8th bit: 0 for N, 1 for S

Bytes 0x01-3: Fraction of latitude (0-9,999,999)

Byte 0x04: Longitude (0-180)

First bit of byte 0x05: 0 for E, 1 for W

Rest of byte 0x05 and bytes 0x06-7: Fraction of longitude (0-999,999)

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.