Handle control

1、Operating environment

Operating system:Ubuntu 18.04 LTS

ROS version:melodic

Device:jetson nano 、Raspberry Pi、PC、handle(USB receiver)

Handle control function package path:~/transbot_ws/src/transbot_ctrl

2、Install driver

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

3、Steps for usage

First of all, we need to insert the USB adapter of the wireless controller into Jetson NANO, Raspberry Pi, and PC.

In this lesson, we will insert the USB port of the wireless controller to Jetson NANO board.

Open the terminal, enter the following command, it shows [js0], this is the wireless controller.

001

Open the terminal and input the following commands.

As shown in the figure, the wireless handle has 8 axial inputs and 15 key inputs. You can press the keys to test the numbers corresponding to the keys on handle.

002

If jstest is not installed, you need run the following command to install it.

Open three terminals, enter the following commands in sequence to view the detailed information, which is the same as [Test Handle].

Different devices (Raspberry Pi, Jetson NANO, PC) and different systems have different handle states.

003

4、Handle control turtle

4.1、Start the turtle

If you want to drive the little turtle, just give the little turtle a certain speed. Next, check the ROS speed control node.

004

4.2、View node

4.3、View the node information

 

4.4、Handle control turtle

Receive the current status information of the handle, and send instructions to the little turtle by pressing the button or shaking the joystick to receive different information feedback from the wireless handle.

Copy the wireless controller control function package to the workspace, compile and update the environment.

Input command to start up python code

Input command to start up C++ code

006

At this point, we can use the handle to control the little turtle to run.

HandleTurtle
Left rocker upadvance
Left rocker downback
Left rocker leftturn left
Left rocker rightturn right

【/joy_node】:Handle information node

【/turtlesim_joy】:Handle control node

【/turtlesim_node】:Turtle node

 

007

5、Handle control Transbot

Handle controls Transbot, which is similar to the handle control of the turtle; let the handle control node establish a connection with the Transbot bottom driver node, change the current state of the handle, send different information to Transbot, and drive Transbot to make different responses. We need to control the buzzer, searchlight, pan-tilt, light bar, robotic arm, and trolley movement (linear velocity, angular velocity).

5.1、handle control node

5.2、Associated node

5.3、Operating procedures

008

Start up command

View node graph

Can only see the connections between topics

009

View service list

The system will print the following:

5.4、Source code analysis

Code path: ~/transbot_ws/src/transbot_bringup/launch/joy_bringup.launch

Node 【DeviceSrv】 starts the camera device service: obtains the current camera device number, and publishes whether it is currently connected to the Astra camera.

Code path: ~/transbot_ws/src/transbot_ctrl/scripts/transbot_joy.py

Start the thread, get the currently connected camera device in the 【self.analyse_PWM()】function, which is convenient for processing different cameras, and turn on the loop to control the gimbal servo and robotic arm.

5.5、Handle control effect212

 

Appendix

jetson nano

axes(8)

Code analysisHandle buttonCar control
axes[0]Left rocker 
axes[1]Left rockeradvance and back
axes[2]Right rockerleft and right
axes[3]Right rocker 
axes[4]  
axes[5]  
axes[6]Left buttonArm-1
axes[7]Left buttonArm-2

buttons(15)

Code analysisHandle buttonCar control
buttons[0]Acamera platform move down
buttons[1]Bcamera platform move right
buttons[2]  
buttons[3]Xcamera platform move left
buttons[4]Ycamera platform move up
buttons[5]  
buttons[6]L1Arm-clip close
buttons[7]R1running water light
buttons[8]L2Arm-clip open
buttons[9]R2control switch
buttons[10]SELECTsearch light on high frame rate camera
buttons[11]STARTbuzzer
buttons[12]  
buttons[13]Press left rockerLinear speed [ 0.15 , 0.3 , 0.45 ]
buttons[14]Press right rockerAngular speed [ 0.5 , 1 , 1.5 , 2 ]

Raspberry Pi

axes(8)

Code analysisHandle buttonCar control
axes[0]Left rocker 
axes[1]Left rockeradvance and back
axes[2]L2(press:-1,release:1)Arm clip
axes[3]Right rockerleft and right
axes[4]Right rocker 
axes[5]R2(press:-1,release:1)control switch
axes[6]Left buttonArm-1
axes[7]Left buttonArm-2

buttons(11)

Code analysisHandle buttonCar control
buttons[0]Acamera platform move down
buttons[1]Bcamera platform move right
buttons[2]Xcamera platform move left
buttons[3]Ycamera platform move up
buttons[4]L1Arm clip
buttons[5]R1running water light
buttons[6]SELECTsearch light on high frame rate camera
buttons[7]STARTbuzzer
buttons[8]MODE 
buttons[9]Press left rockerLinear speed [ 0.15 , 0.3 , 0.45 ]
buttons[10]Press right rockerAngular speed [ 0.5 , 1 , 1.5 , 2 ]

Precautions for using the handle

 

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