Control the real robot with ROS code - LCAS/RBT1001 GitHub Wiki

Visualising the Joints state

  1. Open a new terminal in VSCode

  2. Check that you can in fact ping the robot: ping tiago-89c.network.uni. If this is not successful, please check your eth connection or restart the network manager.

  3. Launch the connection script for visualisation: ./src/week6/scripts/connect_viz.sh. If it is successful, and you should see the following on your VNC window:

  4. Click "Cancel" and the plotting interface will appear (right-click on the right bottom panel and "Maximize" the window to see if properly):

    Screenshot from 2024-03-07 10-51-01

    Note: if the plot area is all black like in the picture above, open "App" > "Preferences" and disable "OpenGL". Then close and relaunch the application again.

  5. Click on the "Load data window/plots layout" icon on the top-left side, and load the configuration file /workspaces/RBT1001/src/week6/config/plots_conf.xml

8.When asks for "Start the previusly used..." select "Yes"; then filter and select the ROS topic /joint_states; click Okay.

  1. At this point, you should see two plots that are showing the position (top plot) and velocity (bottom plot) of all the robot arm joints. Increase the buffer size to 15 seconds on the left side bar. If the plot does not update in real-time click the "Start" button on the left-hand side.

    Screenshot from 2024-03-07 11-02-23

  2. Launch again the "Wave" and "Home" commands (One at a time) and check the joint position and velocity trajectories. You can click the pause icon (not the "Stop" button) to pause the data stream and better observe the recorded data.

    Screenshot from 2024-03-07 11-14-18

Send joint arm commands to the robot

NOTE: robot commands can be sent only from one dedicated PC in the lab, one at a time.

Every time we ask you to control the robot with your code, you need to:

  1. test it does not fail on your PC;
  2. copy your script to a usb drive and give it to the lecturer;
  3. the lecturer will check your code and execute it on the dedicated PC.

Now you are going to learn how to send commands programmatically using ROS in python.

  1. Open the script src/week6/scripts/joint_command.py in the editor, and launch it from the terminal: python3 /workspaces/RBT1001/src/week6/scripts/joint_command.py
  2. Observe the code for defining a point in the joint space:
        # create joint msg
        msg = JointTrajectory()
        msg.joint_names = [
            "arm_1_joint",
            "arm_2_joint",
            "arm_3_joint",
            "arm_4_joint",
            "arm_5_joint",
            "arm_6_joint",
            "arm_7_joint"
        ]
        # define our target point
        target_point = JointTrajectoryPoint()
        target_point.positions = [
            initial_state.position[0],
            initial_state.position[1],
            initial_state.position[2],
            initial_state.position[3],
            initial_state.position[4],
            initial_state.position[5],
            1.0  # << we are just modifying one joint value, the previous ones remain in the initial configuration
        ]
        target_point.velocities = [0.0] * 7
        target_point.velocities[-1] = 0.5  # << all velocities are 0 but the joint we want to move
        target_point.accelerations = [0.0] * 7 # << all accelerations are zero
        target_point.time_from_start.sec = 3  # << we are asking to arrive at desired point at 3 seconds from start

This program sends two consecutive commands to be executed at certain times from the start. Note that the second has zero velocity, because it represents the end of the trajectory and we want to stop there.

  1. Launch it again with the plotting running and pause the plot to see the trajectories.

  2. Try increasing the arm_7_joint value to 2.0 for the target_point and increase the times to 10 and 20 seconds for the intermediate and final point respectively. Also, increase the Buffer to 25 in the plotting software to be able to plot the entire trajectory. Save and launch the code again, while looking at the plot.

  3. Modify the code to reproduce the "Wave" trajectory by setting the following points (you can approximate the values to 2 decimal points):

      positions: [0.09, -0.679638896132783, -3.1087325315620733, 2.0882339360702575, -1.1201172410014792, -0.031008601325809293, -2.0,
                  0.09, -0.7354151774072313, -2.939624246421942, 1.8341256735249563, -1.1201355028397157, -0.031008601325809293, -2.0,
                  0.09, -0.7231278283145929, -2.9385504456273295, 2.18, -1.1201355028397157, -0.031008601325809293, -2.04,
                  0.09, -0.7354151774072313, -2.939624246421942, 1.8341256735249563, -1.1201355028397157, -0.031008601325809293, -2.0]
      times_from_start: [3, 6, 9, 12]
  1. When you have finished, ask the lecturer to look at the code and give you permission to execute it. Observe the plots and pause it once the movement has finished.

  2. What is the problem with this approach? Did the arm perform any strange/unwanted movements? Why?