Skip to main content

Getting Started with Pinocchio and MeshCat for reBot Arm B601-DM

traj_sim_geodesic

Pinocchio is an open-source library for robotics dynamics analysis and optimization. It provides efficient forward/inverse kinematics, dynamics calculations, and trajectory planning capabilities. MeshCat is a web-based 3D visualization tool that can display robot status and motion trajectories in real-time.

This project combines Pinocchio's powerful computing capabilities with MeshCat's intuitive visualization, providing a complete set of kinematic analysis and debugging tools for reBot Arm B601-DM.


Project Features

  1. Complete Kinematic Analysis
    Supports Forward Kinematics (FK) and Inverse Kinematics (IK) calculations, able to solve the robot arm's end-effector pose in real-time.

  2. Real-time 3D Visualization
    Displays robot arm status and motion trajectories in real-time through MeshCat in the browser, no additional software required.

  3. Trajectory Planning and Tracking
    Implements SE(3) geodesic trajectory planning, supporting CLIK (Closed-Loop Inverse Kinematics) tracking control.

  4. Gravity Compensation Control
    Calculates joint gravity torque based on Pinocchio dynamics model, achieving the "floating" effect of the robot arm.

  5. Open Source & Extensible
    All code is open source, supporting users to customize control algorithms and visualization effects according to their needs.

Specifications

The hardware for this tutorial is provided by Seeed Studio

ParameterSpecification
Robot Arm ModelreBot Arm B601-DM
Degrees of Freedom6-DOF + Gripper
Motor ModelDamiao DM4340 / DM4310
Communication MethodCAN Bus via USB-CAN Adapter
Operating Voltage24V DC
Control MethodPC
Recommended Operating Temperature Range0°C ~ 40°C

Bill of Materials (BOM)

ComponentQuantityIncluded
reBot Arm B601-DM Robotic Arm1
USB2CAN Serial Bridge1
Power Adapter (24V)1
USB-C Cable1
Gripper1
caution

Seeed Studio is only responsible for hardware quality. The tutorial is updated in strict accordance with official documentation. If you encounter unsolvable software or environmental issues, please consult the FAQ at the end of the document first, or contact customer service to join the SeeedStudio Lerobot communication group for inquiries.


Environment Requirements

ItemRequirement
Python3.10+
Operating SystemUbuntu 22.04+
Communication InterfaceUSB2CAN Serial Bridge or CAN Interface

Installation Steps

Step 1. Install uv (if not installed)

curl -LsSf https://astral.sh/uv/install.sh | sh

Step 2. Sync Environment (Install All Dependencies)

git clone https://github.com/vectorBH6/reBotArm_control_py.git
cd reBotArm_control_py
uv sync
tip

