| can_msgs | init | |
| socketcan_driver | init | |
| README.md | Update README.md | |
ros2_socketcan
ros2 package for SocketCAN drivers and network stack. Made by Gerard Rius for BCN eMotorsport FSAE prototypes.
Allows for receiving and sending CAN 2.0 messages in a non-blocking way.
Previous setup
Before launching the node you must create the CAN interface using:
$ ip link set <can_name> type can bitrate <bitrate>
$ ip link set <can_name> up
The <can_name> must be the same as the one given to the ros2 node. Usually, can0, can1, canN....
You may also need to start the respective drivers. For PEAK hardware, it is not needed. For kvaser hardware, run modprobe kvaser_usb or kvaser_pci.
This commands require permission, so those must be run using sudo.
For testing the driver, you can also create a virtual bus using vcan.
can-utils can be useful as well.
Packages
can_msgs
Contains messages used by the socketcan_driver node.
can_msgs::msg::CANInfo: Stats for the bus, such as bus usage, error frames, etc.can_msgs::msg::Frame: A CAN frame.
socketcan_driver
C++ Node that interfaces with the socket Linux API.
Publishers
"/can_rx": Publishes acan_msgs::msg::Framefor each received message.
Subscribers
"/can_tx": Subscribes to acan_msgs::msg::Frameand sends the message to the bus.
Parameters
("can_name", std::string): the name of the CAN interface. By default it's value is"can0".