Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"pathing": {
"laps": 2,
"upload_distance_buffer_m": 50.0,
"dubins": {
"turning_radius": 30.0,
"point_separation": 20.0
Expand Down
1 change: 1 addition & 0 deletions configs/jetson.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"pathing": {
"laps": 10,
"upload_distance_buffer_m": 50.0,
"dubins": {
"turning_radius": 5.0,
"point_separation": 20.0
Expand Down
5 changes: 5 additions & 0 deletions include/core/mission_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class MissionState {
void setInitPath(const MissionPath& init_path);
MissionPath getInitPath();

void setNextWaypointPath(const MissionPath& next_waypoint_path);
MissionPath getNextWaypointPath();

void setCoveragePath(const MissionPath& coverage_path);
MissionPath getCoveragePath();

Expand Down Expand Up @@ -139,6 +142,8 @@ class MissionState {

std::mutex init_path_mut; // for reading/writing the initial path
MissionPath init_path;
std::mutex next_waypoint_path_mut; // for reading/writing the next waypoint path
MissionPath next_waypoint_path;
std::mutex coverage_path_mut; // for reading/writing the coverage path
MissionPath coverage_path;
std::mutex airdrop_path_mut;
Expand Down
6 changes: 3 additions & 3 deletions include/network/mavlink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class MavlinkClient {
mavsdk::Telemetry::RcStatus get_conn_status();
bool armAndHover(std::shared_ptr<MissionState> state);
bool startMission();
bool clearMission();

/*
* Triggers a relay on the ArduPilot
Expand All @@ -92,10 +93,9 @@ class MavlinkClient {
*/
bool triggerRelay(int relay_number, bool state);

// Safety Functions
void KILL_THE_PLANE_DO_NOT_CALL_THIS_ACCIDENTALLY();

// rtl
void rtl();
void returnToLaunch();

private:
mavsdk::Mavsdk mavsdk;
Expand Down
22 changes: 19 additions & 3 deletions include/pathing/static.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,27 @@ class AirdropApproachPathing {
*/
RRTPoint getCurrentLoc(std::shared_ptr<MissionState> state);

MissionPath generateInitialPath(std::shared_ptr<MissionState> state);
/**
* Calculates the approximate angle of exit out of a waypoint path
*
* @param path ==> the waypoint path
* @param state ==> mission state
* @return angle of exit (+x-axis is 0 deg, ccw is positive)
*/
double calculateFinalAngle(
const MissionPath& path,
const std::optional<CartesianConverter<GPSProtoVec>>& cartesianConverter);

std::vector<GPSCoord> generateInitialPath(std::shared_ptr<MissionState> state);

std::vector<GPSCoord>
generateNextWaypointPath(std::shared_ptr<MissionState> state, double start_angle);

MissionPath generateSearchPath(std::shared_ptr<MissionState> state);
std::vector<GPSCoord>
generateSearchPath(std::shared_ptr<MissionState> state, double start_angle);

MissionPath generateAirdropApproach(std::shared_ptr<MissionState> state, const GPSCoord &goal);
std::vector<GPSCoord>
generateAirdropApproach(std::shared_ptr<MissionState> state, const GPSCoord &goal);
Comment thread
AskewParity marked this conversation as resolved.

std::pair<double, double> estimateAreaCoveredAndPathLength(const std::vector<XYZCoord> &goals,
const Environment &airspace);
Expand Down
3 changes: 1 addition & 2 deletions include/ticks/path_gen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class PathGenTick : public Tick {
void init() override;
Tick* tick() override;
private:
std::future<MissionPath> init_path;
std::future<MissionPath> coverage_path;
std::future<void> paths_future;

void startPathGeneration();
};
Expand Down
1 change: 1 addition & 0 deletions include/utilities/obc_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ struct AirdropApproachConfig {

struct PathingConfig {
int laps;
double upload_distance_buffer_m;
DubinsConfig dubins;
RRTConfig rrt;
AirdropCoverageConfig coverage;
Expand Down
10 changes: 10 additions & 0 deletions src/core/mission_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ MissionPath MissionState::getInitPath() {
return this->init_path;
}

void MissionState::setNextWaypointPath(const MissionPath& next_waypoint_path) {
Lock lock(this->next_waypoint_path_mut);
this->next_waypoint_path = next_waypoint_path;
}

MissionPath MissionState::getNextWaypointPath() {
Lock lock(this->next_waypoint_path_mut);
return this->next_waypoint_path;
}

void MissionState::setCoveragePath(const MissionPath& coverage_path) {
Lock lock(this->coverage_path_mut);
this->coverage_path = coverage_path;
Expand Down
2 changes: 1 addition & 1 deletion src/network/gcs_routes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ DEF_GCS_HANDLE(Post, camera, runpipeline) {

DEF_GCS_HANDLE(Post, rtl) {
LOG_REQUEST("POST", "/rtl");
state->getMav()->rtl();
state->getMav()->returnToLaunch();
LOG_RESPONSE(INFO, "RTL activated", OK);
}

Expand Down
19 changes: 17 additions & 2 deletions src/network/mavlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ MavlinkClient::MavlinkClient(OBCConfig config)
});

this->telemetry->subscribe_heading([this](mavsdk::Telemetry::Heading heading) {
VLOG_F(DEBUG, "Heading: %d", heading.heading_deg);
VLOG_F(DEBUG, "Heading: %f deg", heading.heading_deg);
Lock lock(this->data_mut);
this->data.heading_deg = heading.heading_deg;
});
Expand Down Expand Up @@ -511,12 +511,27 @@ bool MavlinkClient::startMission() {
return true;
}

/**
* Clears the existng mission
*/
bool MavlinkClient::clearMission() {
LOG_F(INFO, "Sending clear mission command");
auto start_result = this->mission->clear_mission();
if (start_result != mavsdk::MissionRaw::Result::Success) {
LOG_S(ERROR) << "FAIL: Mission could not be cleared " << start_result;
return false;
}

LOG_F(INFO, "Mission Cleared!");
return true;
}

void MavlinkClient::KILL_THE_PLANE_DO_NOT_CALL_THIS_ACCIDENTALLY() {
LOG_F(ERROR, "KILLING THE PLANE: SETTING AFS_TERMINATE TO 1");
auto result = this->param->set_param_int("AFS_TERMINATE", 1);
LOG_S(ERROR) << "KILL RESULT: " << result;
}

void MavlinkClient::rtl() {
void MavlinkClient::returnToLaunch() {
this->action->return_to_launch();
}
Loading