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 "../world_interface/world_interface.h"
7#include "websocket/WebSocketServer.h"
8
9#include <memory>
10#include <mutex>
11#include <optional>
12#include <unordered_map>
13#include <utility>
14
15namespace net::mc::tasks {
16
21class PowerRepeatTask : public util::PeriodicTask<> {
22public:
23 PowerRepeatTask();
24
29 void setJointPower(robot::types::jointid_t id, double power);
30
35 void setCmdVel(double steerVel, double xVel);
36
41 void setTankCmdVel(double steerVel, double xVel);
42
43 void start() override;
44
45 void stop() override;
46
47private:
48 std::mutex _mutex;
50 // if not present, then there is no last requested drive power
51 std::optional<std::pair<double, double>> _last_cmd_vel;
52 bool _tank;
53
54 void periodicTask();
55};
56
61class CameraStreamTask : public util::AsyncTask<> {
62public:
63 CameraStreamTask(websocket::SingleClientWSServer& server);
64
71 void openStream(const robot::types::CameraID& cam, int fps);
72
79
80protected:
82
83private:
84 struct stream_data_t {
87 uint32_t frame_num;
88
89 stream_data_t(std::shared_ptr<video::H264Encoder> encoder,
91 : encoder(encoder), cam_handle(cam_handle), frame_num(0) {}
92 };
93
94
96 std::mutex _mutex;
98};
99
103class TelemReportTask : public util::PeriodicTask<> {
104public:
105 TelemReportTask(websocket::SingleClientWSServer& server);
106
107private:
109
110 void sendTelemetry();
111};
112
118class ArmIKTask : public util::PeriodicTask<> {
119public:
120 ArmIKTask(websocket::SingleClientWSServer& server);
121
122private:
123 std::mutex _mutex;
125
126 void updateArmIK();
127};
128
129} // 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:83
void closeStream(const robot::types::CameraID &cam)
Stop streaming a camera to Mission Control.
Definition MissionControlTasks.cpp:105
void task(std::unique_lock< std::mutex > &lock) override
The long-running task, overridden by client code.
Definition MissionControlTasks.cpp:112
void setJointPower(robot::types::jointid_t id, double power)
Set the power to resend to the given joint.
Definition MissionControlTasks.cpp:28
void setTankCmdVel(double steerVel, double xVel)
Set the tank drive command to resend.
Definition MissionControlTasks.cpp:39
void setCmdVel(double steerVel, double xVel)
Set the drive command to resend.
Definition MissionControlTasks.cpp:33
void stop() override
Stop the task and wait for it to finish.
Definition MissionControlTasks.cpp:51
void start() override
Start the task.
Definition MissionControlTasks.cpp:45
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
::uint32_t uint32_t
uint32_t CameraID
The type of a camera id.
Definition data.h:46