Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
AutonomousTask.h
1#pragma once
2
3#include "../navtypes.h"
4
5#include <cmath>
6#include <condition_variable>
7#include <mutex>
8#include <thread>
9
10namespace autonomous {
11
12/*
13 * @brief This class facilitates autonomous navigation to a specified waypoint.
14 */
15class AutonomousTask {
16public:
17 /*
18 * @brief Constructs a new AutonomousTask
19 */
20 AutonomousTask();
21
22 /*
23 * @brief Destructs AutonomousTask object, joins _autonomous_task_thread
24 */
25 ~AutonomousTask();
26
27 /*
28 * @brief Starts an autonomous task to the provided waypoint
29 *
30 * @param navtypes::pose_t The waypoint to navigate to
31 */
32 void start(const navtypes::point_t&);
33
34 /*
35 * @brief Halts autonomous navigation by exiting the navigate() function and joining the
36 * autonomous task thread
37 */
38 void kill();
39
40private:
41 /*
42 * @brief Handles navigation to waypoint, called by start()
43 */
44 void navigate();
45
46 navtypes::point_t _waypoint_coords;
47 std::mutex _autonomous_task_mutex;
48 std::thread _autonomous_task_thread;
49 std::condition_variable _autonomous_task_cv;
50 bool _kill_called;
51};
52
53} // namespace autonomous
size_t start() const