File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -254,20 +254,14 @@ void GimbalController::_handleGimbalDeviceAttitudeStatus(const mavlink_message_t
254254 const bool yaw_in_vehicle_frame = _yawInVehicleFrame (attitude_status.flags );
255255 if (yaw_in_vehicle_frame) {
256256 const float bodyYaw = qRadiansToDegrees (yaw);
257- float absoluteYaw = bodyYaw + headingDeg;
258- if (absoluteYaw > 180 .0f ) {
259- absoluteYaw -= 360 .0f ;
260- }
257+ const float absoluteYaw = std::remainder (bodyYaw + headingDeg, 360 .0f );
261258
262259 gimbal->setBodyYaw (bodyYaw);
263260 gimbal->setAbsoluteYaw (absoluteYaw);
264261
265262 } else {
266263 const float absoluteYaw = qRadiansToDegrees (yaw);
267- float bodyYaw = absoluteYaw - headingDeg;
268- if (bodyYaw < -180 .0f ) {
269- bodyYaw += 360 .0f ;
270- }
264+ const float bodyYaw = std::remainder (absoluteYaw - headingDeg, 360 .0f );
271265
272266 gimbal->setBodyYaw (bodyYaw);
273267 gimbal->setAbsoluteYaw (absoluteYaw);
You can’t perform that action at this time.
0 commit comments