CAN Devices¶
Meta-Team robots uses a wide range of CAN devices, mostly motors and encoders. This section provides some basic information on how to use these devices with Meta-ROS.
CAN bus¶
Controller Area Network (CAN) is a robust communication protocol. Multiple devices can be connected to a single CAN bus, and they can communicate with each other.
Setup¶
CAN bus uses a two-wire differential signal. The two wires are called CAN_H
and CAN_L
. Devices that directly support CAN_H
and CAN_L
(most of the motors) can be connected to the CAN bus directly. Some may require an additional transceiver to convert the voltage levels to CAN bus levels.
Attention
It is generally recommended to use two 120 \(\Omega\) resistors at both ends of the CAN bus. Communication may be very unreliable without these resistors. Many motors (and CANable) have their built-in resistors that can be toggled on and off.
CANable USB to CAN adapter¶
CANable is an open-source USB to CAN adapter. It can be directly recognized as a PCAN device in Linux, provided that you have the necessary kernel modules installed.
On-board CAN interface¶
Many edge-computing devices have built-in CAN interfaces.
The Jetson Orin Nano Developer Kit has a built-in CAN controller. Unlike traditional CAN bus interfaces, the CAN interface on the board is not directly CAN bus voltage compatible (as the names TX
and RX
imply). You need a CAN transceiver to convert the voltage into CAN bus voltage levels (which is usually called CAN_H
CAN_L
).
Refer to Jetson Linux developer guide for more information on this.
To be updated.
To be updated.
Setup CAN interfaces on Linux¶
CAN interfaces are recognized as network sockets in Linux. You can directly see them with ip
command.
ip link show
To setup a CAN interface, you can simply treat it as a plain network interface.
sudo ip link set can0 type can bitrate 1000000
sudo ip link set up can0
This configures can0
with a bitrate of 1Mbps and brings it up.
SocketCAN utilities¶
SocketCAN provides a set of utilities to work with CAN interfaces.
candump¶
candump
is a simple utility to see CAN messages on the bus. You can see all messages on can0
with:
candump can0
cansend¶
cansend
is a simple utility to send CAN messages. You can send a message with CAN ID 0x123
and data 0x11 0x22 0x33
with:
cansend can0 123#112233