Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
MissionControlTasks.h
1#pragma once
2
3#include "../utils/scheduler.h"
4#include "../video/H264Encoder.h"
5#include "../world_interface/data.h"
6#include "websocket/WebSocketServer.h"
7
8#include <memory>
9#include <mutex>
10#include <optional>
11#include <unordered_map>
12#include <utility>
13
14namespace net::mc::tasks {
15
20class PowerRepeatTask : public util::PeriodicTask<> {
21public:
22 PowerRepeatTask();
23
28 void setJointPower(robot::types::jointid_t id, double power);
29
34 void setCmdVel(double steerVel, double xVel);
35
40 void setTankCmdVel(double steerVel, double xVel);
41
46 void setTurnInPlaceCmdVel(double steerVel);
47
52 void setCrabCmdVel(double steerVel, double xVel);
53
54 void start() override;
55
56 void stop() override;
57
58private:
59 std::mutex _mutex;
61 // if not present, then there is no last requested drive power
62 std::optional<std::pair<double, double>> _last_cmd_vel;
63 bool _tank;
64
65 void periodicTask();
66};
67
72class CameraStreamTask : public util::AsyncTask<> {
73public:
74 CameraStreamTask(websocket::SingleClientWSServer& server);
75
82 void openStream(const robot::types::CameraID& cam, int fps);
83
90
91protected:
93
94private:
96 std::mutex _mutex;
99 _camera_encoders;
100};
101
105class TelemReportTask : public util::PeriodicTask<> {
106public:
107 TelemReportTask(websocket::SingleClientWSServer& server);
108
109private:
111
112 void sendTelemetry();
113};
114
120class ArmIKTask : public util::PeriodicTask<> {
121public:
122 ArmIKTask(websocket::SingleClientWSServer& server);
123
124private:
125 std::mutex _mutex;
127
128 void updateArmIK();
129};
130
131} // namespace net::mc::tasks
_Tp power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
void lock(_L1 &__l1, _L2 &__l2, _L3 &... __l3)
void openStream(const robot::types::CameraID &cam, int fps)
Start streaming a new camera to Mission Control.
Definition MissionControlTasks.cpp:129
void closeStream(const robot::types::CameraID &cam)
Stop streaming a camera to Mission Control.
Definition MissionControlTasks.cpp:138
void task(std::unique_lock< std::mutex > &lock) override
The long-running task, overridden by client code.
Definition MissionControlTasks.cpp:144
void setJointPower(robot::types::jointid_t id, double power)
Set the power to resend to the given joint.
Definition MissionControlTasks.cpp:40
void setTankCmdVel(double steerVel, double xVel)
Set the tank drive command to resend.
Definition MissionControlTasks.cpp:51
void setCrabCmdVel(double steerVel, double xVel)
Set the crab drive command to resend.
Definition MissionControlTasks.cpp:67
void setCmdVel(double steerVel, double xVel)
Set the drive command to resend.
Definition MissionControlTasks.cpp:45
void stop() override
Stop the task and wait for it to finish.
Definition MissionControlTasks.cpp:83
void start() override
Start the task.
Definition MissionControlTasks.cpp:77
void setTurnInPlaceCmdVel(double steerVel)
Set the turn-in-place drive command to resend.
Definition MissionControlTasks.cpp:57
A WebSocket server class that only accepts a single client at a time to each endpoint served by this ...
Definition WebSocketServer.h:35
An abstract class that can be overridden to run long-running tasks and encapsulate task-related data.
Definition scheduler.h:316
Implements a task that executes a function periodically.
Definition scheduler.h:484
Namespace for camera access system.
Definition Camera.cpp:13
std::string CameraID
The type of a camera id.
Definition data.h:46