How atinfinity/toio_ros2 works
Purpose and runtime
toio_ros2 is a ROS 2 Python package that bridges a Bluetooth-connected toio Core Cube into standard ROS interfaces. It targets Ubuntu 24.04 / ROS 2 Jazzy and relies on the external toio.py library for cube communication. Package metadata and Python installation are defined in package.xml and setup.py.
Entry points and deployment
The main runtime node is toio_ros2/toio_ros2_node.py. Normal deployment uses the ROS launch entry point launch/toio_ros2_bringup.launch.py, which starts the node and supplies a play-mat parameter file. RViz visualization is supported through rviz/toio.rviz.
ROS command ingress
The node accepts velocity and pose goals at ROS boundaries:
• /cmd_vel (geometry_msgs/msg/Twist) for direct desired linear/angular motion.
• /goal_pose (geometry_msgs/msg/PoseStamped) for desired map-frame positioning.
These inputs enter the control logic in toio_ros2/toio_ros2_node.py, where ROS-level commands must be translated into cube motion commands through toio.py.
Cube connection and hardware boundary
toio_ros2/toio_ros2_node.py owns the hardware integration boundary: connecting to the toio Core Cube, reading its position-ID and battery state, and issuing motor/control commands. Bluetooth transport and device protocol behavior are delegated to the external toio.py runtime rather than implemented in this repository.
Pose normalization and coordinate model
Physical position-ID coordinates from the play mat are converted into a ROS map-coordinate system using configurable field bounds and physical dimensions. The launch flow defaults to A4 mat calibration in params/toio_a4_play_mat_params.yaml; an A3 alternative is available at params/toio_a3_play_mat_params.yaml. This parameterized transform is the key portability boundary between toio hardware mats and ROS metric navigation.
ROS state egress and transforms
The node publishes cube state as:
• /toio/pose (PoseStamped) in the map frame.
• /toio/battery_level (Float32).
• TF transform from map to center.
Publishing and TF broadcast behavior are implemented in toio_ros2/toio_ros2_node.py. Consumers such as RViz, teleoperation, or navigation-oriented ROS nodes interact only through these ROS topics and frames.
Launch configuration and visualization
launch/toio_ros2_bringup.launch.py exposes a params_file launch argument and defaults it to the A4 calibration YAML. This separates site-specific mat geometry from node code. rviz/toio.rviz provides the expected visualization setup for the published pose and transform tree.
Main entry points: toio_ros2_node.py toio_ros2 node · toio_ros2_bringup.launch.py Bringup launch · setup.py Python setup · toio.rviz RViz setup
Components 16
Deployment
- Package metadata · Defines package metadata and Python installation.
package.xml - Python setup
setup.py - Bringup launch · Starts the bridge with a selectable mat calibration.
launch/toio_ros2_bringup.launch.py - A4 mat calibration · Default play-mat geometry and field bounds.
params/toio_a4_play_mat_params.yaml - A3 mat calibration · Alternative play-mat geometry and field bounds.
params/toio_a3_play_mat_params.yaml - RViz setup · Visualizes published pose and transform tree.
rviz/toio.rviz
ROS interfaces
- /cmd_vel · Direct desired linear and angular motion.
- /goal_pose · Desired map-frame position.
- /toio/pose · Cube pose in the map frame.
- /toio/battery_level
- map → center TF
Bridge node
- toio_ros2 node · Owns ROS interfaces, cube I/O, state publication, and TF broadcast.
toio_ros2/toio_ros2_node.py - Command translation · Converts Twist and pose goals into cube motion commands.
toio_ros2/toio_ros2_node.py - Pose normalization · Converts position-ID coordinates to metric map coordinates.
toio_ros2/toio_ros2_node.py
Cube hardware
- toio.py · Provides Bluetooth transport and cube protocol behavior.
- toio Core Cube · Provides position-ID and battery state and receives motor commands.
Connections 19
- Package metadata → Python setup: packages
- Python setup → toio_ros2 node: installs
- Bringup launch → toio_ros2 node: starts
- A4 mat calibration → Bringup launch: default params_file
- A3 mat calibration → Bringup launch: alternative params_file
- Bringup launch → Pose normalization: loads calibration
- /cmd_vel → Command translation: velocity command
- /goal_pose → Command translation: pose goal
- Command translation → toio_ros2 node: cube control
- toio_ros2 node → toio.py: uses
- toio.py → toio Core Cube: Bluetooth protocol
- toio Core Cube → toio.py: position-ID and battery
- toio.py → toio_ros2 node: cube state
- toio_ros2 node → Pose normalization: physical coordinates
- Pose normalization → /toio/pose: map-frame pose
- Pose normalization → map → center TF: map to center
- toio_ros2 node → /toio/battery_level: battery state
- /toio/pose → RViz setup: visualizes
- map → center TF → RViz setup: visualizes