Vehicle isn't executing target depth command correctly

Hi guys,
my problem might be related to this topic.

I encountered a problem, when using the depth hold mode in combination with ‘set_position_target_global_int_send()’

My setup:
I am using the SITL provided here: SITL · GitBook
I am running it natively on Windows using Cygwin.

I am doing the following steps:
Setting up SITL

  1. Open QGroundControl
  2. Open the Cygwin64 Terminal
  3. Navigate to ‘~/ardupilot/tools/autotest’
  4. Execute ‘python3.7 sim_vehicle.py -v ArduSub -L RATBeach --out=udp:0.0.0.0:14550 --map --console’
  5. MAVProxy opens
  6. Execute ‘output add 127.0.0.1:14551’
    Run my Code
  7. Run Set Target Depth/Attitude Example: Pymavlink · GitBook
    This is my script.
    I basically copy and pasted the example. I only changed the target depth from -0.5m to -10m and the udpin from ‘udpin:0.0.0.0:14550’ to the in step 5) added ‘udpin:127.0.0.1:14551’

My problem
I am watching the state of the sub on QGroundControl, where it displays an unexpected behaviour. It either does not hold the specified depth or it does not even dive to the specified depth in the first place.

My approach to solve this problem
I tried a bunch of stuff, like looping ‘set_position_target_global_int_send()’ until it actually reaches the desired depth. Although Eliot stated in this post:

it should be set only once.
But my sub dived to the specified depth, only if i looped it.

But once i start rotating, the sub starts to raise to the surface again, eventhough it is in depth hold mode and i did not change the target depth. All i did, was to use the ‘set_attitude_target_send()’ function, with the ‘ATTITUDE_TARGET_TYPEMASK_THROTTLE_IGNORE’ as used in the previously mentioned example.

I do not know how to debug this either. For example i tried to request the message for ‘POSITION_TARGET_GLOBAL_INT’ to check if the target depth is actually set, but i received no answer. But i can receive other messages like ‘GLOBAL_POSITION_INT’.
This is my current project where i tried to use the workaround by looping ‘set_position_target_global_int_send()’ in Testsequence_SurfaceComputerToAutopilot_w_set_target_position(). It is quite messy though and i do not expect anyone to solve this for me.

What i am ultimately trying to achieve
I am trying to autonomously dive to a specified depth, rotate and make some pictures. That should be an easy task, but i am having a hard time, even with the provided examples.
I can not test it on the actual submarine for now, thats why i tried to make it work in the SITL first.

I found a bunch of forum entries, that are related to the topic, unfortunately most of them are a dead end to me.

1 Like