This ros2 package provides bridge between socket can and ros2 message. Though this ros2 package is called can "parser", it don't parse any of the incoming can signals. Instead, NTURacingTeam/nturt_can_config provide such function using c code generated from dbc(can database) file.
Obviously, the name "parser" suggests that this package was once used as a parser of can message before we find out that there's a de facto standard dbc format that document such. And even dozens of code generators built for that. Better research before doing any hard works! If you are interested in how this package was used for parsing can message, please checkout
ros1
branch.
The library used for bridging socket can and ros2 node implementation was adopted from autowarefoundation/ros2_socketcan. Yet the library has minor defect that the receiver node will receive the can message sent by the sender node due to socket can's local loopback
. Hence we forked the package into our own NTURacingTeam/ros2_socketcan.
The sender/receiver node from autowarefoundation/ros2_socketcan does not support for real-time. Hence this package adds it's own implementation of the sender/receiver node in order to make them real-time.
After system reboot, can bus have to be configured before use, hence this node(process) is used for such purpose, and it exits afterwards.
Usage:
ros2 run nturt_can_parser configure_can.sh [OPTIONS]
Use -h
option to checkout its full usage.
This ros2 node publishes can_msgs/msg/Frame
message to from_can_bus
topic when receiving can signal from socket can. To run it in real-time mode, use --real-time
option.
Usage:
ros2 run nturt_can_parser socket_can_receiver [--real-time]
This ros2 node subscribes can_msgs/msg/Frame
message from to_can_bus
topic to send can signal to socket can. To run it in real-time mode, use --real-time
option.
Usage:
ros2 run nturt_can_parser socket_can_sender [--real-time]
This launch file combines the functionality of the above three nodes.
Usage:
ros2 launch nturt_can_parser socker_can_bridge.launch.py
There are couple ros2 parameters defined in this launch file:
password
- string: The password of the sudo user for configuring can bus, required.bitrate
- int: The Bitrate at which the can bus will transfer can signal, default to100000
(100K).is_realtime
- bool: Whether to run in real-time mode, default totrue
.
This package provides two python scripts to test socket can:
- can_receive_test.py
- can_send_test.py
Use -h
option to checkout theirs full usage.