Jetracer Steuerung

Aus HSHL Mechatronik
Zur Navigation springen Zur Suche springen
Verschiedene manuelle Steuerungsmodi
Die verschiedenen Möglichkeiten wie der JetRacer gesteuert werden kann werden im Tutorial Robot Movement Control beschrieben. Hierbei ist zu beachten das beim Befehl "sudo adduser jetbot dialout" welcher den User hinzufügt, das jetbot durch ein jetracer ersetzt werden muss.
Steuerung per Node Publishing
Wie im Tutorial beschrieben kann der Roboter anhand einer Publishing Note Befehl für Befehl gesteuert werden. Dies ist zu Beginn nützlich um zu testen ob alle Bewegungsmöglichkeiten funktionieren.
Steuerung per Tastatur
Ebenfalls kann der Roboter per Tastatur gesteuert werden. Dieser Modus läuft flüssiger als die Publishing Node, ist aber gewöhnungsbedürftig.
Steuerung per Joystick
Der intuitivste Steurungsmodus ist das steuern per Game Controller, hier genannt Joystick. Für diesen Modus muss allerdings erst der Controller mit der Virtualbox verbunden werden. Hierfür muss in den Einstellungen der VM der Controller als USB Input Gerät festgelegt werden. Außerdem muss vielleicht der Input an der Virtualbox von js0 auf js1 geändert werden, da sonst die Maus als Input für die Steuerung benutzt wird. In diesem Tutorial: Assign specific device input paths wird beschrieben wie dies in einer ubunutu Umgebung möglich ist.
Falls der Roboter nicht geradeaus fährt wenn man eine gerade Bewegung eingibt, könnte es daran liegen das die Räder beim Aufbau leicht versetzt montiert wurden. Dies kann durch eine Änderung des Fahrtwinkels kompensiert werden. In diesem Tutorial: Robot Odometer Calibration wird beschrieben wie man den Winkel einstellen kann. Außerdem nützlich dafür ist dieser Beitrag: Editing Cfg Files in Linux welcher erklärt wie man eine config Datei in Linux bearbeitet.

"Serial User Group" hinzufügen

  • 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

Step01

  • 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 jetson dialout  #Add the current user to the user group dialout where the serial port is located

Step02

  • 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

Roboter Karosserie Knoten öffnen

  • 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

[]

  • 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

[]

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

[]

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

Steuerung per Veröffentlichungs Knoten

  • 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

[]

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

[]

  • 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

[]

Steuerung per Tastatur

  • 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

[]

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

[]

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

Steuerung per Kontroller

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

[]

  • 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/

[]

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

[]

  • 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

[]

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

[]

  • 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

[]