Home        Store        Learn        Blog

Issue setting target altitude with joystick

I am having trouble getting the joystick input to update the target altitude. It is my understanding that when the sub is set to depth hold mode and the joystick is set to position mode, the joystick should be updating the target altitude. It is not doing that – and seems to have no effect at all. Instead, the depth sensor (immersed in ~20cm water) seems to be setting the target altitude to whatever the current depth is.
In my debugging attempts, I have been using the gcs messaging in a UserCode.cpp loop to print out pos_control.get_alt_target() to QGroundControl-- is this the correct variable? If so, how is this variable changed based on user input instead of the current depth? I can’t find anything in the joystick.cpp file but may be looking in the wrong place.

Hi @Coco,

The current depth hold behavior goes up/down in open loop and sets de desired depth when the stick is centered. This was made so the user is in full control when using the joystick. The relevant file is control_althold.cpp.

I have an open pull request that changes this behavior. But that could feel more sluggish or introduce issues, so it needs further testing before merging. Let me know if you try it out!

That is what you are looking for. Additionally, you should find these in the dataflash log as CTUN.DAlt (Desired Altitude). You may need to change the logging bitmask to include PIDs, though.

1 Like