CARLA
LibCarla/source/carla/rpc/EpisodeSettings.h
Go to the documentation of this file.
1 // Copyright (c) 2017 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/MsgPack.h"
10 #include "carla/MsgPackAdaptors.h"
11 
12 #ifdef LIBCARLA_INCLUDED_FROM_UE4
14 #endif // LIBCARLA_INCLUDED_FROM_UE4
15 
16 #include <boost/optional.hpp>
17 
18 namespace carla {
19 namespace rpc {
20 
22  public:
23 
24  // =========================================================================
25  // -- Public data members --------------------------------------------------
26  // =========================================================================
27 
28  bool synchronous_mode = false;
29 
30  bool no_rendering_mode = false;
31 
32  boost::optional<double> fixed_delta_seconds;
33 
34  bool substepping = true;
35 
36  double max_substep_delta_time = 0.01;
37 
38  int max_substeps = 10;
39 
40  float max_culling_distance = 0.0f;
41 
43 
44  float tile_stream_distance = 3000.f; // 3km
45 
46  float actor_active_distance = 2000.f; // 2km
47 
48  MSGPACK_DEFINE_ARRAY(synchronous_mode, no_rendering_mode, fixed_delta_seconds, substepping,
49  max_substep_delta_time, max_substeps, max_culling_distance, deterministic_ragdolls,
50  tile_stream_distance, actor_active_distance);
51 
52  // =========================================================================
53  // -- Constructors ---------------------------------------------------------
54  // =========================================================================
55 
56  EpisodeSettings() = default;
57 
59  bool synchronous_mode,
60  bool no_rendering_mode,
61  double fixed_delta_seconds = 0.0,
62  bool substepping = true,
63  double max_substep_delta_time = 0.01,
64  int max_substeps = 10,
65  float max_culling_distance = 0.0f,
66  bool deterministic_ragdolls = true,
67  float tile_stream_distance = 3000.f,
68  float actor_active_distance = 2000.f)
69  : synchronous_mode(synchronous_mode),
70  no_rendering_mode(no_rendering_mode),
71  fixed_delta_seconds(
72  fixed_delta_seconds > 0.0 ? fixed_delta_seconds : boost::optional<double>{}),
73  substepping(substepping),
74  max_substep_delta_time(max_substep_delta_time),
75  max_substeps(max_substeps),
76  max_culling_distance(max_culling_distance),
77  deterministic_ragdolls(deterministic_ragdolls),
78  tile_stream_distance(tile_stream_distance),
79  actor_active_distance(actor_active_distance) {}
80 
81  // =========================================================================
82  // -- Comparison operators -------------------------------------------------
83  // =========================================================================
84 
85  bool operator==(const EpisodeSettings &rhs) const {
86  return
87  (synchronous_mode == rhs.synchronous_mode) &&
88  (no_rendering_mode == rhs.no_rendering_mode) &&
89  (substepping == rhs.substepping) &&
90  (fixed_delta_seconds == rhs.fixed_delta_seconds) &&
91  (max_substep_delta_time == rhs.max_substep_delta_time) &&
92  (max_substeps == rhs.max_substeps) &&
93  (max_culling_distance == rhs.max_culling_distance) &&
94  (deterministic_ragdolls == rhs.deterministic_ragdolls) &&
95  (tile_stream_distance == tile_stream_distance) &&
96  (actor_active_distance == actor_active_distance);
97  }
98 
99  bool operator!=(const EpisodeSettings &rhs) const {
100  return !(*this == rhs);
101  }
102 
103  // =========================================================================
104  // -- Conversions to UE4 types ---------------------------------------------
105  // =========================================================================
106 
107 #ifdef LIBCARLA_INCLUDED_FROM_UE4
108 
109  EpisodeSettings(const FEpisodeSettings &Settings)
110  : EpisodeSettings(
111  Settings.bSynchronousMode,
112  Settings.bNoRenderingMode,
113  Settings.FixedDeltaSeconds.Get(0.0),
114  Settings.bSubstepping,
115  Settings.MaxSubstepDeltaTime,
116  Settings.MaxSubsteps,
117  Settings.MaxCullingDistance,
118  Settings.bDeterministicRagdolls,
119  Settings.TileStreamingDistance,
120  Settings.ActorActiveDistance) {
121  constexpr float CMTOM = 1.f/100.f;
122  tile_stream_distance = CMTOM * Settings.TileStreamingDistance;
123  actor_active_distance = CMTOM * Settings.ActorActiveDistance;
124  }
125 
126  operator FEpisodeSettings() const {
127  constexpr float MTOCM = 100.f;
128  FEpisodeSettings Settings;
131  if (fixed_delta_seconds.has_value()) {
133  }
134  Settings.bSubstepping = substepping;
136  Settings.MaxSubsteps = max_substeps;
139  Settings.TileStreamingDistance = MTOCM * tile_stream_distance;
140  Settings.ActorActiveDistance = MTOCM * actor_active_distance;
141 
142  return Settings;
143  }
144 
145 #endif // LIBCARLA_INCLUDED_FROM_UE4
146  };
147 
148 } // namespace rpc
149 } // namespace carla
EpisodeSettings(bool synchronous_mode, bool no_rendering_mode, double fixed_delta_seconds=0.0, bool substepping=true, double max_substep_delta_time=0.01, int max_substeps=10, float max_culling_distance=0.0f, bool deterministic_ragdolls=true, float tile_stream_distance=3000.f, float actor_active_distance=2000.f)
MSGPACK_DEFINE_ARRAY(synchronous_mode, no_rendering_mode, fixed_delta_seconds, substepping, max_substep_delta_time, max_substeps, max_culling_distance, deterministic_ragdolls, tile_stream_distance, actor_active_distance)
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
bool operator!=(const EpisodeSettings &rhs) const
bool operator==(const EpisodeSettings &rhs) const