RoArm-M2-S 3. Drive Nodes to Control Real-world Robotic Arm

From Waveshare Wiki
Jump to: navigation, search
RoArm-M2-S 3. Drive Nodes to Control Real-world Robotic Arm
RoArm-M2-S.jpg

I2C, UART
TTL Serial Bus Servo Control Interface,
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

3. Drive Nodes to Control Real-world Robotic Arm

3.1 View the Serial Devices Connected to Robotic Arm

  1. Press "Ctrl+Alt+T" on the Ubuntu to open the terminal, and view the current connected serial devices. Note that do not connect the robotic arm to the PC with a USB cable now.
  2. ls /dev/tty*
  3. Connect the power supply to the robotic arm, turn on the switch of the robotic arm's driver board. Connect the robotic arm to the PC with a USB cable. Note that the Type-C interface is in the middle of the driver board (the Type-C interface on the edge is for radar communication and is not for ESP32 communication).
  4. Click on "Device" on the top of Oracle VM VirtualBox → "USB" → the device name with the word "CP210x". If displays in the front the device name, it means the robotic arm is successfully connected to the vitual machine.

  5. M2-S SERIAL2.png
    If when connecting the serial device of the robotic arm, a pop-up box on the right reminds cannot be mounted to this device, you can try to shut down the system of the virtual machine.
    First of all, make sure your host computer (Windows system) can detect the USB device of the robot arm.
    In the settings of this system image, find USB devices, check Enable USB controller, select USB 3.0(xHCI) controller, then click the second icon on the right side to add a USB filter, select the device with the word CP210x, click OK.
    Run the image again, click Device → USB → Check if the device with the word "CP2102N USB" has a check mark in front of it, if it does, it means it is mounted successfully.
    
  6. Looking at the current Ubuntu serial device in the terminal again, you can see that there is an extra device name /dev/ttyUSB0, which represents the port number that the robot arm is connected to.

  7. M2-S 1.png

3.2 Modify Serial Devices

In our demo, the default serial device name is "/dev/ttyUSB0". If the serial device of the robotic arm checked on the last step is "/dev/ttyUSB0", you can skip this step.
If your serial device name is not "/dev/ttyUSB0", you need to modify the serial device name. Open " roarm_driver.py" file under the directory "~/roarm_ws_em0/src/roarm_main/roarm_driver/roarm_driver/ ", you can modify "/dev/ttyUSB0" as the one checked on the robotic arm. After modification, you can click on "Save" on the top right and then close it.
M2-S modify name.png

3.3 Drive Nodes of Robotic Arm

  1. To communicate with a serial device using Python scripts in Ubuntu, you need to give read and write permissions to the serial device, enter the following command in the virtual machine terminal to grant serial port permissions:
    sudo chmod 666 /dev/ttyUSB0  (the default system password: ws)
    If this command reports an error, refer to subsections 3.1 and 3.2 to determine if the serial device number is correct and if the robot arm is connected to the VM system.
  2. Next, we compile the function packages for the robot arm ROS2. Compiling the function packages needs to be done in the corresponding workspace:
    cd ~/roarm_ws_em0/
    colcon build
    source install/setup.bash
  3. Press Ctrl+Alt+T to open a new terminal window, enter the workspace of the robotic arm ROS2, and run the ROS2's robotic arm drive node:
    cd ~/roarm_ws_em0/
    ros2 run roarm_driver roarm_driver

    The following feedback means that the run was successful. The ROS2 model joint interface is not open at this time, so there is no other feedback:
    M2-S nodes.png

Do not close the terminal interface of the successfully running robot arm driver node, and then open the robot arm model joint interface in ROS2 according to subsection 3.4. In the following tutorials, you need to keep the robot arm driver node running and re-run the robot arm driver node if you end the process accidentally.

3.4 View Robotic Arm Model Joints

Here is a demonstration of the robotic arm model and the joint angle control panel using the ROS2 Rviz2 tool, a visualization tool for ROS2 that can be used to display and debug a variety of information about the robot model, sensor data, planning paths, and more. With Rviz2, we can visualize the motion status and current position of the robot arm. In addition, Rviz2 provides some tools, such as 3D view, timeline, parameter adjustment, etc., to help us better understand the robot's behavior.
Note: After executing this command, the arm will rotate (all vertically upward), please do not place fragile products around the arm and keep it away from children.

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

cd ~/roarm_ws_em0/
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 driver node, which edits these joint angles into the corresponding JSON-formatted control commands and sends them to the robotic arm, which therefore rotates. At the same time, you can also see the information about each joint angle of the robot arm appearing on the driver node of the running robot arm.
Run the robotic arm drive node and view the robotic arm model joint terminal interface, the left side is the interface for running the robotic arm drive node and the right side is the interface for viewing the Rviz2 robotic arm model joint:
M2-S查看模型关节.png
By clicking on the gear icon on the left, the joint angle control panel will appear above the Rviz2 model interface:
M2-S查看模型关节1.png

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

3.5 Robotic Arm Viewpoint Operation in Rviz2

In Rviz2, you can use the mouse to adjust the viewing angle of the robot model.

  • Left-click and drag to move the view in 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. zoom in or out of the view.
  • Pressing the middle mouse button (i.e. the scroll wheel button) and dragging allows you to move in the plane of the vertical viewing direction.

Using these operations, you can view the robot model from any angle and distance.

RoArm-M2-S ROS2 Humble + Moveit2 Tutorial