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  MSGPACK_DEFINE_ARRAY(synchronous_mode, no_rendering_mode, fixed_delta_seconds, substepping,
45  max_substep_delta_time, max_substeps, max_culling_distance, deterministic_ragdolls);
46 
47  // =========================================================================
48  // -- Constructors ---------------------------------------------------------
49  // =========================================================================
50 
51  EpisodeSettings() = default;
52 
54  bool synchronous_mode,
55  bool no_rendering_mode,
56  double fixed_delta_seconds = 0.0,
57  bool substepping = true,
58  double max_substep_delta_time = 0.01,
59  int max_substeps = 10,
60  float max_culling_distance = 0.0f,
61  bool deterministic_ragdolls = true)
62  : synchronous_mode(synchronous_mode),
63  no_rendering_mode(no_rendering_mode),
64  fixed_delta_seconds(
65  fixed_delta_seconds > 0.0 ? fixed_delta_seconds : boost::optional<double>{}),
66  substepping(substepping),
67  max_substep_delta_time(max_substep_delta_time),
68  max_substeps(max_substeps),
69  max_culling_distance(max_culling_distance),
70  deterministic_ragdolls(deterministic_ragdolls) {}
71 
72  // =========================================================================
73  // -- Comparison operators -------------------------------------------------
74  // =========================================================================
75 
76  bool operator==(const EpisodeSettings &rhs) const {
77  return
78  (synchronous_mode == rhs.synchronous_mode) &&
79  (no_rendering_mode == rhs.no_rendering_mode) &&
80  (substepping == rhs.substepping) &&
81  (fixed_delta_seconds == rhs.fixed_delta_seconds) &&
82  (max_substep_delta_time == rhs.max_substep_delta_time) &&
83  (max_substeps == rhs.max_substeps) &&
84  (max_culling_distance == rhs.max_culling_distance) &&
85  (deterministic_ragdolls == rhs.deterministic_ragdolls);
86  }
87 
88  bool operator!=(const EpisodeSettings &rhs) const {
89  return !(*this == rhs);
90  }
91 
92  // =========================================================================
93  // -- Conversions to UE4 types ---------------------------------------------
94  // =========================================================================
95 
96 #ifdef LIBCARLA_INCLUDED_FROM_UE4
97 
98  EpisodeSettings(const FEpisodeSettings &Settings)
100  Settings.bSynchronousMode,
101  Settings.bNoRenderingMode,
102  Settings.FixedDeltaSeconds.Get(0.0),
103  Settings.bSubstepping,
104  Settings.MaxSubstepDeltaTime,
105  Settings.MaxSubsteps,
106  Settings.MaxCullingDistance,
107  Settings.bDeterministicRagdolls) {}
108 
109  operator FEpisodeSettings() const {
110  FEpisodeSettings Settings;
113  if (fixed_delta_seconds.has_value()) {
115  }
116  Settings.bSubstepping = substepping;
118  Settings.MaxSubsteps = max_substeps;
121 
122  return Settings;
123  }
124 
125 #endif // LIBCARLA_INCLUDED_FROM_UE4
126  };
127 
128 } // namespace rpc
129 } // namespace carla
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:99
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)
MSGPACK_DEFINE_ARRAY(synchronous_mode, no_rendering_mode, fixed_delta_seconds, substepping, max_substep_delta_time, max_substeps, max_culling_distance, deterministic_ragdolls)
bool operator!=(const EpisodeSettings &rhs) const
bool operator==(const EpisodeSettings &rhs) const