Re-enabling the ignored axes after using set_target_depth function in ALT_HOLD mode

Hello dear forumers,
Today i was working on implementing the ALT_HOLD mode according to the pymavlink documentations. While i was reading and coding at the same time i got some questions in my mind.

When we are calling this function, we ignore some axes.

master.mav.set_position_target_global_int_send(
        int(1e3 * (time.time() - boot_time)), # ms since boot
        master.target_system, master.target_component,
        coordinate_frame=mavutil.mavlink.MAV_FRAME_GLOBAL_INT,
        type_mask=( # ignore everything except z position
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_X_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_Y_IGNORE |
            # DON'T mavutil.mavlink.POSITION_TARGET_TYPEMASK_Z_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_VX_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_VY_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_VZ_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_AX_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_AY_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_AZ_IGNORE |
            # DON'T mavutil.mavlink.POSITION_TARGET_TYPEMASK_FORCE_SET |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_YAW_IGNORE |
            mavutil.mavlink.POSITION_TARGET_TYPEMASK_YAW_RATE_IGNORE
        ), lat_int=0, lon_int=0, alt=depth, # (x, y WGS84 frame pos - not used), z [m]
        vx=0, vy=0, vz=0, # velocities in NED frame [m/s] (not used)
        afx=0, afy=0, afz=0, yaw=0, yaw_rate=0
        # accelerations in NED frame [N], yaw, yaw_rate
        #  (all not supported yet, ignored in GCS Mavlink)
    )

after using this function in my code, do i need to re-enable these ignored axes? And if i need to, what is the way of doing this?

At the end of the documentated code, it says:

# clean up (disarm) at the end
master.arducopter_disarm()
master.motors_disarmed_wait()

do i need to disarm the vehicle, every time i use depth hold actions to re-enable that ignored axes? Or are there a way that is not requires me to stop the motors?

Thanks for the time you reading this, any help will be appreciated.

Hi @toosat,

No - that function is being used to specify a new altitude (depth) for depth hold mode to target/aim for. The SET_POSITION_TARGET_GLOBAL_INT MAVLink message requires a value for several targets (x, y, and z position, velocity, and acceleration, and yaw and yaw rate), so in order to only update the depth (z) position target you need to explicitly specify that you’re not updating any of the other targets in this function call (i.e. the values you pass for them should be ignored). That’s what those typemask flags are doing :slight_smile:

The “clean up” section at the end is just there to make sure that the vehicle gets disarmed before the script stops (e.g. if you’re running that example to test things out, you don’t want the vehicle to keep running after the example is finished). In your own programs can disarm whenever it makes sense to do so.

1 Like

Hey @EliotBR ,
Thanks for the informations. We were out for a test yesterday, and i got some new quesitons in my mind. But first i’ll do my researches about them afterwards i’ll be asking my remained questions here in this topic :smiley:
Have a good day :slight_smile:

edit: typos.

1 Like