Proportional control of additional T200 (or similar)

Hi

I’m in the need to controll one or two PWM outputs, for example servo 9+10 (AUX 1 and two on Pixhawk 1) proportional to controll an additional T200 motor.

I was hoping to be able to assign buttons LT and RT on Xbox controller to servo_1_min/max but I can’t find any way to use buttons LT and RT.
Is it possible to use LT and RT in some way?

Is there any other good idéas on how I could proportional control PWM output on AUX 1 and 2 or alternatively directly control Main 7 and 8?

No idéa out there on how to solve this?

Hi @Stihus and welcome to the forum!

We have tried something similar to what you are planning to do. We have attached a crawler to the bottom of our BlueRov2 Heavy and are controlling it with the LT and RT buttons on our XBox controller.
The problem is that LT and RT are not actually buttons, they’re axes, and QGC does not recognise them. (I believe this is because some controllers don’t have LT/RT axes and QGC wants to be independent of controller type.) This also means that you would need to change quite a lot of code in QGC to be able to use them and pass their values on to Ardusub/Pixhawk.

Our solution was to separate the crawler control from QGC entirely and instead use ROS and the pins on the Raspberry Pi. So now we are running a little ROS node on the Pi (see here for Installing ROS on BlueROV companion) and another ROS node on our laptop. The ROS node on the laptop takes the joystick controller input using joy and then sends a custom message with the direction and duty cycle to the ROS node on the Pi. The ROS node on the Pi then sets the PWM signals on the pins of the Pi.

The ROS code runs at the same time as QGC so we can control the BlueROV normally and make use of LT and RT to control the crawler.

I hope this helps you to get started. Let me know if you have any more questions.
(Note that this project is still under development so I will not be able to share any of my code.)

Hi @Stihus,

I don’t believe the reasoning is because QGC wants to be independent of controller type - I expect it’s just that the functionality hasn’t been implemented yet. I believe the equivalent LT/RT axis switches for Play station controller do in fact show up, but as buttons instead of axes - I’m unsure how that’s implemented, or how difficult it would be to make that possible for XBox controllers. Ideally they would be available as some form of axis control too, instead of just a button, but that’s not yet the case.

Probably the simplest way of doing this would be assigning servo_1_inc/dec functionalities to buttons, and potentially also a servo_1_center button so you can ensure the thruster stops at a set point. Is there a particular reason you want to use LT/RT instead of the other buttons? If you include the shifted options you can assign 30 unique button functionalities, so presumably it’s not from a lack of button options.

Assuming other button’s aren’t sufficient for your purposes, @monsterbacke’s solution of running ROS on the topside and on the Companion computer is one possibility, although it may also be possible to write some code on the topside that monitors the joystick inputs, and when LT and/or RT are pressed sends suitable DO_SET_SERVO messages to the Pixhawk via Pymavlink.

I’m unsure whether there could be issues connecting to the joystick with both QGroundControl and another program, or for the vehicle receiving commands from two places, but assuming both of those work I expect it would be quite a bit simpler than the ROS solution, and wouldn’t require anything to be added to the Companion computer, just the topside :slight_smile:

@monsterbacke , I will definitely look into this , thanks for the tip!

I agree, it would be really nice to use LT/RT as axis controll!

I’ve tried this servo inc/dec function and this is working ok, but not the perfect solution.
Problem is not the lack of buttons, but lack of “proportional” buttons. Would be nice to controll the speed of ther extra motors proportional directly from the controller, and when button is released PWM signal is neutral to the ECS.

I will look into both of these sugestions. Thanks!

1 Like

This may be useful for getting the controller input:

1 Like

Good luck @Stihus :slight_smile:

Just a few comments:

Absolutely agree! That way we would not need the ROS overhead and one simple “read input - set servo” Python script running on the laptop would do. So @Stihus try @EliotBR’s solution first!

In our case, we came up with the ROS solution mainly because we wanted to use the pins on the companion computer for PWM (all our Pixhawk connections are full :see_no_evil:) and for some reason I had issues getting pymavlink to run at the same time as QGC (probably dubious UDP port config but networking has never been my strong suit and I gave up trying :woman_shrugging:)

We have not found any joystick issues on Ubuntu 20.04 with a USB-wired XBox controller :+1: I guess it becomes an issue if you assign buttons in QGC and have them do other things in your custom code. But this shouldn’t be the case with LT/RT.
Our crawler electronics are separate from the BlueROV bits so they don’t interfere. But I agree that attempting to control the BlueROV itself through two programs at the same time could cause issues.

Yeah we also needed a way for continous driving with changing speed and servo_1_inc / dec would just have have been a bit “clunky” for this.

1 Like