CARLA
IMUSerializer.h
Go to the documentation of this file.
1 // Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #pragma once
8 
9 #include "carla/Buffer.h"
10 #include "carla/Memory.h"
11 #include "carla/sensor/RawData.h"
12 
13 namespace carla {
14 namespace sensor {
15 
16  class SensorData;
17 
18 namespace s11n {
19 
21  {
22  public:
23 
24  struct Data {
25 
27 
29 
30  float compass;
31 
32  MSGPACK_DEFINE_ARRAY(accelerometer, gyroscope, compass)
33  };
34 
35  template <typename SensorT>
36  static Buffer Serialize(
37  const SensorT &sensor,
40  const float compass);
41 
42  static Data DeserializeRawData(const RawData &message) {
43  return MsgPack::UnPack<Data>(message.begin(), message.size());
44  }
45 
47  };
48 
49  template <typename SensorT>
51  const SensorT &,
54  const float compass) {
55  return MsgPack::Pack(Data{accelerometer, gyroscope, compass});
56  }
57 
58 } // namespace s11n
59 } // namespace sensor
60 } // namespace carla
static Buffer Pack(const T &obj)
Definition: MsgPack.h:19
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
Definition: Memory.h:20
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
auto begin() noexcept
Begin iterator to the data generated by the sensor.
Definition: RawData.h:51
static Buffer Serialize(const SensorT &sensor, const geom::Vector3D &accelerometer, const geom::Vector3D &gyroscope, const float compass)
Definition: IMUSerializer.h:50
size_t size() const
Size in bytes of the data generated by the sensor.
Definition: RawData.h:82
static SharedPtr< SensorData > Deserialize(RawData &&data)
A piece of raw data.
Definition: carla/Buffer.h:41
static Data DeserializeRawData(const RawData &message)
Definition: IMUSerializer.h:42
Wrapper around the raw data generated by a sensor plus some useful meta-information.
Definition: RawData.h:20