Skip to content

Commit

Permalink
AP_Mount: improve handling of invalid target
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Jul 20, 2023
1 parent 6bfe4ad commit 66a6f67
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
9 changes: 3 additions & 6 deletions libraries/AP_Mount/AP_Mount_Alexmos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ void AP_Mount_Alexmos::update()

// point to the angles given by a mavlink message
case MAV_MOUNT_MODE_MAVLINK_TARGETING:
// mavlink targets are stored while handling the incoming message and are considered valid
// mavlink targets are stored while handling the incoming message
break;

// RC radio manual angle control, but with stabilization from the AHRS
case MAV_MOUNT_MODE_RC_TARGETING: {
// update targets using pilot's RC inputs

if (get_rc_rate_target(mnt_target.rate_rads)) {
mnt_target.target_type = MountTargetType::RATE;
} else if (get_rc_angle_target(mnt_target.angle_rad)) {
Expand Down Expand Up @@ -87,13 +86,11 @@ void AP_Mount_Alexmos::update()
case MountTargetType::RATE:
update_angle_target_from_rate(mnt_target.rate_rads, mnt_target.angle_rad);
FALLTHROUGH;
case MountTargetType::INVALID:
case MountTargetType::ANGLE:
// send latest targets to gimbal
// send latest angle targets to gimbal
control_axis(mnt_target.angle_rad);
break;
default:
// invalid target, Do nothing
break;
}
}

Expand Down
9 changes: 5 additions & 4 deletions libraries/AP_Mount/AP_Mount_Gremsy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void AP_Mount_Gremsy::update()
}

case MAV_MOUNT_MODE_MAVLINK_TARGETING: {
// mavlink targets are stored while handling the incoming message set_angle_target() or set_rate_target() and are considered valid
// mavlink targets are stored while handling the incoming message set_angle_target() or set_rate_target()
break;
}

Expand Down Expand Up @@ -82,15 +82,16 @@ void AP_Mount_Gremsy::update()

// send target angles or rates depending on the target type
switch (mnt_target.target_type) {
case MountTargetType::INVALID:
// send zero rates
send_gimbal_device_set_rate(0, 0, 0, false);
break;
case MountTargetType::ANGLE:
send_gimbal_device_set_attitude(mnt_target.angle_rad.roll, mnt_target.angle_rad.pitch, mnt_target.angle_rad.yaw, mnt_target.angle_rad.yaw_is_ef);
break;
case MountTargetType::RATE:
send_gimbal_device_set_rate(mnt_target.rate_rads.roll, mnt_target.rate_rads.pitch, mnt_target.rate_rads.yaw, mnt_target.rate_rads.yaw_is_ef);
break;
default:
// invalid target, Do nothing
break;
}
}

Expand Down
5 changes: 2 additions & 3 deletions libraries/AP_Mount/AP_Mount_Servo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,14 @@ void AP_Mount_Servo::update()
case MountTargetType::RATE:
update_angle_target_from_rate(mnt_target.rate_rads, mnt_target.angle_rad);
FALLTHROUGH;
case MountTargetType::INVALID:
// use lastest angle targets
case MountTargetType::ANGLE:
// update _angle_bf_output_rad based on angle target
if ((mount_mode != MAV_MOUNT_MODE_RETRACT) & (mount_mode != MAV_MOUNT_MODE_NEUTRAL)) {
update_angle_outputs(mnt_target.angle_rad);
}
break;
default:
// invalid target, Do nothing
break;
}

// move mount to a "retracted position" into the fuselage with a fourth servo
Expand Down
9 changes: 5 additions & 4 deletions libraries/AP_Mount/AP_Mount_Siyi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void AP_Mount_Siyi::update()
}

case MAV_MOUNT_MODE_MAVLINK_TARGETING: {
// mavlink targets are stored while handling the incoming message and are considered valid
// mavlink targets are stored while handling the incoming message
break;
}

Expand Down Expand Up @@ -127,15 +127,16 @@ void AP_Mount_Siyi::update()

// send target angles or rates depending on the target type
switch (mnt_target.target_type) {
case MountTargetType::INVALID:
// send zero rates
send_target_rates(0, 0, false);
break;
case MountTargetType::ANGLE:
send_target_angles(mnt_target.angle_rad.pitch, mnt_target.angle_rad.yaw, mnt_target.angle_rad.yaw_is_ef);
break;
case MountTargetType::RATE:
send_target_rates(mnt_target.rate_rads.pitch, mnt_target.rate_rads.yaw, mnt_target.rate_rads.yaw_is_ef);
break;
default:
// invalid target, Do nothing
break;
}
}

Expand Down
7 changes: 4 additions & 3 deletions libraries/AP_Mount/AP_Mount_Viewpro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,16 @@ void AP_Mount_Viewpro::update()

// send target angles or rates depending on the target type
switch (mnt_target.target_type) {
case MountTargetType::INVALID:
// send zero rates
send_target_rates(0, 0, false);
break;
case MountTargetType::ANGLE:
send_target_angles(mnt_target.angle_rad.pitch, mnt_target.angle_rad.yaw, mnt_target.angle_rad.yaw_is_ef);
break;
case MountTargetType::RATE:
send_target_rates(mnt_target.rate_rads.pitch, mnt_target.rate_rads.yaw, mnt_target.rate_rads.yaw_is_ef);
break;
default:
// invalid target, Do nothing
break;
}
}

Expand Down
8 changes: 4 additions & 4 deletions libraries/AP_Mount/AP_Mount_Xacti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void AP_Mount_Xacti::update()
}

case MAV_MOUNT_MODE_MAVLINK_TARGETING: {
// mavlink targets are stored while handling the incoming message and are considered valid
// mavlink targets are set while handling the incoming message
break;
}

Expand Down Expand Up @@ -109,15 +109,15 @@ void AP_Mount_Xacti::update()

// send target angles or rates depending on the target type
switch (mnt_target.target_type) {
case MountTargetType::INVALID:
send_target_rates(0, 0, false);
break;
case MountTargetType::ANGLE:
send_target_angles(mnt_target.angle_rad.pitch, mnt_target.angle_rad.yaw, mnt_target.angle_rad.yaw_is_ef);
break;
case MountTargetType::RATE:
send_target_rates(mnt_target.rate_rads.pitch, mnt_target.rate_rads.yaw, mnt_target.rate_rads.yaw_is_ef);
break;
default:
// invalid target, Do nothing
break;
}
}

Expand Down

0 comments on commit 66a6f67

Please sign in to comment.