Skip to content

Bridging the CAN Bus to ROS 2 topics based on the linux socketcan libraries.

License

Notifications You must be signed in to change notification settings

GOFIRST-Robotics/ros2socketcan_bridge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROS 2 to CAN Bridge

Overview

For easy access to the CAN bus, a bridge between ROS 2 topics and the CAN bus was implemented. The CAN Bus is included in the Linux operating system as a network socket with the socket CAN driver. Therefore the CAN bus is included in the software similar to an Ethernet socket using the “asio” library. The node functions as a bidirectional bridge that listens to the CAN bus and publishes the received messages to a ROS 2 topic called:

  • "CAN/" + CAN socket name + "/receive"

Equally the messages on a ROS 2 topic called:

  • "CAN/" + CAN socket name + "/transmit"

are monitored and forwarded to the CAN bus. Examples of the topic names are:

  • "CAN/can1/receive"
  • "CAN/can0/transmit"

The topic names are structured in two field names and the transmit and receive topic. The first field name, “CAN” identifies the topic within ROS 2 as a CAN Topic. The ‘CAN socket name’ identifies the CAN bus within a building block because multiple CAN buses can be connected. A ROS 2 to CAN Bridge node is always coupled to one CAN bus.

Build this Package

sudo apt install ros-${ROS_DISTRO}-can-msgs
colcon build --packages-select ros2socketcan_bridge

Usage

The ros2 CAN bridge can be run using the command:

ros2 run ros2socketcan_bridge ros2socketcan

By default, it will start the CAN Bridge with the CAN socket "can0".

Note: This ROS 2 node is meant to be used on a Linux machine and may not work with other operating systems!

ROS2 Message Type

The message type used for topics is the ROS 2 "can_msgs/msg/Frame" message type.

About

Bridging the CAN Bus to ROS 2 topics based on the linux socketcan libraries.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 88.9%
  • CMake 11.1%