Thunderbots Project
Loading...
Searching...
No Matches
unix_simulator_backend.h
1#pragma once
2
3#include <mutex>
4
5#include "proto/parameters.pb.h"
6#include "proto/replay_bookmark.pb.h"
7#include "proto/robot_crash_msg.pb.h"
8#include "proto/robot_log_msg.pb.h"
9#include "proto/robot_status_msg.pb.h"
10#include "proto/sensor_msg.pb.h"
11#include "proto/tbots_software_msgs.pb.h"
12#include "proto/validation.pb.h"
13#include "proto/world.pb.h"
14#include "software/backend/backend.h"
15#include "software/logger/proto_logger.h"
16#include "software/networking/unix/threaded_proto_unix_listener.hpp"
17#include "software/networking/unix/threaded_proto_unix_sender.hpp"
18
19class UnixSimulatorBackend : public Backend, public Subject<TbotsProto::ThunderbotsConfig>
20{
21 public:
27 UnixSimulatorBackend(std::string runtime_dir,
28 const std::shared_ptr<ProtoLogger>& proto_logger);
29
33 double getLastWorldTimeSec();
34
35 private:
36 void receiveThunderbotsConfig(TbotsProto::ThunderbotsConfig request);
37 void onValueReceived(TbotsProto::PrimitiveSet primitives) override;
38 void onValueReceived(World world) override;
39
40 // ThreadedProtoUnix** to communicate with Thunderscope
41 // Inputs
42 std::unique_ptr<ThreadedProtoUnixListener<TbotsProto::RobotStatus>>
43 robot_status_input;
44 std::unique_ptr<ThreadedProtoUnixListener<SSLProto::SSL_WrapperPacket>>
45 ssl_wrapper_input;
46 std::unique_ptr<ThreadedProtoUnixListener<SSLProto::Referee>> ssl_referee_input;
47 std::unique_ptr<ThreadedProtoUnixListener<SensorProto>> sensor_proto_input;
48 std::unique_ptr<ThreadedProtoUnixListener<TbotsProto::ThunderbotsConfig>>
49 dynamic_parameter_update_request_listener;
50 std::unique_ptr<ThreadedProtoUnixListener<TbotsProto::ValidationProtoSet>>
51 validation_proto_set_listener;
52 std::unique_ptr<ThreadedProtoUnixListener<TbotsProto::RobotLog>> robot_log_listener;
53 std::unique_ptr<ThreadedProtoUnixListener<TbotsProto::RobotCrash>>
54 robot_crash_listener;
55 std::unique_ptr<ThreadedProtoUnixListener<TbotsProto::ReplayBookmark>>
56 replay_bookmark_listener;
57
58 // Outputs
59 std::unique_ptr<ThreadedProtoUnixSender<TbotsProto::World>> world_output;
60 std::unique_ptr<ThreadedProtoUnixSender<TbotsProto::PrimitiveSet>> primitive_output;
61 std::unique_ptr<ThreadedProtoUnixSender<TbotsProto::ThunderbotsConfig>>
62 dynamic_parameter_update_respone_sender;
63
64 std::shared_ptr<ProtoLogger> proto_logger;
65
66 // World protobuf sequence number counter
67 uint64_t sequence_number = 0;
68
69 // The timestamp of the last world received
70 std::atomic<double> last_world_time_sec = 0;
71};
Definition backend.h:20
Definition subject.hpp:18
Definition unix_simulator_backend.h:20
double getLastWorldTimeSec()
Definition unix_simulator_backend.cpp:102
Definition world.h:23