Skip to content

Commit

Permalink
Plane: use POSITION_TARGET_TYPEMASK enum for bitmasks
Browse files Browse the repository at this point in the history
- Use POSITION_TARGET_TYPEMASK.
- Remove duplicate check for guided mode.

Signed-off-by: Rhys Mainwaring <[email protected]>
  • Loading branch information
srmainwaring committed Mar 7, 2024
1 parent 6bdcedc commit 769ee2d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions ArduPlane/GCS_Mavlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,10 +1372,17 @@ void GCS_MAVLINK_Plane::handle_set_position_target_global_int(const mavlink_mess
// Unexpectedly, the mask is expecting "ones" for dimensions that should
// be IGNORNED rather than INCLUDED. See mavlink documentation of the
// SET_POSITION_TARGET_GLOBAL_INT message, type_mask field.
const uint16_t alt_mask = 0b1111111111111011; // (z mask at bit 3)

// bit mask for path following: ignore force_set, yaw, yaw_rate
const uint16_t path_mask = 0b1111111000000000;
// const uint16_t alt_mask = 0b1111111111111011; // (z mask at bit 3)
const uint16_t alt_mask = POSITION_TARGET_TYPEMASK_X_IGNORE | POSITION_TARGET_TYPEMASK_Y_IGNORE | POSITION_TARGET_TYPEMASK_Z_IGNORE
| 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_FORCE_SET
| POSITION_TARGET_TYPEMASK_YAW_IGNORE | POSITION_TARGET_TYPEMASK_YAW_RATE_IGNORE;

// bit mask for path following: force_set, yaw, yaw_rate
// const uint16_t path_mask = 0b1111110000000000;
const uint16_t path_mask = POSITION_TARGET_TYPEMASK_YAW_IGNORE
| POSITION_TARGET_TYPEMASK_YAW_RATE_IGNORE;

bool msg_valid = true;
AP_Mission::Mission_Command cmd = {0};
Expand Down Expand Up @@ -1454,10 +1461,7 @@ void GCS_MAVLINK_Plane::handle_set_position_target_global_int(const mavlink_mess
}
}

// only accept position updates when in GUIDED mode
if (!plane.control_mode->is_guided_mode()) {
return;
}
// update path guidance
plane.mode_guided.handle_guided_path_request(
cmd.content.location, unit_vel, path_curvature, dir_is_ccw);

Expand Down

0 comments on commit 769ee2d

Please sign in to comment.