How myersjm/mecademic-ros2 works
Purpose and execution model
This ROS 2 Humble workspace controls two Mecademic Meca500 R3 arms, plans collision-aware joint trajectories for their shared workcell, and visualizes plans before execution. Primary executables are the per-robot driver, central planner, and application/control client:
• meca_ws/src/meca_controller/meca_controller/meca_driver.py
• meca_ws/src/meca_motion_planner/meca_motion_planner/motion_planner.py
• meca_ws/src/meca_controller/meca_controller/meca_control.py
ROS package boundary and contract
custom_interfaces is the wire contract between controller clients, robot drivers, and the planner. It defines motion-plan/status messages and services for pose/joint motion, gripper control, planner requests, and visualization:
• meca_ws/src/custom_interfaces/msg/MotionPlan.msg
• meca_ws/src/custom_interfaces/srv/GetMotionPlan.srv
• meca_ws/src/custom_interfaces/srv/GoToPose.srv
The system runs two instances of the driver under separate ROS namespaces (normally /robot1 and /robot2), isolating each arm’s services and state topics while the planner reasons about both arms jointly.
Physical robot driver
The driver is the hardware-facing ROS node. It connects to an arm through MecademicPy, publishes robot/gripper state, and exposes services for movement and runtime settings such as joint velocity, acceleration, blending, gripper force, and gripper velocity:
• meca_ws/src/meca_controller/meca_controller/meca_driver.py
• meca_ws/src/meca_controller/meca_controller/meca_settings.py
• meca_ws/src/custom_interfaces/msg/RobotStatus.msg
Robot IP addresses, namespaces, and fallback/rest configurations are centralized in meca_settings.py. This is the safety-critical boundary where planned commands ultimately become physical motion; physical robot joint commands use degrees.
Application/control client
meca_control is the intended user-program entry point. It coordinates ROS service calls: obtain and optionally visualize a motion plan, then invoke namespaced driver services to execute robot and gripper commands:
• meca_ws/src/meca_controller/meca_controller/meca_control.py
• meca_ws/src/custom_interfaces/srv/MoveJoints.srv
• meca_ws/src/custom_interfaces/srv/VisualizeMotionPlan.srv
It separates task-level sequencing from hardware communications and planning implementation.
Joint planning pipeline
The planner node accepts planning/visualization service requests, builds a collision-free path through joint space, and returns a MotionPlan. Bidirectional RRT generates feasible paths; shortcutting reduces unnecessary waypoints:
• meca_ws/src/meca_motion_planner/meca_motion_planner/motion_planner.py
• meca_ws/src/meca_motion_planner/meca_motion_planner/bidirectional_rrt.py
• meca_ws/src/meca_motion_planner/meca_motion_planner/shortcutting.py
Planner and visualization inputs use radians, unlike the driver’s physical-robot command convention. The plan should be previewed and executed at low velocity due to known model-vs-real-world clearance limitations.
Combined collision and visualization model
RobotModel constructs the shared kinematic/collision world: two instances of the arm model plus the fixed environment, including their extrinsic transforms. Pinocchio supplies kinematics/collision checking and Meshcat provides visualization:
• meca_ws/src/meca_motion_planner/meca_motion_planner/robot_model.py
• meca_ws/src/resources/meca/meca.urdf
• meca_ws/src/resources/environment/environment.urdf
The model is the key planning boundary: calibration changes alter robot-to-robot placement; environment URDF changes alter obstacles. Mesh/STL assets back these URDF collision and visual geometries.
Runtime and infrastructure
The workspace is built with colcon and contains Python ROS packages plus a CMake-built interface package. Runtime requires ROS 2 Humble/Ubuntu 22.04, Python 3.10 virtualenv setup, Pinocchio (pin), Meshcat, and MecademicPy. Environment initialization is captured in:
• meca_ws/meca_setup.sh
• meca_ws/src/meca_controller/setup.py
• meca_ws/src/meca_motion_planner/setup.py
Main entry points: motion_planner.py motion_planner · meca_driver.py meca_driver ×2 · meca_control.py meca_control · robot_model.py RobotModel
Components 17
Control & Hardware
- meca_control · Sequences planning, preview, and execution.
meca_ws/src/meca_controller/meca_controller/meca_control.py - meca_driver ×2 · One hardware-facing instance runs per arm namespace.
meca_ws/src/meca_controller/meca_controller/meca_driver.py - Robot settings · Centralizes IPs, namespaces, and fallback configurations.
meca_ws/src/meca_controller/meca_controller/meca_settings.py - Meca500 R3 arms · Driver commands use joint degrees.
Joint Planning
- motion_planner · Serves plan and visualization requests in radians.
meca_ws/src/meca_motion_planner/meca_motion_planner/motion_planner.py - Bidirectional RRT
meca_ws/src/meca_motion_planner/meca_motion_planner/bidirectional_rrt.py - Path shortcutting
meca_ws/src/meca_motion_planner/meca_motion_planner/shortcutting.py
Shared Cell Model
- RobotModel · Combines both arms, extrinsics, and fixed environment.
meca_ws/src/meca_motion_planner/meca_motion_planner/robot_model.py - Arm URDF
meca_ws/src/resources/meca/meca.urdf - Environment URDF
meca_ws/src/resources/environment/environment.urdf - Meshcat
ROS Contract
- custom_interfaces · Wire contract shared by clients, planner, and drivers.
- MotionPlan
meca_ws/src/custom_interfaces/msg/MotionPlan.msg - GetMotionPlan
meca_ws/src/custom_interfaces/srv/GetMotionPlan.srv - GoToPose
meca_ws/src/custom_interfaces/srv/GoToPose.srv - RobotStatus
meca_ws/src/custom_interfaces/msg/RobotStatus.msg - MoveJoints & visualization · Control-client execution and preview service contracts.
meca_ws/src/custom_interfaces/srv/MoveJoints.srv
Connections 20
- meca_control → motion_planner: requests plan / preview
- meca_control → meca_driver ×2: calls namespaced motion and gripper services
- motion_planner → Bidirectional RRT: generates feasible path
- Bidirectional RRT → Path shortcutting: raw waypoint path
- Path shortcutting → motion_planner: reduced trajectory
- motion_planner → RobotModel: collision queries
- motion_planner → Meshcat: visualizes plan
- RobotModel → Arm URDF: two arm instances
- RobotModel → Environment URDF: fixed obstacles
- meca_driver ×2 → Robot settings: loads connection and safety defaults
- meca_driver ×2 → Meca500 R3 arms: MecademicPy commands
- Meca500 R3 arms → meca_driver ×2: robot and gripper state
- custom_interfaces → MotionPlan: defines
- custom_interfaces → GetMotionPlan: defines
- custom_interfaces → GoToPose: defines
- custom_interfaces → RobotStatus: defines
- custom_interfaces → MoveJoints & visualization: defines
- meca_control → custom_interfaces: uses contract
- motion_planner → custom_interfaces: uses contract
- meca_driver ×2 → custom_interfaces: uses contract