Skip to main content

ROS2 to Cyphal bridge (YAML-configured)

Project description

ros2-cyphal-bridge PyPI ci-and-deploy

ROS 2 <-> Cyphal bridge with YAML-configured routing and transforms.

Install

pip install ros2-cyphal-bridge

Requirements

  • ROS 2 installed and sourced (for rclpy).
  • Python >= 3.9.
  • Cyphal DSDL types available via CYPHAL_PATH (e.g., the public regulated data types).
  • libpcap (needed for UDP transport on Linux, and included in the Docker image).

Usage

ros2-cyphal-bridge --config bridge.yaml

Config format

Example example_bridge.yaml:

version: 1
cyphal:
  node_id: 99
  node_name: "com.manufacturer.project.example_ros2_bridge"
  can_iface: "socketcan:slcan0"
  can_mtu: 8
cyphal_to_ros2:
  - rule: "uavcan.node.Heartbeat.1.0@42 -> /nodes/uptime:std_msgs/msg/UInt32"
    transform: "data=int(msg.uptime)"

  - rule: "2000:uavcan.si.unit.pressure.Scalar.1.0 -> /robot/sensors/pressure:sensor_msgs/msg/FluidPressure"
    transform: "fluid_pressure=float(msg.pascal);variance=0.0"

  - rule: "2003:uavcan.si.unit.temperature.Scalar.1.0 -> /robot/sensors/temperature:sensor_msgs/msg/Temperature"
    transform: "temperature=float(msg.kelvin - 273.15);variance=0.0"

  - rule: "2001:uavcan.primitive.scalar.Bit.1.0 -> /robot/sensors/limit_switch:std_msgs/msg/Bool"
    transform: "data=bool(msg.value)"

ros2_to_cyphal:
  - rule: "/setpoint:std_msgs/msg/Float32 -> 2002:uavcan.primitive.scalar.Real32.1.0"
    transform: "value=float(msg.data)"

Cyphal config

  • node_id: Optional Cyphal node-ID; if omitted, uses UAVCAN__NODE__ID or leaves it unset.
  • node_name: Optional node name for uavcan.node.GetInfo; defaults to com.manufacturer.project.ros2_bridge.
  • can_iface: Optional PyCyphal CAN interface (e.g., socketcan:slcan0).
  • can_mtu: Optional CAN MTU (e.g., 8).
  • udp_iface: Optional UDP interface (e.g., 127.0.0.1).

Rule syntax

  • Cyphal endpoint: port_id@node_id:dsdl_type
    • port_id can be omitted to use the fixed port ID (e.g., uavcan.node.Heartbeat.1.0).
    • @node_id is optional.
  • ROS 2 endpoint: /topic:pkg/msg/Type.
  • Rules use left -> right for direction.

Transform syntax

Transforms are assignment expressions separated by ;:

field=value

The left-hand side is a target field on the output message. The right-hand side is a Python expression evaluated with:

  • msg (input message)
  • float, int, bool, abs, min, max, math

Examples:

  • data=float(msg.pascal)
  • value=float(msg.data)

Security note: transforms use Python eval and must be treated as trusted input only.

Quick start (Docker)

Run the bridge container with the example config:

docker run --rm --net=host -v $(pwd)/tools/docker/example_bridge.yaml:/tmp/bridge.yaml:ro ponomarevda/ros2-cyphal-bridge:v0.3.0 --verbose

Notes

  • Requires a ROS 2 environment (rclpy) for execution.
  • Cyphal DSDL types are resolved via CYPHAL_PATH.
  • Cyphal uavcan.node.GetInfo reports software_version from the package version (setuptools-scm tag).

Troubleshooting

  • UDP/libpcap: On Linux, PyCyphal UDP capture relies on libpcap and raw packet access. Install libpcap (e.g., libpcap/libpcap-dev) and grant raw capture privileges (run as root or give cap_net_raw to the Python interpreter), per PyCyphal’s UDP transport docs.
  • NumPy scalar conversion error: If you see TypeError: only 0-dimensional arrays can be converted to Python scalars (e.g., in yakut monitor) after a NumPy upgrade, try pinning NumPy to 2.3.5.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ros2_cyphal_bridge-0.3.0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ros2_cyphal_bridge-0.3.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file ros2_cyphal_bridge-0.3.0.tar.gz.

File metadata

  • Download URL: ros2_cyphal_bridge-0.3.0.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for ros2_cyphal_bridge-0.3.0.tar.gz
Algorithm Hash digest
SHA256 41b82407005384b2997b2772dab6526e817a95222b53d0b2f4896ea4bab95a6f
MD5 a155fe1f065377b9dc26612b71f8a9ee
BLAKE2b-256 b251f80b38ece12676578be697721bda884ee5965c147a46b43c0736bf0ea2fa

See more details on using hashes here.

File details

Details for the file ros2_cyphal_bridge-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ros2_cyphal_bridge-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 126aaeaa286049777ea5195235d297ff7d0815c9a3b3320b8dad4c072ebd05c2
MD5 f9e1ddf2574c2e0550ec0076bafa943a
BLAKE2b-256 79f6d8b29a9b7e9bfb0401e162670d9405f174860dd167becee07653a7c8ec37

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page