Gamepad
description of the file gamepad.py
Last updated
Was this helpful?
description of the file gamepad.py
Last updated
Was this helpful?
The class Gamepad handle event from the Logitech Gamepad F310 connected by USB to topside computer. Build to test ROS implementation before we can connect ROS in parallel of QGroundControl (QGC).
The class Gamepad uses the library input from to handle gamepad joystick and buttons.
This library comes with the github ROS repository but you will need to build it by
Otherwise you can install it with pip:
The inputs library provides API to handle the events from gamepad. Based on the event's name, a dictionary provide a link between the name of the event and the method to call.
Gamepad event name
Method called
Designation
Value
ArduSub/MAVlink id
ABS_Y
_throttle
LEFT stick vertical
[0-128-255]
clicked Joy : 7
ABS_X
_lateral
LEFT stick horizontal
[0-128-255]
clicked Joy : 8
ABS_RZ
_forward
RIGHT stick vertical
[0-128-255]
/
ABS_Z
_yaw
RIGHT stick horizontal
[0-128-255]
/
ABS_HAT0Y
_NDEF
LEFT cross vertical
-1 up; 0 neutral; +1 down
up : 11 ; down : 12
ABS_HAT0X
_set_gain_light
LEFT cross horizontal
-1 up; 0 neutral; +1 down
left : 13 ; right : 14
BTN_TRIGGER
_override_controller
X
0 ; 1
2
BTN_TOP1
_NDEF
Y
0 ; 1
3
BTN_THUMB
_NDEF
A
0 ; 1
1
BTN_THUMB2
_NDEF
B
0 ; 1
0
BTN_BASE
_NDEF
LT
0 ; 1
/
BTN_BASE2
_NDEF
RT
0 ; 1
/
BTN_TOP2
_cam_down
LB
0 ; 1
9
BTN_PINKIE
_cam_up
RB
0 ; 1
10
BTN_BASE3
_disarm
BACK
0 ; 1
4
BTN_BASE4
_arm
START
0 ; 1
6
Gamepad
ROS topics subscribed
Message
Description
/BlueRov2/arm
Bool
The arm status
ROS topics published
Message
Description
/Command/joy
sensor_msgs/Joy
axes : [THROTTLE, YAW, FORWARD, LATERAL]
buttons : [ARM, OVERRIDE_CONTROLLER, PWM_CAM, LIGHT_DEC, LIGHT_INC, GAIN_LIGHT]
Joy message parameters
Type
Description
THROTTLE
Float32
pwm : Uint16 [1100-1900]range
YAW
Float32
pwm : Uint16 [1100-1900]range
FORWARD
Float32
pwm : Uint16 [1100-1900]range
LATERAL
Float32
pwm : Uint16 [1100-1900]range
ARM
Int32
0 : disarm ; 1 : arm
OVERRIDE_CONTROLLER
Int32
0 : AUTOMATIC mode, 1 : MANUAL mode
PWM_CAM
Int32
pwm for camera tilt
LIGHT_DEC
Int32
1 if you want to decrease brightness, else 0
LIGHT_INC
Int32
1 if you want to increase brightness, else 0
GAIN_LIGHT
Int32
result of gain light