I’ve been trying to send my sub a depth command with SET_POSITION_TARGET_GLOBAL_INT, but I’m witnessing some odd behavior that I thought I would make a forum post for.
My issue is very similar to this issue: Altitude hold and depth hold in pymavlink - #11 by kg9316
However the last activity on the post is from 2020, so I thought I’d make a new post.
To summarize, when my sub has a depth of 10m and I send it a SET_POSITION_TARGET_GLOBAL_INT message with a target of 15m, the sub will only descend 1m to 11m below the surface. If I send the exact same message again, the sub will descend to 12m and so on until I send enough messages for the sub to reach the original target.
I modified the parameters suggested in the original post to no avail. Additionally, the function calc_leash_length_z doesn’t exist anymore.
Here’s the function that I’m using to send the message:
void Plugin::_sendPositionTargetGlobal(const double alt)
{
mavlink_message_t msg;
mavlink_set_position_target_global_int_t ptg;
memset(&ptg, 0, sizeof(ptg));
MAVLinkProtocol *mavlink = qgcApp()->toolbox()->mavlinkProtocol();
ptg.target_system = _activeVehicle->id();
ptg.target_component = _activeVehicle->compId();
ptg.coordinate_frame = MAV_FRAME_GLOBAL_INT;
ptg.type_mask = POSITION_TARGET_TYPEMASK_VX_IGNORE |
POSITION_TARGET_TYPEMASK_VY_IGNORE |
POSITION_TARGET_TYPEMASK_VZ_IGNORE |
POSITION_TARGET_TYPEMASK_AX_IGNORE |
POSITION_TARGET_TYPEMASK_AY_IGNORE |
POSITION_TARGET_TYPEMASK_AZ_IGNORE |
POSITION_TARGET_TYPEMASK_YAW_IGNORE |
POSITION_TARGET_TYPEMASK_YAW_RATE_IGNORE;
ptg.alt = alt;
mavlink_msg_set_position_target_global_int_encode_chan(
mavlink->getSystemId(),
mavlink->getComponentId(),
_sharedLink->mavlinkChannel(),
&msg,
&ptg);
_activeVehicle->sendMessageOnLinkThreadSafe(_sharedLink.get(), msg);
}
Also, I’m using the latest version of BlueOS and ArduPilot v4.1.2.
Would really appreciate some advice on this!