Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
statemachine::SearchPatternState Class Reference

The SearchPatternState class implements the Search Pattern state for the Autonomy State Machine. More...

#include <SearchPatternState.h>

Inheritance diagram for statemachine::SearchPatternState:
Collaboration diagram for statemachine::SearchPatternState:

Public Member Functions

 SearchPatternState ()
 Construct a new State object.
 
void Run () override
 Run the state machine. Returns the next state.
 
States TriggerEvent (Event eEvent) override
 Trigger an event in the state machine. Returns the next state.
 
- Public Member Functions inherited from statemachine::State
 State (States eState)
 Construct a new State object.
 
virtual ~State ()=default
 Destroy the State object.
 
States GetState () const
 Accessor for the State private member.
 
virtual std::string ToString () const
 Accessor for the State private member. Returns the state as a string.
 
virtual bool operator== (const State &other) const
 Checks to see if the current state is equal to the passed state.
 
virtual bool operator!= (const State &other) const
 Checks to see if the current state is not equal to the passed state.
 

Protected Member Functions

void Start () override
 This method is called when the state is first started. It is used to initialize the state.
 
void Exit () override
 This method is called when the state is exited. It is used to clean up the state.
 

Private Types

enum class  SearchPatternType { eSpiral , eSnake , eZigZag , END }
 

Private Attributes

bool m_bInitialized
 
geoops::Waypoint m_stSearchPatternCenter
 
std::vector< std::shared_ptr< TagDetector > > m_vTagDetectors
 
std::vector< std::shared_ptr< ObjectDetector > > m_vObjectDetectors
 
std::vector< geoops::Waypointm_vSearchPath
 
int m_nSearchPathIdx
 
SearchPatternType m_eCurrentSearchPatternType
 
statemachine::TimeIntervalBasedStuckDetector m_StuckDetector
 
std::unique_ptr< logging::graphing::PathTracerm_pRoverPathPlot
 

Detailed Description

The SearchPatternState class implements the Search Pattern state for the Autonomy State Machine.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17

Member Enumeration Documentation

◆ SearchPatternType

enum class statemachine::SearchPatternState::SearchPatternType
strongprivate
51 {
52 eSpiral,
53 eSnake,
54 eZigZag,
55 END
56 };

Constructor & Destructor Documentation

◆ SearchPatternState()

statemachine::SearchPatternState::SearchPatternState ( )

Construct a new State object.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17
93 : State(States::eSearchPattern)
94 {
95 // Submit logger message.
96 LOG_INFO(logging::g_qConsoleLogger, "Entering State: {}", ToString());
97
98 // Initialize member variables.
99 m_bInitialized = false;
100 m_StuckDetector = statemachine::TimeIntervalBasedStuckDetector(constants::STUCK_CHECK_ATTEMPTS,
101 constants::STUCK_CHECK_INTERVAL,
102 constants::STUCK_CHECK_VEL_THRESH,
103 constants::STUCK_CHECK_ROT_THRESH);
104 m_pRoverPathPlot = std::make_unique<logging::graphing::PathTracer>("SearchPatternRoverPath");
105
106 // Start state.
107 if (!m_bInitialized)
108 {
109 Start();
110 m_bInitialized = true;
111 }
112 }
void Start() override
This method is called when the state is first started. It is used to initialize the state.
Definition SearchPatternState.cpp:35
virtual std::string ToString() const
Accessor for the State private member. Returns the state as a string.
Definition State.hpp:202
State(States eState)
Construct a new State object.
Definition State.hpp:145
This class should be instantiated within another state to be used for detection of if the rover is st...
Definition StuckDetection.hpp:43
Here is the call graph for this function:

Member Function Documentation

◆ Start()

void statemachine::SearchPatternState::Start ( )
overrideprotectedvirtual

This method is called when the state is first started. It is used to initialize the state.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17

Reimplemented from statemachine::State.

