HI I am working on an auv and having some troubles with depth hold mode so I needed a few clarification. I am currently using pymavlink but porting over to mavros with ros2.
does the send_position_global_int function work to set a target depth that depth hold mode should then try to reach?
if so, do I need to run that function multiple times (10Hz) or can I just publish that command once everytime I want to change my target depth?
I read in some old forum posts that the X_IGNORE and Y_IGNORE flags shouldn’t be set to add a desired depth and that it was a bug. But I am using Ardusub 4.5.1, this should not be an issue here?
what should the sequence of actions be here:
arm->change_mode->set_target_depth
change_mode->set_target_depth->arm
or something else entirely?
We had an issue where we just run some of the example code in the pymavlink gitbook to set a target depth and the auv shoots up or down sometimes(randomly, if I run same code again, it may not show this behaviour).
Finally I tried to read some logs under where I plot DAlt and Alt under CTUN but the desired altitude spiked down to -100m when I only ever set it to -0.5m. Should I be checking anything else in the logs for debugging purposes? We get limited time in the pool so I haven’t been able to get a good log for this but I can in a couple days if needed.
Here is an example(sorry it’s so long) log of trying to do depth hold mode (above water). The only depth I ever set it to is -0.5m so these DAlt values are a bit puzzling to me. 00000022.BIN (2.7 MB)
Note that depth hold re-evaluates its target based on pilot input, so if you’re also controlling the vehicle with a joystick then any vertical input you provide will reset the depth target to your current depth.
The relevant fix is indeed merged in to recent ArduSub releases, including 4.5.1
Either should in principle work, although I have a vague recollection that it has previously been preferable to be in manual mode when arming, and switch to depth hold afterwards (possibly even once the vehicle is fully below the water level), so maybe try that as a starting point?
All of ArduSub’s operation expects to be in water, and breaking that assumption tends to result in unexpected behaviour, while also not being representative of the behaviour during normal operation. I wouldn’t expect that to change the depth target, but it’s hard to say what the autopilot will try to do if its requested output isn’t achieving anything (short of walking through and analysing the source code, which I’m afraid I don’t currently have time for).
If you get a log of depth hold not working as expected in water then we can try to take a look at it and see if there’s a bug that needs fixing or something
I do control the vehicle with rc override but I always set the thrust channel to the int max value which is supposed to ignore this input. Is it better to set it to zero?
Also wanted clarification on this^ I know the example code doesn’t do that but I’ve had issues so wanted to clarify the actual expected behavior.
If I do face further issues, I will get a proper log of the vehicle underwater for debugging. Thanks again!
Hmm, I’m not sure that would make a difference, but it’s potentially worth a shot if the target is changing unexpectedly.
The function you’ve mentioned doesn’t exist. There is a global_position_int_send, which allows sending a GLOBAL_POSITION_INT message, but that’s unrelated to any kinds of target, and is instead what the autopilot is expected to send to reflect its current position estimate (which is only potentially correct if it has the sensors to actually make an estimate about its position).
Apologies, I need to be a bit more careful when I mention functions. I meant the set_position_target_global_int function, the same one used in the depth example (but in my case, the mavros topic)
Ok, as mentioned, yes, that sets a target which generally shouldn’t change itself in the absence of pilot input, so ideally should only need to be set once per intended set-point.
I would note that “pilot input” could include pitching or rolling the vehicle and then moving (relatively) forwards / sideways in a way that moves the vehicle up/downwards, which is something to be aware of. If you’re running into issues with the depth target changing because of motion you’re commanding on other axes then it may be worth setting the depth target multiple times / repeatedly.