uv sync will automatically create a virtual environment (if it doesn't exist) and install all dependencies according to pyproject.toml and uv.lock.


Debug Tools

Single Motor Console (1_damiao_text.py)

Direct motorbridge SDK single motor testing.

Usage:

uv run python example/1_damiao_text.py

Interactive Commands:

CommandDescription
enable / disableEnable/Disable
set_zeroSet zero position
stateView state

Zero Calibration & Angle Monitor (2_zero_and_read.py)

Automatically set all joint zeros and display joint angles in real-time.

Usage:

uv run python example/2_zero_and_read.py

Kinematics Tests

Forward Kinematics Test (5_fk_test.py)

Calculate end-effector pose from joint angles.

Input: 6 joint angles (degrees)

Output:

  • End-effector position (X, Y, Z) — Unit: meters
  • Rotation matrix (3×3)
  • Euler angles (Roll/Pitch/Yaw) — Unit: degrees

Example:

uv run python example/5_fk_test.py
> 0 0 0 0 0 0
> 45 -30 15 -60 90 180

Inverse Kinematics Test (6_ik_test.py)

Solve joint angles from desired end-effector pose.

Input Format:

  • Position only: <x> <y> <z> (meters)
  • Position + Orientation: <x> <y> <z> <roll> <pitch> <yaw> (degrees)

Example:

uv run python example/6_ik_test.py
> 0.25 0.0 0.15 # Position only
> 0.25 0.0 0.15 0 0 0 # Position + Orientation

Simulation Environment

Forward Kinematics Simulation (sim/fk_sim.py)

Interactive forward kinematics simulation, visualize robot arm pose by inputting joint angles in MeshCat.

Usage:

uv run python example/sim/fk_sim.py

Interactive Commands:

  • Input 6 joint angles (degrees), space separated
  • Example: 0 0 0 0 0 0
  • Example: 45 -30 15 -60 90 -180
  • q/quit/exit: Exit

Features:

  • Real-time display of end-effector position and orientation
  • Supports continuous input to test different poses
  • Formatted pose information output

Inverse Kinematics Simulation (sim/ik_sim.py)

Interactive inverse kinematics simulation, automatically solve joint angles from target pose and visualize.

Usage:

uv run python example/sim/ik_sim.py

Input Format:

  • Position only: x y z (meters)
  • Position+Orientation: x y z roll pitch yaw (radians)

Example:

> 0.25 0.0 0.25              # Position only
> 0.25 0.0 0.25 0 0 0 # Position+Orientation

Features:

  • Automatic judgment of IK convergence
  • Display iteration count and error
  • Real-time robot pose updates

Trajectory Planning Simulation (sim/traj_sim.py)

SE(3) geodesic based trajectory planning simulation, including CLIK tracking and MeshCat animation playback.

Usage:

uv run python example/sim/traj_sim.py

Interactive Commands:

  • Input: x y z [roll pitch yaw] (meters/radians)
  • Press Enter to use default configuration
  • q: Exit

Features:

  • Plan from current position to target position
  • Use minimum jerk trajectory profile
  • Real-time display of trajectory statistics
  • Complete trajectory animation playback in MeshCat
  • Display reference path (gray) and actual path (green)

Visualizer Tool (sim/visualizer.py)

MeshCat visualizer wrapper, providing unified robot display interface.

Main Features:

  • Load URDF model and display robot
  • Draw 3D polyline paths (reference/actual)
  • Display IK target pose (tricolor axes + sphere)
  • Support joint trajectory animation playback

Usage Example:

from example.sim.visualizer import Visualizer
viz = Visualizer()
viz.update(q) # Update robot pose
viz.draw_path(points, "path_name", color) # Draw path

Real Machine Control

Permission Setup

Before running real machine control examples, you need to set device permissions:

# Set serial device permission (Damiao USB2CAN)
sudo chmod 666 /dev/ttyACM0

# Or for CAN interface (e.g., can0)
sudo chmod 666 /dev/can0

IK Real-time Control (7_arm_ik_control.py)

Real-time end-effector control based on IK solver.

Interactive Commands:

CommandDescription
x y z [roll pitch yaw]Target end-effector pose
stateView state
posCurrent end-effector position
q/quit/exitExit

Usage:

uv run python example/7_arm_ik_control.py
> 0.3 0.0 0.2
> 0.3 0.1 0.25 0 0.5 0

Trajectory Planning Control (8_arm_traj_control.py)

SE(3) geodesic trajectory planning + CLIK tracking.

Input Format:

x y z [roll pitch yaw] [duration]

Parameters:

  • x, y, z: Target position (meters)
  • roll, pitch, yaw: Target orientation (radians)
  • duration: Movement duration (seconds), default 2.0s

Usage:

uv run python example/8_arm_traj_control.py
> 0.3 0.0 0.3 0 0.4 0 2.0

Gravity Compensation Control (9_gravity_compensation.py)

Compensates for joint gravity using Pinocchio dynamics model.

Control Law:

tau = g(q)          — Gravity feedforward
pos = current motor position — Joint position follows current position
kp = 2, kd = 1 — Unified stiffness/damping for all joints

Expected Behavior:

  • The robotic arm can "float" in any posture
  • Won't fall due to its own weight when released
  • Can be manually moved to any position

Usage:

uv run python example/9_gravity_compensation.py

Output:

  • Real-time display of expected torque for each joint (N·m)
  • Press Ctrl+C to stop and disconnect

FAQ

  • Encountering Permission denied error
    Ensure you have executed sudo chmod 666 /dev/ttyACM0 or sudo chmod 666 /dev/can0 to set device permissions.

  • IK solving fails or results are abnormal
    Check if the target pose is within the robot arm's workspace, ensure joint limit configuration is correct.

  • Gravity compensation effect is not good
    This may be caused by structural errors and processing accuracy. The gravity compensation of this project depends on urdf and pinocchio. You can try to correct urdf to your actual measured parameters (you can ask ai for this step).


License

This project is open source under the MIT License.


Contact Us


Reference Documents


If this project helps you, please give us a Star!
Loading Comments...