Home        Store        Docs        Blog

ArduSub custom motor control


#1

Hello,

We are a team at Virginia Tech currently developing an autonomous reactor inspection vehicle for Framatome and we intend to use the ArduSub open source solution for our purposes.

In short, we are attempting to use ArduSub’s current implementation to control 4 600HF Hi-Flow Thrusters and then 2 additional PWM pins on the Pixhawk to control 2 additional motors (I can provide specifics on motors if needed.)

Here is what we believe to be the correct approach:

  1. We may use the QGroundControl to map a function to a button on our xbox 360 controller. We noticed many of these function calls (i.e. lights1_brighter) are in the joystick.cpp and also found a switch case for custom buttons. We believe that these custom buttons would be what we should use and where we should implement our custom code; one button to tell the the left and right motors to rotate clockwise, and another to do the opposite of that (maybe a third to stop the motors if buttons are not hold-to-operate).

We did also read about some servo_n functions, although we’re not sure if that’s what we need instead of implementing the custom switch cases.

  1. By default, 4 PWM pins are assigned to the Pixhawk for 4 thrusters, and we can change this to 6 via the BRD_PWM_COUNT parameter which we believe is part of a parameters text file we upload. We then use the DO_SET_SERVO command to operate the servos (we’re not sure how this function works, what parameters it needs, etc.)

So at this point we’re unsure whether we should be going the custom button route, or the *_servo_n route. We also don’t know if the *_servo_n function that controls the PWM output can send the output specified in (1).

  1. Once we know where our code should go (or how to use the *_servo_n function for our purposes), what would this code actually look like? We looked into the motors library to try and get some sense of the calls that functions we found were making to try and use as a reference, but we’re still very unsure of whether it would be correct or not.

One function of interest that seemed to revolve around our intentions was the “AP_MotorsSingle::output_test_seq(motor_seq, pwm)” function in AP_MotorsSingle.cpp, which appears to take in a motor and a pwm value? Although this was also commented to be for testing rather than normal operation.

Alternatively, we also found “AP_Motors::rc_write(chan, pwm)” in AP_motors_class.cpp, prompting for two similar parameters and then following that with what appears to be output_pwm assignment.

2/13/19: Another assignment that seemed interesting is “motor_out[i] = 1500” in AP_Motors6DOF.

Ending Comments

We’re a team of Mechanical Engineers with minimal CS experience. I myself only have some experience with Java, C, C++ from my CS minor which is certainly not enough to fully grasp all of the intricacies of the ArduSub code.

We are hoping that we may find the answers to our many doubts here on the forums, if one is willing to help us out!

Thanks,
Daniel


(Jacob) #2

(I can provide specifics on motors if needed.)

Hello, what purpose do the two extra motors serve?


#3

Each motor is responsible for rotating a drag chain belt spool. Two spools come together to form an arm that descends down to a specific water level. At the end of the arm is a camera provided by Framatome (our sponsor) and its video feed is also handled by the sponsor.

We also have another smaller camera attached to the bottom of the platform, and we plan to setup that feed with QGroundControl.

Link to motors: https://www.vexrobotics.com/217-2000.html#Other_Info

The image below depicts the drag chain spools, and on the rightmost spool, one of the motors responsible for rotation is featured. Motor functions would most likely be ‘extend’ belt, ‘retract’ belt (if the function is press & hold then a ‘stop’ button would not be required.)


(Jacob) #4

Ok, you don’t want to use a ‘motor’ output for this, the motors in the context that you have spoken about are specifically for vehicle control.

If this is some actuator you want to be able to move with pilot input, you can just use the ‘servo’ function assignments for the buttons.

Go Hokies.


#5

Ok, thanks! That seems like it should be easy enough for us to handle.

At the moment, we’re now thinking that to avoid having to press two buttons simultaneously for the ‘servo’ functions, we could either split the output of one servo pin (if possible) to the two motors so that they receive the same input or implement two of the custom buttons using the servo function implementation as a reference.


(Jacob) #6

we could either split the output of one servo pin (if possible) to the two motors so that they receive the same input or implement two of the custom buttons using the servo function implementation as a reference.

Yes and yes


#7

Thanks!

Are we limited to only discrete steps? Or is there a way to incorporate holding a button down as well? We noticed something along the lines of “if (!held)” but we’re not sure.

Also, are the min/max servo values set to some default somewhere? Or must we ourselves set that value using “chan->set_output_min();” and “chan->set_output_max();” ?