41 lines
900 B
C++
41 lines
900 B
C++
#pragma once
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <mutex>
|
|
#include <string>
|
|
|
|
namespace lm {
|
|
|
|
class Database;
|
|
class MissionQueue;
|
|
|
|
class RobotRuntime
|
|
{
|
|
public:
|
|
explicit RobotRuntime(Database& db, MissionQueue& mission_queue);
|
|
|
|
nlohmann::json status() const;
|
|
bool start(std::string& err);
|
|
bool pause(std::string& err);
|
|
bool resetError(std::string& err);
|
|
bool setCmdVel(double linear, double angular, std::string& err);
|
|
bool setJoystick(bool engaged, const std::string& speed, std::string& err);
|
|
bool setActiveMap(const std::string& map_id, std::string& err);
|
|
void clearActiveMapIf(const std::string& map_id);
|
|
void tick();
|
|
|
|
private:
|
|
Database& db_;
|
|
MissionQueue& mission_queue_;
|
|
mutable std::mutex mu_;
|
|
nlohmann::json state_;
|
|
|
|
void load();
|
|
void saveUnlocked() const;
|
|
void ensureDefaultsUnlocked();
|
|
nlohmann::json buildStatusUnlocked() const;
|
|
};
|
|
|
|
} // namespace lm
|