Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ffd010b

Browse files
danieleLorenzMeier
daniele
authored andcommitted
add yaw_absolute to mount_orientation
1 parent 44c7b90 commit ffd010b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/modules/mavlink/mavlink_messages.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4721,7 +4721,8 @@ class MavlinkStreamMountOrientation : public MavlinkStream
47214721

47224722
private:
47234723
MavlinkOrbSubscription *_mount_orientation_sub;
4724-
uint64_t _mount_orientation_time;
4724+
MavlinkOrbSubscription *_gpos_sub;
4725+
uint64_t _mount_orientation_time{0};
47254726

47264727
/* do not allow top copying this class */
47274728
MavlinkStreamMountOrientation(MavlinkStreamMountOrientation &) = delete;
@@ -4730,12 +4731,12 @@ class MavlinkStreamMountOrientation : public MavlinkStream
47304731
protected:
47314732
explicit MavlinkStreamMountOrientation(Mavlink *mavlink) : MavlinkStream(mavlink),
47324733
_mount_orientation_sub(_mavlink->add_orb_subscription(ORB_ID(mount_orientation))),
4733-
_mount_orientation_time(0)
4734+
_gpos_sub(_mavlink->add_orb_subscription(ORB_ID(vehicle_global_position)))
47344735
{}
47354736

47364737
bool send(const hrt_abstime t) override
47374738
{
4738-
struct mount_orientation_s mount_orientation;
4739+
mount_orientation_s mount_orientation{};
47394740

47404741
if (_mount_orientation_sub->update(&_mount_orientation_time, &mount_orientation)) {
47414742
mavlink_mount_orientation_t msg = {};
@@ -4744,6 +4745,10 @@ class MavlinkStreamMountOrientation : public MavlinkStream
47444745
msg.pitch = math::degrees(mount_orientation.attitude_euler_angle[1]);
47454746
msg.yaw = math::degrees(mount_orientation.attitude_euler_angle[2]);
47464747

4748+
vehicle_global_position_s gpos{};
4749+
_gpos_sub->update(&gpos);
4750+
msg.yaw_absolute = math::degrees(matrix::wrap_2pi(gpos.yaw + mount_orientation.attitude_euler_angle[2]));
4751+
47474752
mavlink_msg_mount_orientation_send_struct(_mavlink->get_channel(), &msg);
47484753

47494754
return true;

0 commit comments

Comments
 (0)