RoArm-M3 Drive Node to Control Real-world Robotic Arm

From Waveshare Wiki
Jump to: navigation, search
RoArm-M3
RoArm-M3
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Drive Node to Control Real-world Robotic Arm

3.1 View Serial Port Device When Robotic Arm is Connected

  1. Press Ctrl+Alt+T on the Ubuntu virtual machine to open the terminal, and before viewing the current Ubuntu serial device, you need to first execute the ros_humble.sh file and enter it into the container, which has already deployed the ROS2 Humble environment.
  2. Ros2.png
  3. View the current Ubuntu serial devices. At this point, there is no need to connect the robotic arm to the computer using a USB cable.
  4. ls /dev/tty*
  5. First, connect the robotic arm to the power source, turn on the power switch on the robotic arm drive board, and connect the robotic arm to the computer using a USB cable. Note that you should connect to the Type-C interface in the middle of the drive board (the Type-C interface on the edge is for communication with the radar and does not communicate with the ESP32).

  6. Click on Devices → USB in Oracle VM VirtualBox, and find the device named CP210x. and the device name is preceded by a √ to indicate that the controller is connected to the virtual machine. If a checkmark (✓) appears before the device name, it indicates that the robotic arm is connected to the virtual machine.
  7. M2-S连接串口.png
    If you connect the serial port device of the robotic arm, a prompt box pops up on the right that you cannot mount the device, and the system of the virtual machine will be shut down.
    Firstly, ensure that your host (Windows system) can detect the USB device of the robotic arm.
    In the settings of this system image, find the USB device, check Enable USB Controller, select USB 3.0 (xHCI) controller, then click the second icon on the right to add a USB filter, select the device with the words CP210x, and click OK.
    Run the image again, click on the device -> USB -> check if there is a check mark in front of the device with the words CP2102N USB at the top of the window. If there is, it means the mounting is successful.
    
  8. Check the current Ubuntu serial device in the terminal again, and you can see that there is a new device name of /dev/ttyUSB0 at this time, which represents the port number connected to the robotic arm.
  9. Ls dev.png


3.2 Change Serial Device

In our demo, the default serial device name is /dev/ttyUSB0. If the serial device name of the robotic arm seen in the previous section is /dev/ttyUSB0, you can skip this section and proceed directly to the next section.

If the serial device name you found is not /dev/ttyUSB0, you need to change it. Open the roarm_driver.py script file in the /home/ws/roarm_ws/src/roarm_main/roarm_driver/roarm_driver/ directory, and change /dev/ttyUSB0 to the serial device name that your robotic arm can see as shown below. After making the changes, click "Save" in the upper right corner to save and close the file.

M2-S更改串口设备名-1.png


3.3 Run Robotic Arm Drive Node

  1. To communicate with serial devices using Python scripts in Ubuntu, read and write permissions need to be granted to the serial devices. Enter the following command in the virtual machine terminal to grant serial port permissions:
    sudo chmod 666 /dev/ttyUSB0 (The password is the system default password: ws)
    If the command fails, refer to sections 3.1 and 3.2 to determine if the serial port device number is correct and if the robotic arm is connected to the virtual machine system.
  2. Next, compile the function package of the robotic arm ROS2, which needs to be compiled in the corresponding workspace:
    cd /home/ws/roarm_ws/
    colcon build
    source install/setup.bash

    Note: The robotic arm driver library in the virtual machine image needs to be updated

    pip install roarm-sdk==0.1.0
  3. Press Ctrl+Alt+T to open a new terminal window, enter the workspace of the ROS2 robotic arm, and run the ROS2 robotic arm drive node:
    cd /home/ws/roarm_ws/
    ros2 run roarm_driver roarm_driver

    The following feedback indicates successful operation. At this time, the joint interface of the ROS2 model is not open, so there is no other feedback:

    Driver2.png

Do not close the terminal interface of the successfully running robotic arm drive node, and then open the joint interface of the robotic arm model in ROS2 according to the content in section 3.4. In the subsequent tutorial operations, you need to keep the robotic arm driver node running. If you accidentally terminate the process, you need to run the robotic arm drive node again.

3.4 View Robotic Arm Model Joints

Here's how the ROS2 Rviz2 tool was used to show the robotic arm model and the joint angle control panel. Rviz2 is a visualization tool for ROS2 that can be used to display and debug robot models, sensor data, planning paths, and more. With Rviz2, we can intuitively see the movement status and current position of the robotic arm. Additionally, Rviz2 provides some tools such as 3D views, timeline, parameter tuning, etc., to help us better understand the behavior of the robot.

Note: After executing this command, the robotic arm will rotate (with the upper arm and lower arm vertically upwards), please do not place fragile items around the robotic arm and keep away from children.

Press Ctrl+Alt+T to open a new terminal window, enter the workspace of ROS2 of the robotic arm, and start the Rviz2 model interface:

cd /home/ws/roarm_ws/
ros2 launch roarm_description display.launch.py

After starting Rviz2, the robot URDF in Rviz2 publishes each joint angle of the robotic arm to the drive node, and the drive node will edit these joint angles into the corresponding JSON format control commands and send them to the robotic arm, so the robotic arm will rotate.

Run the robotic arm drive node and view the joint terminal interface of the robotic arm model. The left side is the operation interface of the robotic arm drive node, and the right side is the interface for viewing the Rviz2 robotic arm model joint:

1200px-Rviz.png

If the following errors occur while running the robotic arm drive node, it is necessary to execute xhost + on the host terminal, start the X server, and then execute the robotic arm drive node on the container terminal;

Erro5.png Xhost.png

Click on the gear icon on the left, and the joint angle control panel will appear above the Rviz2 model interface:

1200px-Rviz3.png

  • You can control the rotation of each joint of the robotic arm by dragging and dropping the sliders on the control panel;
  • Center —— Restore to the initial position when the Rviz2 model interface was started;
  • Randomize —— The robotic arm randomly moves to a certain position.


3.5 Rviz 2 Robotic Arm Viewing Angle Operation

In Rviz 2, the mouse can be used to adjust the viewing angle of observing the robot model.

  • Left-click and drag to adjust the viewing view horizontally within the horizontal plane.
  • Right-click and drag to change the direction and angle of viewing.
  • Scroll the mouse wheel to adjust the viewing distance, i.e., to zoom in or out of the view.
  • Hold the middle mouse button (scroll wheel) and drag to move within the plane perpendicular to the current viewing direction.

By using these operations, you can observe the robot model from any angle and distance.