![]() |
ros2_control - rolling
|
Tutorial 5: Base Velocity Plugin
This tutorial demonstrates driving a mobile/floating-base robot with BaseVelocityPlugin.
The mobile base is a free-floating, wheeled chassis (MJCF <freejoint>) carrying a
Because the override is kinematic, it outranks the physics engine: the mounted arm's
reaction forces as it swings have no effect on the base's velocity, but neither does
colliding with the wall in the scene -- see doc/tutorials.rst (Tutorial 5) and
mobile_base.xml for the full rationale.
Key concepts:
- BaseVelocityPlugin: hard free-joint velocity override, applied by writing directly into
data->qvel during update()
- Driving a MJCF <freejoint> body from a cmd_vel-style topic
- Disturbance immunity: the override holds the commanded velocity (zero, by default)
- Floating-base odometry publishing (mujoco_ros2_control's odom_free_joint_name)
Resources used:
- demo_resources/scenes/scene_mobile_base.xml (scene with mobile base + wall obstacle)
- demo_resources/mobile_base/mobile_base.xml (MJCF chassis+arm with wheels and freejoint)
- demo_resources/mobile_base/mobile_base.urdf (URDF with the arm's ros2_control joint)
- config/mujoco_ros2_control_plugins_base_velocity.yaml (BaseVelocityPlugin configuration)
- config/controllers_base_velocity.yaml (joint_state_broadcaster + arm_position_controller)
Usage:
ros2 launch mujoco_ros2_control_demos 05_base_velocity_plugin.launch.py
ros2 launch mujoco_ros2_control_demos 05_base_velocity_plugin.launch.py headless:=true
Drive the base:
ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.5}, angular: {z: 0.2}}" --rate 10
Swing the arm back and forth (with no cmd_vel active, the base should stay close to put):
ros2 topic pub /arm_position_controller/commands std_msgs/msg/Float64MultiArray "data: [0.7]"
ros2 topic pub /arm_position_controller/commands std_msgs/msg/Float64MultiArray "data: [-0.7]"
Watch odometry:
ros2 topic echo /simulator/floating_base_state