Home        Store        Docs        Blog

ArduSub custom motor control

(Jacob) #52

The suggestion is to match the implmentation of held with if statements, as demonstrated in other places in the file. This way, it will work (the code that is already there works, do the same thing and yours will too!). The way you have it right now, you enter the while loop, and you never come out of it, because the value of held never changes inside of the loop. (connection is lost because the code running on the autopilot is completely hung, doing nothing spinning around inside of your while loop forever.

We always have to power on the vehicle and THEN open QGC in order to connect to the vehicle. So in the case that we lose connection, we must always restart QGC in order to establish connection again; is this normal?

This is not normal, it is probably related to your firmware bugs.

#53

Thanks for the reply!

The issue that I have preventing me from going forward with the if statement is not knowing exactly what is happening. In the toggle switch case, does held come in as ‘false’ after the user has pressed the button but not held it?

And so held would come in as true if the user has pressed the button and is still holding it?

And if that is indeed the case, then the code would be something like:

{
if (held) {
// do stuff to make motors spin
}
}

but how do I make it so that it goes back to neutral once the user is no longer holding the button? I can’t do this in the same switch case or else every time the user does hold the button, the duration of the motor running would basically be 0 (however fast the code is running)

#54

I think we’ll just go with 3 buttons then instead of trying to implement for 2, I don’t see how I’d be able to do what I want to do if held doesn’t update to reflect current status.

That’ll just leave the issue of figuring out these ESC’s.

(Jacob) #55

I think what you are trying to do is similar to the servo_n_max_momentary function. You should add a handler for press, and release.

You may not need to use the held variable after all, it is normally used to actually check if a button has not been held.

#56

Ohh, thanks for mentioning the handler for release, I actually never noticed this. It was something I was curious about, initially thinking somehow the handler for press was being called twice with held as true and then held as false…

I am going to write something now using both handlers! I’ll be adding the custom switch cases into the release handler so that they’re called when the button is released.

#57

Tested the new buttons today using press and release handler, working as intended, thanks!

We also tested our motors/ESC with the new voltage regulator and found that the “resetting to a different neutral value” actually occurs when the motor attempts to draw a current beyond the limit et by regulator. We were able to confirm this because our new regulator has a variable constant current that we were able to modify.

We will be looking into this more next week.

1 Like
(Jacob) #58

Very good @adaniel1. I hope the rest goes more smoothly.

#59

Hey, we’re currently doing some wet tests and troubleshooting movement issues.

Is the “Feedback control and stability” feature automatically enabled or must we change a parameter value within QGroundControl?

(Jacob) #60

Hi @adaniel1, it is automatically enabled in stabilize and depth hold flight mode.
https://www.ardusub.com/operators-manual/flight-modes.html

#61

Ah, we have been booting in Manual mode, which according to the link, means we had nothing enabled. Or does Manual mode include stabilize and depth hold?

(Jacob) #62

Manual has no stabilization whatsoever.

1 Like
#63

Hey,

Just wanted to drop a quick thank you for all the help (hopefully we won’t be having any more issues that requires us to use the forum too heavily).

Here are some videos of our wet tests, we’re still fine tuning a few things but on track to have the product ready by the deadline:

(before fixing some parameters and the custom configuration, it wasn’t moving too well in water…)
https://streamable.com/epbl3

(after fixing everything)
https://streamable.com/lp93h

We’ll be testing both arms (dry & wet) simultaneously this weekend (we have already confirmed one arm is able to lift 5lbs easily)

#64

To prevent the use of custom buttons without arming the vehicle, would I use the boolean returned by “motors.armed()” ?

Just thinking this should be a safety feature added…

(Patrick José Pereira) #65

Hi,

Yes, you can use motors.armed() to filter user inputs for safety reasons.

(Jacob) #66

Awesome @adaniel1, I will be very interested in any paper or presentation resulting from this.

#67

In terms of documentation i’d have to check with our adviser and sponsor what exactly we can share, but here is a video that we presented during our senior design expo: https://streamable.com/a7oy0

(Deepak Jayan) #68

I tried to assemble all the blue Robotics components and burnt the latest version of ardusub firmware into the pixhawk and then I tried to run the vehicle using QGroundcontrol installed on my topside computer.The topside computer and raspberry pi were connected using tether. I assume that, when I use the joystick to provide commands, actually mavlink messages are being transmitted from topside computer to raspberry pi and this pi controls the pixhawk thereby controlling thrusters, lights and camera. As I am unaware of python programming, now from my topside computer (with linux OS) , if I wanted to directly send various commands to control the thrusters, arm the vehicle, provide yaw and throttle values and also to receive mavlink messages like getting the temperature reading from the temperature sensor, do I need to install python first in my topside and raspberry pi. In which window , should I need to write these commands in the topside computer?As I am new to python programming, I couldn’t make out what is written in the " PYMAVLINK " section of " ARDUSUB " page. I kindly request you to help me with all the necessary information (or some video links) required for writing these commands in the topside computer.Looking forward for your reply,

Regards,
Deepak

(Jacob) #69

@deepak both the topside computer and the raspberry pi are on the same Local Area Network, so your program can run on either machine and communicate with the autopilot.

The pymavlink examples are the simplest examples we provide. I think most of them are designed to run on the topside computer, but they can be adapted to run on either computer.

(Deepak Jayan) #70

Sir,

I have a few doubts in pymavlink. I am new to python and mavlink. I read the pymavlink documentation given on “https://www.ardusub.com/developers/pymavlink.html”. Here it basically provides various examples to arm/disarm the vehicle, read and write parameters etc. If I take the example of ’ read and write parameters’, I found the following lines in the code:-

master.mav.param_request_read_send(
master.target_system, master.target_component,
b’SURFACE_DEPTH’,
-1}

what does these lines mean? Do we need to give values for this target system and target component ?
As per the instruction given, if we installed python 3.7.3, its dependencies and mavproxy , can we write all these code given in that page directly(without making any modifications) to some text editor and save it as .*py python file and run this file using a python interpreter 3.7.3 (assuming TETHER connections exist from my surface computer to raspberry pi and the raspberry pi is connected to pixhawk -1 using usb connection), will I be able to control my ardusub vehicle (i mean arming, diasrming, changing the value of parameters, rotating the thrusters etc) manualy without using QGC? You are kindly requested to help me on this topic.
please reply.

(Patrick José Pereira) #71

Hi,

I believe that mostly of your questions are related to the python language itself and not about mavlink or our ardusub project/code structure.
I recommend you to study python before doing any such task, check the official python tutorial here.