JetRacer ROS AI Kit Tutorial V: Robot Movement Control

From Waveshare Wiki
Revision as of 03:48, 4 November 2022 by Eng52 (talk | contribs) (Created page with "==Step 1: Add serial User Group== *Enter the command ls /dev in jetson nano to check whether the driver board is connected to jetbot normally, and whether ttyACM0 and ttyACM1...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Step 1: Add serial User Group

  • Enter the command ls /dev in jetson nano to check whether the driver board is connected to jetbot 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    

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

Robot Movement Control02.png

  • Enter the command "sudo reboot" to restart, the password is jetbot [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

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 jetbot_pro jetbot.launch #Start the robot chassis node

Robot 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.

Robot Movement Control08.png

    • /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 point 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, click "+" to create a new topic, /cmd_vel is the topic of controlling the motion of the robot, linear->x indicates the linear velocity of the robot, and angular->x indicates the angular velocity of the robot.
  • 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 3.14, the robot will rotate half a circle.
  • Note: The topic we see here is cmd_vel, please select Twist type, and choose 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

Robot Movement Control102.png

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 jetbot_pro keyboard.launch

Robot Movement Control103.png

  • 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 Jetbot.

Robot Movement Control105.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, 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 jetbot_pro joy.launch  

Robot Movement Control108.png

  • Turn on the power of the handle, press the HOME button, a red light will be displayed, then press and hold the A button, and control the left joystick at the same time to control the movement of the robot; release the A button, the robot stops.

Robot Movement Control109.png

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

Robot Movement Control110.png