pymoveit2 Documentation

repository·main·Indexed 18 days ago

https://github.com/andrejorsula/pymoveit2

A basic Python interface for MoveIt 2 built on ROS 2 actions and services. It provides high-level abstractions for joint goals, pose goals, gripper control, and real-time Cartesian control via MoveIt 2 Servo. Compatible with ROS 2 Galactic, Humble, and Iron distributions.

Tokens
858
Snippets
2
Records
3
Agent score
13%

What's inside pymoveit2

  1. Overview of pymoveit2 core interfaces

    main

    The pymoveit2 package provides several Python interfaces for interacting with MoveIt 2 via ROS 2 actions and services:

    • moveit2.py: The primary interface for planning and executing trajectories.
    • moveit2_gripper.py: Interface for grippers controlled by a JointTrajectoryController.
    • gripper_command.py: Interface for grippers controlled by GripperCommand.
    • moveit2_servo.py: Interface for MoveIt 2 Servo, enabling real-time control in Cartesian space.
  2. Install and build pymoveit2

    main

    To use pymoveit2, clone the repository into your ROS 2 workspace, install dependencies using rosdep, and build using colcon.

    Prerequisites:

    • ROS 2 (Galactic, Humble, or Iron)
    • MoveIt 2 (matching your ROS 2 distribution)

    Steps:

    1. Clone the repository.
    2. Install dependencies via rosdep.
    3. Build with colcon using --merge-install and --symlink-install to ensure proper module importing.
    4. Source the workspace to enable importing the pymoveit2 module.
    # Clone this repository into your favourite ROS 2 workspace
    git clone https://github.com/AndrejOrsula/pymoveit2.git
    
    # Install dependencies
    rosdep install -y -r -i --rosdistro ${ROS_DISTRO} --from-paths .
    
    # Build
    colcon build --merge-install --symlink-install --cmake-args "-DCMAKE_BUILD_TYPE=Release"
    
    # Sourcing
    source install/local_setup.bash
  3. Run pymoveit2 examples

    main

    Before running examples, you must have a robot control environment running. You can use RViz (fake control) or Gazebo (simulated control) via launch scripts from the panda_moveit_config package.

    1. Start the controller:

    • For RViz (fake control): ros2 launch panda_moveit_config ex_fake_control.launch.py
    • For Gazebo (simulated control): ros2 launch panda_moveit_config ex_gz_control.launch.py

    2. Run the scripts: Use ros2 run pymoveit2 <script_name>.py with ROS 2 parameters (--ros-args -p) to configure goals.

    # Example: Move to joint configuration
    ros2 run pymoveit2 ex_joint_goal.py --ros-args -p joint_positions:="[1.57, -1.57, 0.0, -1.57, 0.0, 1.57, 0.7854]"
    
    # Example: Move to Cartesian pose
    ros2 run pymoveit2 ex_pose_goal.py --ros-args -p position:="[0.25, 0.0, 1.0]" -p quat_xyzw:="[0.0, 0.0, 0.0, 1.0]" -p cartesian:=False
    
    # Example: Toggle gripper
    ros2 run pymoveit2 ex_gripper.py --ros-args -p action:="toggle"
    
    # Example: Add a primitive collision object (sphere)
    ros2 run pymoveit2 ex_collision_primitive.py --ros-args -p shape:="sphere" -p position:="[0.5, 0.0, 0.5]" -p dimensions:="[0.04]"