36 {
37 // Schedule the next run of the state's logic
38 LOG_INFO(logging::g_qSharedLogger, "SearchPatternState: Scheduling next run of state logic.");
39
40 // Initialize member variables.
41 m_eCurrentSearchPatternType = SearchPatternType::eSpiral;
42 m_nSearchPathIdx = 0;
43 m_stSearchPatternCenter = globals::g_pWaypointHandler->PeekNextWaypoint();
44
45 // Get the current rover pose.
46 geoops::RoverPose stCurrentRoverPose = globals::g_pStateMachineHandler->SmartRetrieveRoverPose();
47
48 // Calculate the search path.
49 m_vSearchPath = searchpattern::CalculateSpiralPatternWaypoints(m_stSearchPatternCenter.GetGPSCoordinate(),
50 constants::SEARCH_ANGULAR_STEP_DEGREES,
51 m_stSearchPatternCenter.dRadius,
52 stCurrentRoverPose.GetCompassHeading(),
53 constants::SEARCH_SPIRAL_SPACING);
54
55 // Add the search and rover path layers to the plot.
56 m_pRoverPathPlot->CreatePathLayer("SpiralSearchPattern", "-o");
57 m_pRoverPathPlot->CreateDotLayer("SnakeSearchPattern", "-g");
58 m_pRoverPathPlot->CreateDotLayer("VerticalZigZagSearchPattern", "yellow");
59 m_pRoverPathPlot->CreateDotLayer("DetectedTags", "blue");
60 m_pRoverPathPlot->CreateDotLayer("DetectedObjects", "purple");
61 m_pRoverPathPlot->CreatePathLayer("RoverPath", "-k");
62 // Plot the search path on the rover path.
63 m_pRoverPathPlot->AddPathPoints(m_vSearchPath, "SpiralSearchPattern", 0);
64
65 m_vTagDetectors = {globals::g_pTagDetectionHandler->GetTagDetector(TagDetectionHandler::TagDetectors::eHeadMainCam)};
66 m_vObjectDetectors = {globals::g_pObjectDetectionHandler->GetObjectDetector(ObjectDetectionHandler::ObjectDetectors::eHeadMainCam)};
67 }
std::shared_ptr< ObjectDetector > GetObjectDetector(ObjectDetectors eDetectorName)
Accessor for ObjectDetector detectors.
Definition ObjectDetectionHandler.cpp:127
geoops::RoverPose SmartRetrieveRoverPose(bool bVIOHeading=true, bool bVIOTracking=false)
Retrieve the rover's current position and heading. Automatically picks between getting the position/h...
Definition StateMachineHandler.cpp:445
std::shared_ptr< TagDetector > GetTagDetector(TagDetectors eDetectorName)
Accessor for TagDetector detectors.
Definition TagDetectionHandler.cpp:132
const geoops::Waypoint PeekNextWaypoint()
Returns an immutable reference to the geoops::Waypoint struct at the front of the list without removi...
Definition WaypointHandler.cpp:540
std::vector< geoops::Waypoint > CalculateSpiralPatternWaypoints(const geoops::Waypoint &stStartingPoint, const double dAngularStepDegrees=57, const double dMaxRadius=25, const double dStartingHeadingDegrees=0, const double dStartSpacing=1)
Perform a spiral search pattern starting from a given point.
Definition SearchPattern.hpp:49
This struct is used by the WaypointHandler to provide an easy way to store all pose data about the ro...
Definition GeospatialOperations.hpp:708
double GetCompassHeading() const
Accessor for the Compass Heading private member.
Definition GeospatialOperations.hpp:787
const geoops::GPSCoordinate & GetGPSCoordinate() const
Accessor for the geoops::GPSCoordinate member variable.
Definition GeospatialOperations.hpp:497
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Exit()

void statemachine::SearchPatternState::Exit ( )
overrideprotectedvirtual

This method is called when the state is exited. It is used to clean up the state.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17

Reimplemented from statemachine::State.

78 {
79 // Clean up the state before exiting
80 LOG_INFO(logging::g_qSharedLogger, "SearchPatternState: Exiting state.");
81
82 // Stop drive.
83 globals::g_pDriveBoard->SendStop();
84 }
void SendStop()
Stop the drivetrain of the Rover.
Definition DriveBoard.cpp:195
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Run()

void statemachine::SearchPatternState::Run ( )
overridevirtual

Run the state machine. Returns the next state.

