bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
state_message.h
Go to the documentation of this file.
1#ifndef BITSIM_DISTRIBUTED_STATE_MESSAGE_H
2#define BITSIM_DISTRIBUTED_STATE_MESSAGE_H
3
5
6#include <array>
7#include <string>
8#include <vector>
9
10namespace bitsim
11{
12namespace distributed
13{
14
24{
25 std::string name;
26 std::array<real_t, 3> position{0.0, 0.0, 0.0};
27 std::array<real_t, 4> orientation{1.0, 0.0, 0.0, 0.0};
28 std::array<real_t, 3> linear_velocity{0.0, 0.0, 0.0};
29 std::array<real_t, 3> angular_velocity{0.0, 0.0, 0.0};
30 std::array<real_t, 3> size{0.0, 0.0, 0.0};
31
36 static BodyState planar(const std::string &name, real_t x, real_t y, real_t yaw,
37 real_t vx = 0.0, real_t vy = 0.0, real_t wz = 0.0,
38 const std::array<real_t, 3> &size = {0.0, 0.0, 0.0});
39
43 real_t yaw() const noexcept;
44
48 BodyState extrapolated(real_t dt) const;
49};
50
64{
65 enum class Kind : uint_t
66 {
67 STATE = 0,
68 LEAVE = 1
69 };
70
72 std::string participant;
76 std::vector<BodyState> bodies;
77 std::vector<real_t> values;
78
82 std::string encode() const;
83
88 static StateMessage decode(const std::string &bytes);
89};
90
95
96} // namespace distributed
97} // namespace bitsim
98
99#endif // BITSIM_DISTRIBUTED_STATE_MESSAGE_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
Definition chrono_ghosts.cpp:12
real_t wall_time_now()
The wall-clock time now, in seconds since the epoch of std::chrono::system_clock.
Definition state_message.cpp:118
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20
The state of one body of a participant: where it is, how it moves, and how big it is.
Definition state_message.h:24
real_t yaw() const noexcept
The rotation about z of the orientation.
Definition state_message.cpp:27
BodyState extrapolated(real_t dt) const
Where the body would be dt seconds later, moving as it moves now.
Definition state_message.cpp:33
std::array< real_t, 3 > position
Definition state_message.h:26
std::string name
Definition state_message.h:25
std::array< real_t, 3 > linear_velocity
Definition state_message.h:28
static BodyState planar(const std::string &name, real_t x, real_t y, real_t yaw, real_t vx=0.0, real_t vy=0.0, real_t wz=0.0, const std::array< real_t, 3 > &size={0.0, 0.0, 0.0})
A body that moves in the plane: at (x, y), turned yaw about z, moving with (vx, vy) and turning at wz...
Definition state_message.cpp:14
std::array< real_t, 3 > size
Definition state_message.h:30
std::array< real_t, 3 > angular_velocity
Definition state_message.h:29
std::array< real_t, 4 > orientation
Definition state_message.h:27
What a participant of a distributed simulation sends: the state of its bodies at one step,...
Definition state_message.h:64
static StateMessage decode(const std::string &bytes)
Read a message that encode() wrote.
Definition state_message.cpp:84
real_t time
Definition state_message.h:74
Kind kind
Definition state_message.h:71
uint_t step
Definition state_message.h:73
std::vector< real_t > values
Definition state_message.h:77
std::string participant
Definition state_message.h:72
std::string encode() const
The message in MessagePack, for a transport.
Definition state_message.cpp:58
real_t stamp
Definition state_message.h:75
Kind
Definition state_message.h:66
@ STATE
the state of the bodies at step
Definition state_message.h:67
std::vector< BodyState > bodies
Definition state_message.h:76