5 Robot handle control

According to different models, you only need to set the purchased model in [.bashrc], X1(ordinary four-wheel drive) X3(Mike wheel) X3plus(Mike wheel mechanical arm) R2(Ackerman differential) and so on. Section takes X3 as an example

Open the [.bashrc] file

Find the [ROBOT_TYPE] parameter and modify the corresponding model

5.1 Operating environment

OS: Ubuntu 18.04 LTS

ROS version: melodic

Equipment: jetson nano/Raspberry Pi, PC, wireless handle(USB receiver)

Handle control function code path: ~/yahboomcar _ws/src/yahboomcar_ctrl/scripts

5.2 install the driver

ROS driver for generic Linux controllers. The Joy package contains Joy_node, a node that connects a generic Linux controller to ROS. The node publishes a "/Joy" message containing the current state of each button and axis of the handle.

5.3 Use steps

5.3.1 Device connection

First, connect the USB end of the wireless controller to the device(jetson, Raspberry Pi, PC). This lesson takes connecting the USB end of the wireless controller to the jetson as an example, connecting the mouse, keyboard, and monitor;

5.3.2 View device

Open the terminal, enter the following command, it shows [js0], this is the wireless controller. In special cases, it can also be viewed through the two states of connecting and not connecting to the USB terminal of the wireless handle. The device list changes, if there is a change, the device is changed; otherwise, the connection is unsuccessful or cannot be recognized.

image-20220302120317676

Note: If the keyboard or mouse and other devices are connected to the ROSMASTER first, the remote control receiver will be recognized as other devices. Therefore, if you need to connect the keyboard or mouse, you can connect the remote control receiver first and then connect to other devices. equipment.

5.3.3 Test handle

Open the terminal and enter the following commands. As shown in the figure, the wireless handle has 8 axial inputs and 15 key inputs. You can press the keys respectively to test the numbers corresponding to the keys.

image-20220302121526295

If jstest is not installed, run the following command:

5.3.4 Running the handle node

Open three terminals, and enter the following commands in turn to view the detailed information, which is the same as [Test Handle]. Different devices(Raspberry Pi, jetson nano, PC) and different systems will have different handle states.

image-20220302120815104

5.4 The handle controls the little turtle

5.4.1 Start

image-20220302122239082

  1. view the node

image-20220328175003554

  1. view the speed topic information

image-20220328175136329

  1. The corresponding relationship between the handle and the operation of the little turtle

handlelittle turtle
left stickgo ahead
Left joystick downback
Right stick leftTurn left
right joystickTurn right
  1. view the node graph

[/joy_node]: Node of handle information

[/twist_joy]: The node controlled by the handle

[/turtlesim_node]: The node of the little turtle

The node [/joy_node] publishes the topic [/joy], so that the node [/twist_joy] subscribes, and after processing, publishes the topic [/turtle1/cmd_vel] for the node [/turtlesim_node] to subscribe, and drives the little turtle to move.

image-20220302122408394

5.5, handle control ROSMASTER

The handle to control ROSMASTER is similar to the handle to control the turtle; let the handle control node establish a connection with the ROSMASTER underlying driver node, change the current state of the handle, send different information to ROSMASTER, and drive ROSMASTER to respond differently. Corresponding to the ROSMASTER of different models, what we need to control is also different.

For ROSMASTER-X3(Mecanum wheel) we can control the buzzer, light strip, the linear speed of the car movement(x-axis and y-axis) and the angular speed of the car movement through the handle.

5.5.1 Start handle control

  1. handle control yahboom_joy.launch file reference path

  1. start

After turning it on, press the "START" button and hear the buzzer to start the remote control. If the remote control is turned on for a period of time, it will enter the sleep mode, and you need to press the "START" button to end the sleep mode.

  1. remote control effect description

handleEffect
Left stick up/downThe car goes straight forward/backward
Left joystick left/rightThe car goes straight left/right
Right stick left/rightCar turns left/right
Right "1" keyControl light strip effects
Right "2" keyEnd/open other functions
"START" buttonControl buzzer/end sleep
Left stick pressedAdjust the speed of X/Y axis
Right stick pressedAdjust the angular velocity

  1. view the node graph

image-20220302150953183

The red box part is the topic communication between the handle control node/yahboom_joy and the underlying node/driver_node.

  1. program analysis

Bottom control program:

The code path is:

In Mcnamu_driver.py, the buzzer, speed control, subscribers of the topic information of the light strip and their respective callback functions are defined,

Handle control program:

The code path is:

In yahboom_joy.py, the buzzer, the speed control, the publisher of the topic information of the light strip , and the publisher of these messages

  1. code analysis

In the print information, there are two arrays: axes and buttons, and the data they store is the behavior of the joystick and buttons on the remote control. You can press each button on the remote control one by one, one by one corresponding to the transformation of the array, and you can know what behavior will cause which variable of the array will change its value.

5.6、Precautions for using the handle

ECB7ADF3-824E-4cc6-AE49-5536DF2ACA27