Author
Jason Pittman (jspen.nosp@m.cerp.nosp@m.ittma.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-01-17

Implements statemachine::State.

121 {
122 // Submit logger message.
123 LOG_DEBUG(logging::g_qSharedLogger, "SearchPatternState: Running state-specific behavior.");
124
125 // Get the current rover pose.
126 geoops::RoverPose stCurrentRoverPose = globals::g_pStateMachineHandler->SmartRetrieveRoverPose();
127
128 // Add the current rover pose to the path plot.
129 m_pRoverPathPlot->AddPathPoint(stCurrentRoverPose.GetUTMCoordinate(), "RoverPath");
130
131 /*
132 The overall flow of this state is as follows.
133 1. Is there a tag -> MarkerSeen
134 2. Is there an object -> ObjectSeen
135 3. Is there an obstacle -> TBD
136 4. Is the rover stuck -> Stuck
137 5. Is the search pattern complete -> Abort
138 6. Follow the search pattern.
139 */
140
142 /* --- Detect Tags --- */
144
145 // In order to even care about any tags we see, the goal waypoint needs to be of type MARKER and we need to be within the search radius of the MARKER waypoint.
146 if (m_stSearchPatternCenter.eType == geoops::WaypointType::eTagWaypoint)
147 {
148 // Create instance variables.
149 tagdetectutils::ArucoTag stBestArucoTag, stBestTorchTag;
150 // Identify target marker.
151 statemachine::IdentifyTargetMarker(m_vTagDetectors, stBestArucoTag, stBestTorchTag, m_stSearchPatternCenter.nID);
152 // Check if either tag type is seen.
153 if (stBestArucoTag.nID != -1 || stBestTorchTag.dConfidence != 0.0)
154 {
155 // Submit logger message.
156 LOG_NOTICE(logging::g_qSharedLogger, "SearchPatternState: Rover has seen a target marker!");
157
158 // Check if the OpenCV tag has a good absolute position.
159 if (stBestArucoTag.nID != -1 && stBestArucoTag.stGeolocatedPosition.eType == geoops::WaypointType::eTagWaypoint)
160 {
161 // Add the tag to the path plot.
162 m_pRoverPathPlot->AddDot(stBestArucoTag.stGeolocatedPosition.GetUTMCoordinate(), "DetectedTags");
163 }
164 // Check if the torch tag has a good absolute position.
165 if (stBestTorchTag.dConfidence != 0.0 && stBestTorchTag.stGeolocatedPosition.eType == geoops::WaypointType::eTagWaypoint)
166 {
167 // Add the tag to the path plot.
168 m_pRoverPathPlot->AddDot(stBestTorchTag.stGeolocatedPosition.GetUTMCoordinate(), "DetectedTags");
169 }
170
171 // Handle state transition and save the current search pattern state.
172 globals::g_pStateMachineHandler->HandleEvent(Event::eMarkerSeen, true);
173 // Don't execute the rest of the state.
174 return;
175 }
176 }
177
179 /* --- Detect Objects --- */
181
182 // In order to even care about any objects we see, the goal waypoint needs to be of an object type and we need to be within the search radius of the object
183 // waypoint.
184 if (m_stSearchPatternCenter.eType == geoops::WaypointType::eObjectWaypoint || m_stSearchPatternCenter.eType == geoops::WaypointType::eMalletWaypoint ||
185 m_stSearchPatternCenter.eType == geoops::WaypointType::eWaterBottleWaypoint || m_stSearchPatternCenter.eType == geoops::WaypointType::eRockPickWaypoint)
186 {
187 // Create instance variables.
188 objectdetectutils::Object stBestTorchObject;
189 // Identify target object.
190 statemachine::IdentifyTargetObject(m_vObjectDetectors, stBestTorchObject, m_stSearchPatternCenter.eType);
191 // Check if either tag type is seen.
192 if (stBestTorchObject.dConfidence != 0.0)
193 {
194 // Submit logger message.
195 LOG_NOTICE(logging::g_qSharedLogger, "SearchPatternState: Rover has seen a target object!");
196
197 // Check if the torch tag has a good absolute position.
198 if (stBestTorchObject.dConfidence != 0.0 && stBestTorchObject.stGeolocatedPosition.eType == geoops::WaypointType::eObjectWaypoint)
199 {
200 // Add the tag to the path plot.
201 m_pRoverPathPlot->AddDot(stBestTorchObject.stGeolocatedPosition.GetUTMCoordinate(), "DetectedObjects");
202 }
203
204 // Handle state transition and save the current search pattern state.
205 globals::g_pStateMachineHandler->HandleEvent(Event::eObjectSeen, true);
206 // Don't execute the rest of the state.
207 return;
208 }
209 }
210
212 /* --- Detect Obstacles --- */
214
215 // TODO: Add obstacle detection to SearchPattern state
216
218 /* --- Check if the rover is stuck --- */
220
221 // Check if stuck.
222 if (constants::SEARCH_ENABLE_STUCK_DETECT &&
223 m_StuckDetector.CheckIfStuck(globals::g_pStateMachineHandler->SmartRetrieveVelocity(), globals::g_pStateMachineHandler->SmartRetrieveAngularVelocity()))
224 {
225 // Submit logger message.
226 LOG_WARNING(logging::g_qSharedLogger, "SearchPattern: Rover has become stuck!");
227 // Increment search path index so we skip the waypoint where we got stuck when reentering searchpattern.
228 m_nSearchPathIdx += 1;
229 // Check path index is within bounds.
230 if (m_nSearchPathIdx >= int(m_vSearchPath.size()))
231 {
232 m_nSearchPathIdx = m_vSearchPath.size() - 1;
233 }
234 // Handle state transition and save the current search pattern state.
235 globals::g_pStateMachineHandler->HandleEvent(Event::eStuck, true);
236 // Don't execute the rest of the state.
237 return;
238 }
239
241 /* --- Follow Search Pattern --- */
243
244 // Check if the search path is empty.
245 if (m_vSearchPath.empty())
246 {
247 // Submit logger message.
248 LOG_WARNING(logging::g_qSharedLogger, "SearchPatternState: Search path is empty, aborting search.");
249 // Handle state transition.
250 globals::g_pStateMachineHandler->HandleEvent(Event::eAbort);
251 return;
252 }
253
254 // Have we reached the current waypoint?
255 geoops::GPSCoordinate stCurrTargetGPS = m_vSearchPath[m_nSearchPathIdx].GetGPSCoordinate();
256 geoops::GeoMeasurement stCurrRelToTarget = geoops::CalculateGeoMeasurement(stCurrentRoverPose.GetGPSCoordinate(), stCurrTargetGPS);
257 bool bReachedTarget = stCurrRelToTarget.dDistanceMeters <= constants::SEARCH_WAYPOINT_PROXIMITY;
258
259 // If the entire search pattern has been completed without seeing tags or objects, try different search pattern.
260 if (bReachedTarget && m_nSearchPathIdx >= int(m_vSearchPath.size() - 1))
261 {
262 globals::g_pStateMachineHandler->HandleEvent(Event::eSearchFailed);
263 return;
264 }
265 // Move on to the next waypoint in the search path.
266 else if (bReachedTarget)
267 {
268 ++m_nSearchPathIdx;
269 stCurrTargetGPS = m_vSearchPath[m_nSearchPathIdx].GetGPSCoordinate();
270 stCurrRelToTarget = geoops::CalculateGeoMeasurement(stCurrentRoverPose.GetGPSCoordinate(), stCurrTargetGPS);
271 }
272
273 // Drive to target waypoint.
274 diffdrive::DrivePowers stDrivePowers = globals::g_pDriveBoard->CalculateMove(constants::SEARCH_MOTOR_POWER,
275 stCurrRelToTarget.dStartRelativeBearing,
276 stCurrentRoverPose.GetCompassHeading(),
277 diffdrive::DifferentialControlMethod::eArcadeDrive);
278
279 // Send drive powers over RoveComm.
280 globals::g_pDriveBoard->SendDrive(stDrivePowers);
281
282 return;
283 }
void SendDrive(const diffdrive::DrivePowers &stDrivePowers, const bool bEnableVariableDriveEffort=true)
Sets the left and right drive powers of the drive board.
Definition DriveBoard.cpp:118
diffdrive::DrivePowers CalculateMove(const double dGoalSpeed, const double dGoalHeading, const double dActualHeading, const diffdrive::DifferentialControlMethod eKinematicsMethod=diffdrive::DifferentialControlMethod::eArcadeDrive, const bool bAlwaysProgressForward=false)
This method determines drive powers to make the Rover drive towards a given heading at a given speed.
Definition DriveBoard.cpp:88
void HandleEvent(statemachine::Event eEvent, const bool bSaveCurrentState=false)
This method Handles Events that are passed to the State Machine Handler. It will check the current st...
Definition StateMachineHandler.cpp:353
bool CheckIfStuck(double dCurrentVelocity, double dCurrentAngularVelocity)
Checks if the rover meets stuck criteria based in the given parameters.
Definition StuckDetection.hpp:105
GeoMeasurement CalculateGeoMeasurement(const GPSCoordinate &stCoord1, const GPSCoordinate &stCoord2)
The shortest path between two points on an ellipsoid at (lat1, lon1) and (lat2, lon2) is called the g...
Definition GeospatialOperations.hpp:553
int IdentifyTargetMarker(const std::vector< std::shared_ptr< TagDetector > > &vTagDetectors, tagdetectutils::ArucoTag &stArucoTarget, tagdetectutils::ArucoTag &stTorchTarget, const int nTargetTagID=static_cast< int >(manifest::Autonomy::AUTONOMYWAYPOINTTYPES::ANY))
Identify a target marker in the rover's vision, using OpenCV detection.
Definition TagDetectionChecker.hpp:91
int IdentifyTargetObject(const std::vector< std::shared_ptr< ObjectDetector > > &vObjectDetectors, objectdetectutils::Object &stObjectTarget, const geoops::WaypointType &eDesiredDetectionType=geoops::WaypointType::eUNKNOWN)
Identify a target object in the rover's vision, using Torch detection.
Definition ObjectDetectionChecker.hpp:90
This struct is used to store the left and right drive powers for the robot. Storing these values in a...
Definition DifferentialDrive.hpp:73
This struct stores/contains information about a GPS data.
Definition GeospatialOperations.hpp:100
This struct is used to store the distance, arc length, and relative bearing for a calculated geodesic...
Definition GeospatialOperations.hpp:83
const geoops::GPSCoordinate & GetGPSCoordinate() const
Accessor for the geoops::GPSCoordinate member variable.
Definition GeospatialOperations.hpp:756
const geoops::UTMCoordinate & GetUTMCoordinate() const
Accessor for the geoops::UTMCoordinate member variable.
Definition GeospatialOperations.hpp:767
const geoops::UTMCoordinate & GetUTMCoordinate() const
Accessor for the geoops::UTMCoordinate member variable.
Definition GeospatialOperations.hpp:508
Represents a single detected object. Combines attributes from TorchObject and TensorflowObject struct...
Definition ObjectDetectionUtility.hpp:74
Represents a single ArUco tag. Combines attributes from TorchTag, TensorflowTag, and the original Aru...
Definition TagDetectionUtilty.hpp:59
Here is the call graph for this function:

◆ TriggerEvent()

States statemachine::SearchPatternState::TriggerEvent ( Event  eEvent)
overridevirtual

Trigger an event in the state machine. Returns the next state.

Parameters
eEvent- The event to trigger.
Returns
std::shared_ptr<State> - The next state.
Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17

Implements statemachine::State.

295 {
296 // Create instance variables.
297 States eNextState = States::eSearchPattern;
298 bool bCompleteStateExit = true;
299
300 switch (eEvent)
301 {
302 case Event::eMarkerSeen:
303 {
304 // Submit logger message.
305 LOG_INFO(logging::g_qSharedLogger, "SearchPatternState: Handling MarkerSeen event.");
306 // Change states.
307 eNextState = States::eApproachingMarker;
308 break;
309 }
310 case Event::eObjectSeen:
311 {
312 // Submit logger message.
313 LOG_INFO(logging::g_qSharedLogger, "SearchPatternState: Handling ObjectSeen event.");
314 // Change state.
315 eNextState = States::eApproachingObject;
316 break;
317 }
318 case Event::eStart:
319 {
320 // Submit logger message
321 LOG_NOTICE(logging::g_qSharedLogger, "SearchPatternState: Handling Start event.");
322 // Send multimedia command to update state display.
323 globals::g_pMultimediaBoard->SendLightingState(MultimediaBoard::MultimediaBoardLightingState::eAutonomy);
324 break;
325 }
326 case Event::eSearchFailed:
327 {
328 // Submit logger message.
329 LOG_INFO(logging::g_qSharedLogger, "SearchPatternState: Handling SearchFailed event.");
330 // Stop drive.
331 globals::g_pDriveBoard->SendStop();
332
333 // Regenerate a new search pattern.
334 switch (m_eCurrentSearchPatternType)
335 {
336 // Check which pattern to do next.
337 case SearchPatternType::eSpiral:
338 {
339 // Submit logger message.
340 LOG_NOTICE(logging::g_qSharedLogger, "SearchPatternState: Spiral search pattern failed, trying snake...");
341 // Generate vertical zigzag pattern.
342 m_vSearchPath = searchpattern::CalculateSnakeSearchPattern(m_stSearchPatternCenter.GetGPSCoordinate(),
343 m_stSearchPatternCenter.dRadius * 2,
344 m_stSearchPatternCenter.dRadius * 2,
345 constants::SEARCH_ZIGZAG_SPACING,
346 constants::SEARCH_SNAKE_SLITHERS);
347 // Reset index counter.
348 m_nSearchPathIdx = 0;
349 // Update current search pattern
350 m_eCurrentSearchPatternType = SearchPatternType::eSnake;
351
352 // Add the search and rover path layers to the plot.
353 m_pRoverPathPlot->AddDots(m_vSearchPath, "SnakeSearchPattern");
354 break;
355 }
356 case SearchPatternType::eSnake:
357 {
358 // Submit logger message.
359 LOG_NOTICE(logging::g_qSharedLogger, "SearchPatternState: Snake search pattern failed, trying ZigZag...");
360 // Generate vertical zigzag pattern.
361 m_vSearchPath = searchpattern::CalculateZigZagPatternWaypoints(m_stSearchPatternCenter.GetGPSCoordinate(),
362 m_stSearchPatternCenter.dRadius * 2,
363 m_stSearchPatternCenter.dRadius * 2,
364 constants::SEARCH_ZIGZAG_SPACING);
365 // Reset index counter.
366 m_nSearchPathIdx = 0;
367 // Update current search pattern
368 m_eCurrentSearchPatternType = SearchPatternType::END;
369
370 // Add the search and rover path layers to the plot.
371 m_pRoverPathPlot->AddDots(m_vSearchPath, "VerticalZigZagSearchPattern");
372 break;
373 }
374 case SearchPatternType::END:
375 {
376 // Submit logger message.
377 LOG_WARNING(logging::g_qSharedLogger, "SearchPatternState: All patterns failed to find anything, giving up...");
378 // Pop old waypoint out of queue.
379 globals::g_pWaypointHandler->PopNextWaypoint();
380 // Change states.
381 eNextState = States::eIdle;
382 break;
383 }
384 default:
385 {
386 // Change states.
387 eNextState = States::eIdle;
388 break;
389 }
390 }
391 break;
392 }
393 case Event::eAbort:
394 {
395 // Submit logger message.
396 LOG_INFO(logging::g_qSharedLogger, "SearchPatternState: Handling Abort event.");
397 // Send multimedia command to update state display.
398 globals::g_pMultimediaBoard->SendLightingState(MultimediaBoard::MultimediaBoardLightingState::eOff);
399 // Stop drive.
400 globals::g_pDriveBoard->SendStop();
401 // Change state.
402 eNextState = States::eIdle;
403 break;
404 }
405 case Event::eStuck:
406 {
407 LOG_INFO(logging::g_qSharedLogger, "SearchPatternState: Handling Stuck event.");
408 eNextState = States::eStuck;
409 break;
410 }
411 default:
412 {
413 LOG_WARNING(logging::g_qSharedLogger, "SearchPatternState: Handling unknown event.");
414 eNextState = States::eIdle;
415 break;
416 }
417 }
418
419 if (eNextState != States::eSearchPattern)
420 {
421 LOG_INFO(logging::g_qSharedLogger, "SearchPatternState: Transitioning to {} State.", StateToString(eNextState));
422
423 // Exit the current state
424 if (bCompleteStateExit)
425 {
426 Exit();
427 }
428 }
429
430 return eNextState;
431 }
void SendLightingState(MultimediaBoardLightingState eState)
Sends a predetermined color pattern to board.
Definition MultimediaBoard.cpp:55
geoops::Waypoint PopNextWaypoint()
Removes and returns the next waypoint at the front of the list.
Definition WaypointHandler.cpp:500
void Exit() override
This method is called when the state is exited. It is used to clean up the state.
Definition SearchPatternState.cpp:77
std::vector< geoops::Waypoint > CalculateSnakeSearchPattern(const geoops::Waypoint &stStartCoord, const double dWidth=20.0, const double dHeight=20.0, const double dSpacing=1.0, const int nNumberOfSlithers=1.0, const bool bVertical=true)
Calculate waypoints for a snake search pattern.
Definition SearchPattern.hpp:286
std::vector< geoops::Waypoint > CalculateZigZagPatternWaypoints(const geoops::Waypoint &stCenterPoint, const double dWidth=20.0, const double dHeight=20.0, const double dSpacing=1.0, const bool bVertical=true)
Calculate waypoints for a zigzag pattern. This function generates waypoints for a zigzag pattern star...
Definition SearchPattern.hpp:124
std::string StateToString(States eState)
Converts a state object to a string.
Definition State.hpp:85
States
The states that the state machine can be in.
Definition State.hpp:31
Here is the call graph for this function:

The documentation for this class was generated from the following files: