47 void Write(std::ostream &out)
const {
57 const uint8_t reserved[5] = {0u, 0u, 0u, 0u, 0u};
58 out.write(
reinterpret_cast<const char *
>(reserved),
sizeof(reserved));
61 bool Read(std::istream &in, uint32_t size) {
63 in.setstate(std::ios_base::failbit);
70 !reader.
ReadBytes(reserved,
sizeof(reserved))) {
99 void Write(std::ostream &out)
const {
100 std::ostringstream payload;
102 std::ostringstream value;
112 bool Read(std::istream &in, uint32_t size) {
119 if (!value.
Read(count) || (count > value.
Remaining() /
sizeof(uint64_t))) {
122 std::vector<uint64_t> ids(count);
123 for (uint64_t &
id : ids) {
124 if (!value.
Read(
id)) {
142 std::optional<std::array<double, 3>>
scale;
160 void Write(std::ostream &out)
const {
161 std::ostringstream payload;
164 std::ostringstream record;
167 std::ostringstream value;
168 for (
double axis : *actor.scale) {
173 if (actor.collisions) {
184 bool Read(std::istream &in, uint32_t size) {
191 for (uint32_t i = 0u; i < count; ++i) {
197 std::array<double, 3> scale;
198 for (double &axis : scale) {
199 if (!value.Read(axis)) {
209 if (!value.Read(flag)) {
212 (kind == kCollisions ? actor.collisions : actor.hidden) = (flag != 0u);
223 actors.push_back(std::move(actor));
231 return {
static_cast<uint16_t
>(desired & ~current),
static_cast<uint16_t
>(current & ~desired)};
236 inline std::pair<std::vector<uint64_t>, std::vector<uint64_t>>
DiffSortedIds(
237 const std::vector<uint64_t> ¤t,
238 const std::vector<uint64_t> &desired) {
239 std::pair<std::vector<uint64_t>, std::vector<uint64_t>> diff;
240 std::set_difference(desired.begin(), desired.end(), current.begin(), current.end(),
241 std::back_inserter(diff.first));
242 std::set_difference(current.begin(), current.end(), desired.begin(), desired.end(),
243 std::back_inserter(diff.second));
Reads the fields of one packet (or one record inside it) without ever consuming more than its declare...
uint32_t Remaining() const
bool ReadSizedRecord(F &&read)
Reads one [u32 record_size][record] entry of a variable-size list.
bool ReadVariableListCount(uint32_t &count)
Count of a list of variable-size records, checked against the bytes left.
bool ReadBytes(void *out, uint32_t bytes)
bool ReadFields(F &&read)
Reads TLV fields until the reader is exhausted.
void WritePod(std::ostream &out, const T &value)
void WriteField(std::ostream &out, uint8_t kind, const std::string &value)
std::pair< std::vector< uint64_t >, std::vector< uint64_t > > DiffSortedIds(const std::vector< uint64_t > ¤t, const std::vector< uint64_t > &desired)
Ids in desired and not in current (first), and the other way round (second).
void WriteFrameDataHeader(std::ostream &out, uint8_t id, uint32_t payload_size)
void WriteSizedBytes(std::ostream &out, const std::string &bytes)
One [u32 size][bytes] entry: a variable-size record or, after a kind byte, a TLV value.
std::pair< uint16_t, uint16_t > ComputeMapLayerDiff(uint16_t current, uint16_t desired)
The map layers to load and to unload to go from current to desired.
void WriteFrameDataPacket(std::ostream &out, uint8_t id, const std::string &payload)
Writes a packet whose payload was built beforehand.
This file contains definitions of common data structures used in traffic manager.
An actor's appearance on the primary that a mirror does not get from its spawn attributes or pose.
std::optional< bool > hidden
std::optional< std::array< double, 3 > > scale
std::optional< bool > collisions
Frame data packet 30, on change and on every full resync.
std::vector< ActorAppearance > actors
bool Read(std::istream &in, uint32_t size)
void Write(std::ostream &out) const
static constexpr uint8_t kPacketId
Frame data packet 28, on every frame: world-wide state a client can change on the primary that change...
float imu_gravity
The IMU's gravity, m/s^2.
bool publish_tf
ROS 2: whether TF frames are published.
uint16_t map_layers
rpc::MapLayer bits of the layers loaded.
bool Read(std::istream &in, uint32_t size)
void Write(std::ostream &out) const
static constexpr uint32_t kPayloadSizeV1
static constexpr uint8_t kPacketId
bool day_night_cycle
UCarlaLightSubsystem: whether street lights follow the sun, and the last day/night state it broadcast...
Frame data packet 29, on change and on every full resync: map objects whose state is not part of any ...
bool Read(std::istream &in, uint32_t size)
void Write(std::ostream &out) const
static constexpr uint8_t kPacketId
@ kDisabledEnvironmentObjects
The complete, sorted set of environment objects disabled.
std::optional< std::vector< uint64_t > > disabled_environment_objects