patrickelectric / bluerov_ros_playground

Scripts to help BlueRov integration with ROS
71 stars 76 forks source link

RC Override data array full: how to add more motor control via joystick? #31

Open bcdupree opened 5 years ago

bcdupree commented 5 years ago

I am attempting to control an ROV with mavROS. I have Ardusub code running on a Pixhawk 4. On the topside I am running mavROS to facilitate camera input amongst other sensor streams and provide the ROS specific implementation of Mavlink. I am publishing messages to mavROS topics using an XBox controller.

My startup command in terminal is:

'roslaunch bluerov_ros_playground user_mav.launch'

I am getting perfect control of my 8 existing ROV thrusters using the 2 joysticks on the XBox controller. What I would like to do is add 2 more thrusters that only need stepwise speed control via 2 buttons on the controller (RB and RT). The commands would simply be step up speed in a clockwise direction on both thrusters or step up speed in the anticlockwise direction on both thrusters.

In 'src/bluerov/user.py', the commands for the 8 existing thrusters are sent to the Pixhawk via the ROS topic 'RCOverrideIn'. This data array for this topic is full however. How do I create an equivalent topic on which to publish the commands for my additional 2 thrusters?

I have tried adding in code like:

            if buttons[5] == 1: # Both Additional Motors Speed Up Clockwise
                thrust = [0.5] # THIS IS AN ARBITRARY VALUE BETWEEN 0 and 1 for now
                self.pub.set_data('/mavros/setpoint_attitude/thrust', thrust)

but I am not sure if the Thrust topic is the ideal one to be using.

Any help much appreciated! Also I am new to ROS, apologies for the noob questions in advance.

patrickelectric commented 5 years ago

Do you want to control the thrusters individually ? That's not possible, it's only possible to send vertical and horizontal control reference to ArduSub.

bcdupree commented 5 years ago

Sorry im an idiot for calling them thrusters. They are actually extra motors that are not used for thrusting. The idea is that they would be controlled in unison.

bcdupree commented 5 years ago

Ardusub has a parameter called 'cam_tilit' in joystick.cpp that maybe we could use to send a pwm to 2 other motors? However I cannot find the equivalent parameter/data structure in the python libraries of the bluerov playground. how would we go about adding the appropriate python code on the topside?

bcdupree commented 5 years ago

sorry 'cam_tilt'