Skip to content

Commit

Permalink
Changed gpscoords_t in navtypes.h to contain information about altitu…
Browse files Browse the repository at this point in the history
…de. Also changed the json that MissionControlTasks.cpp to contain information about altitude.
  • Loading branch information
PatrickRung committed Nov 5, 2024
1 parent d0c3ad0 commit d365336
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/navtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/network/MissionControlProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
5 changes: 4 additions & 1 deletion src/network/MissionControlTasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,24 +201,27 @@ 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;
if (gps.isValid()) {
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()},
{"orientY", quat.y()},
{"orientZ", quat.z()},
{"lon", lon},
{"lat", lat},
{"alt", alt},
{"recency", recency}};
_server.sendJSON(Constants::MC_PROTOCOL_NAME, msg);
}
Expand Down
2 changes: 1 addition & 1 deletion src/world_interface/simulator_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex> guard(gpsMutex);
lastGPS = {coords};
}
Expand Down

0 comments on commit d365336

Please sign in to comment.