Skip to content

Commit 6fec2a3

Browse files
authored
Merge pull request #237 from tritonuas/wind
Convert wind info from mavlink passthrough
2 parents ddcd9a5 + 5b990b6 commit 6fec2a3

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

src/network/mavlink.cpp

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
#include <mavsdk/mavsdk.h>
44
#include <mavsdk/plugins/action/action.h>
5-
#include <mavsdk/plugins/param/param.h>
65
#include <mavsdk/plugins/geofence/geofence.h>
76
#include <mavsdk/plugins/mavlink_passthrough/mavlink_passthrough.h>
87
#include <mavsdk/plugins/mission_raw/mission_raw.h>
8+
#include <mavsdk/plugins/param/param.h>
99
#include <mavsdk/plugins/telemetry/telemetry.h>
1010

1111
#include <atomic>
@@ -80,8 +80,7 @@ MavlinkClient::MavlinkClient(OBCConfig config)
8080
// require a recompile to change the typing of a specific parameter if you
8181
// get it wrong.
8282
auto result = mavsdk::Param::Result::Unknown;
83-
if (param == "FS_LONG_TIMEOUT" ||
84-
param == "AFS_RC_FAIL_TIME" ||
83+
if (param == "FS_LONG_TIMEOUT" || param == "AFS_RC_FAIL_TIME" ||
8584
param == "FS_SHORT_TIMEOUT") {
8685
result = this->param->set_param_float(param, val);
8786
} else {
@@ -175,22 +174,16 @@ MavlinkClient::MavlinkClient(OBCConfig config)
175174
});
176175

177176
this->passthrough->subscribe_message(WIND_COV, [this](const mavlink_message_t& message) {
178-
// auto payload = message.payload64;
177+
auto payload = message.payload64;
179178
// LOG_F(INFO, "UNIX TIME: %lu", payload[0]);
180179

181180
/*
182181
NOT TESTED - don't actually know where the data is in thie uint64_t[]
183182
TODO - test on actual pixhawk to make sure that the data makes sense
184183
*/
185-
186-
// this->data.wind.x = payload[1];
187-
// this->data.wind.y = payload[2];
188-
// this->data.wind.z = payload[3];
189-
190-
// can try and implement this for real if we need actual wind data
191-
this->data.wind.x = 0;
192-
this->data.wind.y = 0;
193-
this->data.wind.z = 0;
184+
this->data.wind.x = (payload[1] >> 56) & 0xFF;
185+
this->data.wind.y = (payload[1] >> 48) & 0xFF;
186+
this->data.wind.z = (payload[1] >> 40) & 0xFF;
194187
});
195188
// this->telemetry->subscribe_attitude_euler(
196189
// [this](mavsdk::Telemetry::EulerAngle attitude) {
@@ -205,8 +198,7 @@ MavlinkClient::MavlinkClient(OBCConfig config)
205198
}
206199

207200
bool MavlinkClient::uploadMissionUntilSuccess(std::shared_ptr<MissionState> state,
208-
bool upload_geofence,
209-
const MissionPath& path) const {
201+
bool upload_geofence, const MissionPath& path) const {
210202
if (upload_geofence) {
211203
if (!this->uploadGeofenceUntilSuccess(state)) {
212204
return false;
@@ -282,7 +274,6 @@ bool MavlinkClient::uploadWaypointsUntilSuccess(std::shared_ptr<MissionState> st
282274
const MissionPath& waypoints) const {
283275
LOG_SCOPE_F(INFO, "Uploading waypoints");
284276

285-
286277
while (true) {
287278
LOG_F(INFO, "Sending waypoint information...");
288279

@@ -379,9 +370,7 @@ mavsdk::Telemetry::FlightMode MavlinkClient::flight_mode() {
379370
return this->data.flight_mode;
380371
}
381372

382-
int32_t MavlinkClient::curr_waypoint() const {
383-
return this->mission->mission_progress().current;
384-
}
373+
int32_t MavlinkClient::curr_waypoint() const { return this->mission->mission_progress().current; }
385374

386375
bool MavlinkClient::isMissionFinished() {
387376
// Boolean representing if mission is finished

0 commit comments

Comments
 (0)