Skip to content

Commit 6dfd6ae

Browse files
authored
Merge pull request #348 from tritonuas/fix/mavlink-data
chore: restore mav updates
2 parents bb2a26f + 7bfcc9f commit 6dfd6ae

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

src/network/mavlink.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ MavlinkClient::MavlinkClient(OBCConfig config)
173173
this->data.armed = armed;
174174
});
175175

176+
this->telemetry->subscribe_heading([this](mavsdk::Telemetry::Heading heading) {
177+
VLOG_F(DEBUG, "Heading: %d", heading.heading_deg);
178+
Lock lock(this->data_mut);
179+
this->data.heading_deg = heading.heading_deg;
180+
});
181+
182+
// TODO: AFTER UPDATING TO MAV 3, REPLACE WITH MAVSDK IMPLIMENTATION
176183
this->passthrough->subscribe_message(WIND_COV, [this](const mavlink_message_t& message) {
177184
// LOG_F(INFO, "UNIX TIME: %lu", message.payload64[0]);
178185

@@ -184,16 +191,18 @@ MavlinkClient::MavlinkClient(OBCConfig config)
184191
this->data.wind.y = (message.payload64[1] >> 48) & 0xFF;
185192
this->data.wind.z = (message.payload64[1] >> 40) & 0xFF;
186193
});
187-
// this->telemetry->subscribe_attitude_euler(
188-
// [this](mavsdk::Telemetry::EulerAngle attitude) {
189-
// VLOG_F(DEBUG, "Yaw: %f, Pitch: %f, Roll: %f)",
190-
// attitude.yaw_deg, attitude.pitch_deg, attitude.roll_deg);
191-
192-
// Lock lock(this->data_mut);
193-
// this->data.yaw_deg = attitude.yaw_deg;
194-
// this->data.pitch_deg = attitude.pitch_deg;
195-
// this->data.roll_deg = attitude.roll_deg;
196-
// });
194+
195+
196+
this->telemetry->subscribe_attitude_euler(
197+
[this](mavsdk::Telemetry::EulerAngle attitude) {
198+
VLOG_F(DEBUG, "Yaw: %f, Pitch: %f, Roll: %f)",
199+
attitude.yaw_deg, attitude.pitch_deg, attitude.roll_deg);
200+
201+
Lock lock(this->data_mut);
202+
this->data.yaw_deg = attitude.yaw_deg;
203+
this->data.pitch_deg = attitude.pitch_deg;
204+
this->data.roll_deg = attitude.roll_deg;
205+
});
197206
}
198207

199208
// Implement the triggerRelay method

tests/integration/mavlink_client.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ int main(int argc, char *argv[]) {
4242
LOG_S(INFO) << "LatLng: " << mav.latlng_deg().first <<
4343
", " << mav.latlng_deg().second;
4444
LOG_S(INFO) << "Heading: " << mav.heading_deg();
45+
LOG_S(INFO) << "Yaw: " << mav.heading_deg();
46+
LOG_S(INFO) << "Pitch: " << mav.pitch_deg();
47+
LOG_S(INFO) << "Roll: " << mav.roll_deg();
4548
std::this_thread::sleep_for(std::chrono::seconds(1));
4649
}
4750

0 commit comments

Comments
 (0)