-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add TagID and Radius to Waypoints
- Loading branch information
Showing
16 changed files
with
397 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ accur | |
ACCURACYDATA | ||
ADDMARKERLEG | ||
ADDOBJECTLEG | ||
ADDOBSTACLE | ||
ADDPOSITIONLEG | ||
algobase | ||
alloc | ||
|
Submodule rovecomm
updated
3 files
+1 −1 | data/RoveComm | |
+75 −22 | src/RoveComm/RoveCommManifest.h | |
+1 −1 | src/RoveComm/RoveCommPacket.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,11 +339,15 @@ void StateMachineHandler::HandleEvent(statemachine::Event eEvent, const bool bSa | |
// Acquire write lock for handling events. | ||
std::unique_lock<std::shared_mutex> lkEventProcessLock(m_muEventMutex); | ||
|
||
// Trigger the event on the current state | ||
statemachine::States eNextState = m_pCurrentState->TriggerEvent(eEvent); | ||
// Check if the current state is not null and the state machine is running. | ||
if (m_pCurrentState != nullptr && this->GetThreadState() == AutonomyThreadState::eRunning) | ||
{ | ||
// Trigger the event on the current state | ||
statemachine::States eNextState = m_pCurrentState->TriggerEvent(eEvent); | ||
|
||
// Transition to the next state | ||
ChangeState(eNextState, bSaveCurrentState); | ||
// Transition to the next state | ||
ChangeState(eNextState, bSaveCurrentState); | ||
} | ||
} | ||
|
||
/****************************************************************************** | ||
|
@@ -363,6 +367,22 @@ void StateMachineHandler::ClearSavedStates() | |
m_pPreviousState = std::make_shared<statemachine::IdleState>(); | ||
} | ||
|
||
/****************************************************************************** | ||
* @brief Clear a saved state based on the given state. | ||
* | ||
* @param eState - The state to clear from the saved states. | ||
* | ||
* @author clayjay3 ([email protected]) | ||
* @date 2025-01-06 | ||
******************************************************************************/ | ||
void StateMachineHandler::ClearSavedState(statemachine::States eState) | ||
{ | ||
// Acquire write lock for clearing saved states. | ||
std::unique_lock<std::shared_mutex> lkStateProcessLock(m_muStateMutex); | ||
// Remove all states that match the given state. | ||
m_umSavedStates.erase(eState); | ||
} | ||
|
||
/****************************************************************************** | ||
* @brief Accessor for the Current State private member. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,8 +146,26 @@ class WaypointHandler | |
// Not using this. | ||
(void) stdAddr; | ||
|
||
// Create instance variables. | ||
int nMarkerID = stPacket.vData[2]; | ||
double dRadius = stPacket.vData[3]; | ||
|
||
// Limit the radius to 0-40. | ||
if (dRadius < 0) | ||
{ | ||
// Submit logger message. | ||
LOG_WARNING(logging::g_qSharedLogger, "Incoming Marker Waypoint Data: Radius is less than 0, setting to 0."); | ||
dRadius = 0; | ||
} | ||
else if (dRadius > 40) | ||
{ | ||
// Submit logger message. | ||
LOG_WARNING(logging::g_qSharedLogger, "Incoming Marker Waypoint Data: Radius is greater than 40, setting to 40."); | ||
dRadius = 40; | ||
} | ||
|
||
// Create new waypoint struct with data from the RoveComm packet. | ||
geoops::Waypoint stMarkerWaypoint(geoops::GPSCoordinate(stPacket.vData[0], stPacket.vData[1]), geoops::WaypointType::eTagWaypoint); | ||
geoops::Waypoint stMarkerWaypoint(geoops::GPSCoordinate(stPacket.vData[0], stPacket.vData[1]), geoops::WaypointType::eTagWaypoint, dRadius, nMarkerID); | ||
|
||
// Acquire write lock for writing to waypoints vector. | ||
std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex); | ||
|
@@ -157,7 +175,12 @@ class WaypointHandler | |
lkWaypointsLock.unlock(); | ||
|
||
// Submit logger message. | ||
LOG_INFO(logging::g_qSharedLogger, "Incoming Marker Waypoint Data: Added (lat: {}, lon: {}) to WaypointHandler queue.", stPacket.vData[0], stPacket.vData[1]); | ||
LOG_INFO(logging::g_qSharedLogger, | ||
"Incoming Marker Waypoint Data: Added (lat: {}, lon: {}, marker ID: {}, radius: {}) to WaypointHandler queue.", | ||
stPacket.vData[0], | ||
stPacket.vData[1], | ||
nMarkerID, | ||
dRadius); | ||
}; | ||
|
||
/****************************************************************************** | ||
|
@@ -173,8 +196,25 @@ class WaypointHandler | |
// Not using this. | ||
(void) stdAddr; | ||
|
||
// Create instance variables. | ||
double dRadius = stPacket.vData[2]; | ||
|
||
// Limit the radius to 0-40. | ||
if (dRadius < 0) | ||
{ | ||
// Submit logger message. | ||
LOG_WARNING(logging::g_qSharedLogger, "Incoming Object Waypoint Data: Radius is less than 0, setting to 0."); | ||
dRadius = 0; | ||
} | ||
else if (dRadius > 40) | ||
{ | ||
// Submit logger message. | ||
LOG_WARNING(logging::g_qSharedLogger, "Incoming Object Waypoint Data: Radius is greater than 40, setting to 40."); | ||
dRadius = 40; | ||
} | ||
|
||
// Create new waypoint struct with data from the RoveComm packet. | ||
geoops::Waypoint stObjectWaypoint(geoops::GPSCoordinate(stPacket.vData[0], stPacket.vData[1]), geoops::WaypointType::eObjectWaypoint); | ||
geoops::Waypoint stObjectWaypoint(geoops::GPSCoordinate(stPacket.vData[0], stPacket.vData[1]), geoops::WaypointType::eObjectWaypoint, dRadius); | ||
|
||
// Acquire write lock for writing to waypoints vector. | ||
std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex); | ||
|
@@ -184,7 +224,59 @@ class WaypointHandler | |
lkWaypointsLock.unlock(); | ||
|
||
// Submit logger message. | ||
LOG_INFO(logging::g_qSharedLogger, "Incoming Object Waypoint Data: Added (lat: {}, lon: {}) to WaypointHandler queue.", stPacket.vData[0], stPacket.vData[1]); | ||
LOG_INFO(logging::g_qSharedLogger, | ||
"Incoming Object Waypoint Data: Added (lat: {}, lon: {}, radius: {}) to WaypointHandler queue.", | ||
stPacket.vData[0], | ||
stPacket.vData[1], | ||
dRadius); | ||
}; | ||
|
||
/****************************************************************************** | ||
* @brief Callback function that is called whenever RoveComm receives new ADDOBSTACLE packet. | ||
* | ||
* | ||
* @author clayjay3 ([email protected]) | ||
* @date 2025-01-06 | ||
******************************************************************************/ | ||
const std::function<void(const rovecomm::RoveCommPacket<double>&, const sockaddr_in&)> AddObstacleCallback = | ||
[this](const rovecomm::RoveCommPacket<double>& stPacket, const sockaddr_in& stdAddr) | ||
{ | ||
// Not using this. | ||
(void) stdAddr; | ||
|
||
// Create instance variables. | ||
double dRadius = stPacket.vData[2]; | ||
|
||
// Limit the radius to 0-40. | ||
if (dRadius < 0) | ||
{ | ||
// Submit logger message. | ||
LOG_WARNING(logging::g_qSharedLogger, "Incoming Obstacle Waypoint Data: Radius is less than 0, setting to 0."); | ||
dRadius = 0; | ||
} | ||
else if (dRadius > 40) | ||
{ | ||
// Submit logger message. | ||
LOG_WARNING(logging::g_qSharedLogger, "Incoming Obstacle Waypoint Data: Radius is greater than 40, setting to 40."); | ||
dRadius = 40; | ||
} | ||
|
||
// Create new waypoint struct with data from the RoveComm packet. | ||
geoops::Waypoint stObstacleWaypoint(geoops::GPSCoordinate(stPacket.vData[0], stPacket.vData[1]), geoops::WaypointType::eObstacleWaypoint, dRadius); | ||
|
||
// Acquire write lock for writing to waypoints vector. | ||
std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex); | ||
// Queue waypoint. | ||
m_vWaypointList.emplace_back(stObstacleWaypoint); | ||
// Unlock mutex. | ||
lkWaypointsLock.unlock(); | ||
|
||
// Submit logger message. | ||
LOG_INFO(logging::g_qSharedLogger, | ||
"Incoming Obstacle Waypoint Data: Added (lat: {}, lon: {}, radius: {}) to WaypointHandler queue.", | ||
stPacket.vData[0], | ||
stPacket.vData[1], | ||
dRadius); | ||
}; | ||
|
||
/****************************************************************************** | ||
|
Oops, something went wrong.