58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
|
|
// de Barcelona (UAB).
|
|
//
|
|
// This work is licensed under the terms of the MIT license.
|
|
// For a copy, see <https://opensource.org/licenses/MIT>.
|
|
|
|
#pragma once
|
|
|
|
#include "carla/Buffer.h"
|
|
#include "carla/Debug.h"
|
|
#include "carla/Memory.h"
|
|
#include "carla/rpc/Actor.h"
|
|
#include "carla/sensor/RawData.h"
|
|
|
|
namespace carla {
|
|
namespace sensor {
|
|
|
|
class SensorData;
|
|
|
|
namespace s11n {
|
|
|
|
/// Serializes the current state of the whole episode.
|
|
class ObstacleDetectionEventSerializer {
|
|
public:
|
|
|
|
struct Data {
|
|
|
|
rpc::Actor self_actor;
|
|
|
|
rpc::Actor other_actor;
|
|
|
|
float distance;
|
|
|
|
MSGPACK_DEFINE_ARRAY(self_actor, other_actor, distance)
|
|
};
|
|
|
|
constexpr static auto header_offset = 0u;
|
|
|
|
static Data DeserializeRawData(const RawData &message) {
|
|
return MsgPack::UnPack<Data>(message.begin(), message.size());
|
|
}
|
|
|
|
template <typename SensorT>
|
|
static Buffer Serialize(
|
|
const SensorT &,
|
|
rpc::Actor self_actor,
|
|
rpc::Actor other_actor,
|
|
float distance) {
|
|
return MsgPack::Pack(Data{self_actor, other_actor, distance});
|
|
}
|
|
|
|
static SharedPtr<SensorData> Deserialize(RawData &&data);
|
|
};
|
|
|
|
} // namespace s11n
|
|
} // namespace sensor
|
|
} // namespace carla
|