Skip to content

polymathrobotics/socketcan_adapter

Repository files navigation

SocketCAN Adapter

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.

Architecture

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

Quick Start

Build Both Packages

# Install dependencies
rosdep install -i -y --from-paths .

# Build everything
colcon build --packages-up-to socketcan_adapter_ros

Launch ROS2 CAN Bridge

ros2 launch socketcan_adapter_ros socketcan_bridge_launch.py

Use Core Library in C++

#include "socketcan_adapter/socketcan_adapter.hpp"

using namespace polymath::socketcan;

SocketcanAdapter adapter("can0");
adapter.openSocket();
// ... see socketcan_adapter README for full example

Requirements

System Requirements

  • Linux with SocketCAN support
  • C++17 compatible compiler
  • CMake 3.8+

ROS2 Requirements (for ROS package only)

  • ROS2 Humble or later
  • can_msgs package

Testing

Core Library Tests

colcon test --packages-select socketcan_adapter

Hardware Tests

Set CAN_AVAILABLE=1 to enable hardware-dependent tests:

CAN_AVAILABLE=1 colcon test --packages-select socketcan_adapter

Virtual CAN Setup

For testing without hardware:

sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0

License

Licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

Authors & Maintainers

About

Socketcan Driver Library for Linux based PCs and ROS2 nodes

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •