diff --git a/src/navtypes.h b/src/navtypes.h index 5ac7670f..ea2ebb4e 100644 --- a/src/navtypes.h +++ b/src/navtypes.h @@ -12,6 +12,8 @@ struct gpscoords_t { double lat; /** the longitude of the gps coordinate, in degrees */ double lon; + /** the altitude of the gps coordinate */ + double alt; }; /* @brief Euler angles to represent orientation. Rotation ordering is XYZ extrinsic diff --git a/src/network/MissionControlProtocol.cpp b/src/network/MissionControlProtocol.cpp index cec6d264..daa03481 100644 --- a/src/network/MissionControlProtocol.cpp +++ b/src/network/MissionControlProtocol.cpp @@ -271,11 +271,11 @@ static bool validateWaypointNavRequest(const json& j) { void MissionControlProtocol::handleWaypointNavRequest(const json& j) { float latitude = j["latitude"]; float longitude = j["longitude"]; + float altitude = j["altitude"]; bool isApproximate = j["isApproximate"]; bool isGate = j["isGate"]; - if (Globals::AUTONOMOUS && !isApproximate && !isGate) { - navtypes::gpscoords_t coords = {latitude, longitude}; + navtypes::gpscoords_t coords = {latitude, longitude, altitude}; auto target = robot::gpsToMeters(coords); if (target) { _autonomous_task.start(target.value()); diff --git a/src/network/MissionControlTasks.cpp b/src/network/MissionControlTasks.cpp index 7b4cf874..24de37d5 100644 --- a/src/network/MissionControlTasks.cpp +++ b/src/network/MissionControlTasks.cpp @@ -201,10 +201,11 @@ void TelemReportTask::sendTelemetry() { util::to_string(gps.isValid()).c_str()); if (imu.isValid()) { Eigen::Quaterniond quat = imu.getData(); - double lon = 0, lat = 0; + double lon = 0, lat = 0, alt = 0; if (gps.isValid()) { lon = gps.getData().lon; lat = gps.getData().lat; + alt = gps.getData().alt; } double imuRecency = util::durationToSec(dataclock::now() - imu.getTime()); double recency = imuRecency; @@ -212,6 +213,7 @@ void TelemReportTask::sendTelemetry() { double gpsRecency = util::durationToSec(dataclock::now() - gps.getTime()); recency = std::max(recency, gpsRecency); } + json msg = {{"type", ROVER_POS_REP_TYPE}, {"orientW", quat.w()}, {"orientX", quat.x()}, @@ -219,6 +221,7 @@ void TelemReportTask::sendTelemetry() { {"orientZ", quat.z()}, {"lon", lon}, {"lat", lat}, + {"alt", alt}, {"recency", recency}}; _server.sendJSON(Constants::MC_PROTOCOL_NAME, msg); } diff --git a/src/world_interface/simulator_interface.cpp b/src/world_interface/simulator_interface.cpp index f8348baf..aea1d1ac 100644 --- a/src/world_interface/simulator_interface.cpp +++ b/src/world_interface/simulator_interface.cpp @@ -129,7 +129,7 @@ void initMotors() { } void handleGPS(json msg) { - gpscoords_t coords{msg["latitude"], msg["longitude"]}; + gpscoords_t coords{msg["latitude"], msg["longitude"], msg["altitude"]}; std::lock_guard guard(gpsMutex); lastGPS = {coords}; }