Home        Store        Docs        Blog

Forwarding joystick commands to external controller


(Michael Blom Hermansen) #1

Hello

I am using the BlueROV2 Heavy through QGC, RBP and the pixhawk, and want to add modes and controls for a robotic arm.

Currently, the arm controls are in an external controller (MyRio), but I want it to be controllable in QGC alongside with the BlueRov2. The plan is to add 3 modes (or modify exististing unused modes), that all stabilize the ROV, while one controls the robot arm with a joystick.

The pixhawk/RBP then sends a message to the MyRio about which robot arm mode is active.
The pixhawk/RBP then forwards all raw joystick button presses to the MyRio, where I can program processing of joystick controls for the robot arm in an environment, where I am more savvy.

In short I cant find out how I can send raw joystick commands out of the Pixhawk or (preferrably) the Raspberry Pi’s GPIO.

BR, Michael Hermansen


(Jacob) #2

The communication is done with MAVLink. You can see examples of pulling data out of the stream here, as well as searching the forum. You will be interested in the MANUAL_CONTROL message. You can write some python code to sniff that message out of the stream.


(Michael Blom Hermansen) #3

Hey Jacob

Thanks for the link, it was helpful. How do I access the variables in MANUAL_CONTROL?

Is it like this (with a dot after manual_control):

# Import mavutil
from pyvmalink import mavutil

# Create the connection
master = mavutil.mavlink_connection('udp:0.0.0.0:14550')
# Wait a haertbeat before sending commands
master.wait_heartbeat()

int16_t x_axis
int16_t y_axis
int16_t z_axis
int16_t r_axis
uint16_t js_buttons

while True:
	msg = master.recv_match()
	if not msg:
		continue
	if msg.get_type() == 'MANUAL_CONTROL'
		x_axis = MANUAL_CONTROL.x
		y_axis = MANUAL_CONTROL.y
		z_axis = MANUAL_CONTROL.z
		r_axis = MANUAL_CONTROL.r
		js_buttons = MANUAL_CONTROL.buttons
		# gpio commands (spi or i2c) that sends variables to other controller

Also, can I access the flight modes as well? From the documentation you sent, they seem to be stored in MAV_MODE_FLAG, but when I “watch MAV_MODE_FLAG” in MAVProxy, nothing is watched.


(Jacob) #4

You will need to substitute MANUAL_CONTROL.x with msg.x and so on.

The mode comes in the HEARTBEAT message. There is no MAV_MODE_FLAG message; MAV_MODE_FLAG is an enumeration.