A modular SocketCAN driver library and ROS2 integration for Linux-based systems. This repository provides both a standalone C++ library and ROS2 wrapper for easy integration with robotics applications.
This package is split into two complementary components:
Pure C++ SocketCAN library with no ROS dependencies.
- Core SocketCAN functionality
- Thread-safe operations
- Callback-based asynchronous processing
- Configurable filters and error handling
- Can be used in non-ROS projects
ROS2 wrapper providing nodes and launch files.
- ROS2 lifecycle node
- Integration with
can_msgs
- Launch files with parameter support
- Depends on the core
socketcan_adapter
library
# Install dependencies
rosdep install -i -y --from-paths .
# Build everything
colcon build --packages-up-to socketcan_adapter_ros
ros2 launch socketcan_adapter_ros socketcan_bridge_launch.py
#include "socketcan_adapter/socketcan_adapter.hpp"
using namespace polymath::socketcan;
SocketcanAdapter adapter("can0");
adapter.openSocket();
// ... see socketcan_adapter README for full example
- Linux with SocketCAN support
- C++17 compatible compiler
- CMake 3.8+
- ROS2 Humble or later
- can_msgs package
colcon test --packages-select socketcan_adapter
Set CAN_AVAILABLE=1
to enable hardware-dependent tests:
CAN_AVAILABLE=1 colcon test --packages-select socketcan_adapter
For testing without hardware:
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
Licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
- Zeerek Ahmad - Original author - [email protected]
- Polymath Robotics Engineering Team - Maintainers - [email protected]