JetRacer ROS AI Kit Tutorial V: Robot Movement Control

From Waveshare Wiki
Jump to: navigation, search

JetRacer ROS Kit User Guide

Step 1: Add serial User Group

  • Enter the command ls /dev in jetson nano to check whether the driver board is connected to Jetson normally and whether ttyACM0 and ttyACM1 devices are found 【where ttyACM0 is used to communicate with the microcontroller, and ttyACM1 is used to communicate with the radar】.
 ls /dev    

Jetracer Robot Movement Control01.png

  • Enter the following command to add the serial port user group, otherwise, you will not have permission to operate the serial port. Using the configured system has already added permissions, you can skip this step.
ls -l /dev/ttyACM*             #View the serial port user group as dialout
id -Gn                         #View the user group that the current user belongs to, the first one is the current user
sudo adduser jetbot dialout    #Add the current user to the user group dialout where the serial port is located

Jetracer Robot Movement Control02.png

  • Enter the command "sudo reboot" to restart, the password is jetson 【Note: The above addition command can take effect only after restarting, and when there is no serial port permission, the robot chassis node will always report an error after booting up】.
sudo reboot        #restart jetson nano

Step 2: Start the robot chassis control node

  • Connect SSH to the robot to open the terminal and enter the following command to start the robot master node.
roscore     #Start the robot master node

Jetracer Robot Movement Control06.png

  • The following roslaunch command will also automatically start the master node, but the purpose of starting the master node alone is to keep connected to the virtual machine all the time. Otherwise, the master node will be automatically closed when the chassis node is closed, resulting in the virtual machine being disconnected.
  • Enter the following command to start the robot chassis node.
roslaunch jetracer jetracer.launch   #Start the robot chassis node

Jetracer Movement Control07.png

  • Open the Ubuntu virtual machine terminal and enter the following command in the terminal to verify that the multi-machine communication connection is normal.
rostopic list
  • If the content shown in the figure below appears after running the code, it means that the multi-device communication is successful; if it cannot be connected, recheck whether the ip and hostname in the above steps are incorrect or whether they are connected to the same WiFi.

Jetracer Robot Movement Control08.jpg

    • /cmd_vel is the topic about robot movement and is controlled by the robot.
    • /imu is the robot IMU topic.
    • /motor/* indicates the actual encoded speed and set the speed of the left and right motors.
    • /odom encodes the odometer for the robot.
    • /odom_combined is the robot fusion odometer, which is obtained by combining the encoded odometer with IMU data.

Step 3: Start Topic Publishing Node Control

  • After the multi-machine communication is normal, please keep the robot chassis node running normally, and place the car on the ground.
  • Open a terminal in the Ubuntu virtual machine and enter the following command to start the topic publishing node.
rosrun rqt_publisher rqt_publisher         #Start topic publishing node

Robot Movement Control100.png

  • In the pop-up window, please select the topic /cmd_vel, and click "+" to create a new topic, /cmd_vel is the topic of controlling the motion of the robot, linear->x indicates the linear speed of the robot, and the range is -1.2m/s~1.2m/ s, angular->x represents the steering angle of the front tire of the robot, not the angular velocity, ranging from -0.6 radians to 0.6 radians.
  • Change the value of linear.x to 0.5, right-click and select publish selected Once to publish a topic, the robot will move forward 0.5 meters and then stop; if linear.x is changed to 0, angular. z is changed to 0.6, the robot will turn left maximum angle of motion.
  • Note: The topic we open here is cmd_vel, select Twist type, and select other topics, the car may not move.

Robot Movement Control011.png

  • Press Ctrl+C to close the topic publishing node.
  • Re-open a terminal on the robot side and enter the following command to view the topic information of the car movement.
rostopic echo /cmd_vel    #Display /cmd_vel receives the topic

Jetracer Movement Control102.png

  • Special Note: The angular->z of this is not the angular velocity of the robot, but the steering angle of the robot's tires.

Step 4: Control the Robot Movement with Keyboard

  • Press "Ctrl+Alt+t" on the Ubuntu virtual machine to open a new terminal, and enter the following command to open the keyboard control topic node.
  roslaunch jetracer keyboard.launch  

Jetracer Movement Control103.jpg

  • At this point, you can use the up and down keys to control the movement of the robot, and the movement data can be viewed in the topics received by the robot terminal.

Robot Movement Control104.png

  • Press ctrl+c to interrupt node running and exit.
  • Note: The above controls are only valid when the robot master node and the robot chassis node are activated. If the robot does not move after pressing the button or modifying the corresponding value in the topic, it may be that the node is not turned on or the multi-machine communication is abnormal. Please check again. Node operation and multi-machine communication.

Step5: Connect the Virtual Machine to the Gamepad Control

  • Check the USB receiver of the gamepad to the computer, and a box will pop up, please select Connect to Virtual Machine -> Ubuntu JetRacer.

Robot Movement Control1005.png

  • Run the following command in the virtual machine to test whether the gamepad is connected normally. 【Note: Connect the receiver of the gamepad to the virtual machine for control, if the gamepad is connected to the jetson nano for control, there will be serious delays.】
ls /dev/input/

Robot Movement Control106.png

  • Among them, js0 represents the game joystick handle, run the following command to test whether the game handle is normal.
jstest /dev/input/js0    

Robot Movement Control107.png

  • Press different buttons on the remote control handle, and the corresponding button value will change.
  • Press "Ctrl+C" to end the node.
  • Enter the following command in the virtual machine to start the gamepad control node.
roslaunch jetracer joy.launch   

Robot Movement Control108.png

  • Turn on the power of the handle, press the HOME button and a red light will be on, then press and hold the L1 button in the upper left corner, and at the same time control the left joystick left and right directions to control the steering of the robot's servos, and the right joystick up and down to control the robot to move forward and backward. Release the L1 key, and the robot stops.

Jetracer Movement Control109.png

  • If the remote control fails, you can enter the following command in the virtual machine, open the ~/catkin_ws/src/jetracer_ros/scripts/teleop_joy.py program, and change the values of axes[ ] and buttons[ ] to the actual corresponding button values.
sudo nano catkin_ws/src/jetracer_ros/scripts/teleop_joy.py   #Open the remote control program file

Robot Movement Control110.png