Skip to content

Latest commit

 

History

History
120 lines (97 loc) · 3.77 KB

usingURDF.md

File metadata and controls

120 lines (97 loc) · 3.77 KB

This package provides a ROS2 for visualizing and controlling a robot arm using URDF and RViz.

ros2.robot.arm.package.mov
ros2

🔢 Steps

⚠️ 1. Prerequisites

  • Ensure you have ROS2 Foxy installed on your system, and install the necessary dependencies:
sudo apt update
sudo apt install ros-foxy-ament-cmake ros-foxy-urdf ros-foxy-rviz2 ros-foxy-robot-state-publisher ros-foxy-joint-state-publisher ros-foxy-joint-state-publisher-gui

💻 2. Create a ROS2 Workspace

  1. Source ROS 2 environment:
    source /opt/ros/foxy/setup.bash
  2. Create a new directory:
    mkdir -p ~/ros2_ws/src
    cd ~/ros2_ws/src
  3. Initialize the workspace:
    colcon build
    source install/setup.bash
image ---- ### 📦 3. Create a Robot Arm Package (using CMake as the build system) 1. Navigate to the src directory of your workspace: ```bash cd ~/ros2_ws/src ``` 2. Create a new package for your robot arm using CMake: ```bash ros2 pkg create --build-type ament_cmake robot_arm_package ``` image

©️ 4. Copy URDF and Mesh Files

  1. Clone the repository:
    cd ~/ros2_ws/src
    git clone https://github.com/smart-methods/arduino_robot_arm.git
  2. Copy the URDF and mesh files:
     mkdir -p ~/ros2_ws/src/robot_arm_package/urdf
     mkdir -p ~/ros2_ws/src/robot_arm_package/meshes
     cp ~/ros2_ws/src/arduino_robot_arm/robot_arm_pkg/urdf/arduino_robot_arm.urdf ~/ros2_ws/src/robot_arm_package/urdf/
     cp -r ~/ros2_ws/src/arduino_robot_arm/robot_arm_pkg/meshes/* ~/ros2_ws/src/robot_arm_package/meshes/
  • 🔗 URDF File: The URDF file describing the robot model.

📂 5. Creating and Updating Files:

  • Update the CMakeLists.txt and package.xml files:
  • Create Launch File to visualize the robot in RViz:
cd ~/ros2_ws/src/robot_arm_package
mkdir -p launch
nano launch/display.launch.py
  • 🔗 Launch File: The launch file to start the robot visualization.

🏗️ 6. Build and Launch

  1. Build the workspace:
cd ~/ros2_ws
colcon build
  1. Source the setup file:
source install/setup.bash
  1. Launch the URDF:
ros2 launch robot_arm_package display.launch.py
RVIZ specs
  • Set the "Fixed Frame":

    • In RViz, go to the "Global Options" section in the "Displays" panel on the left.
    • Set the "Fixed Frame" to base.
  • Add a "RobotModel" Display:

    • In the "Displays" panel, click the "Add" button at the bottom.
    • In the "By display type" tab, select "RobotModel" and click "OK".
    • Set the "Description Topic" to /robot_description.
  1. Using the Joint State Publisher GUI
ros2 run joint_state_publisher_gui joint_state_publisher_gui
gui

Done!! You should now see the robot arm model visualized in RViz and be able to interact with its joints using the Joint State Publisher GUI.