CARLA
LibCarla/source/carla/rpc/VehicleControl.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 
11 #ifdef LIBCARLA_INCLUDED_FROM_UE4
13 #endif // LIBCARLA_INCLUDED_FROM_UE4
14 
15 namespace carla {
16 namespace rpc {
17 
19  public:
20 
21  VehicleControl() = default;
22 
24  float in_throttle,
25  float in_steer,
26  float in_brake,
27  bool in_hand_brake,
28  bool in_reverse,
29  bool in_manual_gear_shift,
30  int32_t in_gear)
31  : throttle(in_throttle),
32  steer(in_steer),
33  brake(in_brake),
34  hand_brake(in_hand_brake),
35  reverse(in_reverse),
36  manual_gear_shift(in_manual_gear_shift),
37  gear(in_gear) {}
38 
39  float throttle = 0.0f;
40  float steer = 0.0f;
41  float brake = 0.0f;
42  bool hand_brake = false;
43  bool reverse = false;
44  bool manual_gear_shift = false;
45  int32_t gear = 0;
46 
47 #ifdef LIBCARLA_INCLUDED_FROM_UE4
48 
49  VehicleControl(const FVehicleControl &Control)
50  : throttle(Control.Throttle),
51  steer(Control.Steer),
52  brake(Control.Brake),
53  hand_brake(Control.bHandBrake),
54  reverse(Control.bReverse),
55  manual_gear_shift(Control.bManualGearShift),
56  gear(Control.Gear) {}
57 
58  operator FVehicleControl() const {
59  FVehicleControl Control;
60  Control.Throttle = throttle;
61  Control.Steer = steer;
62  Control.Brake = brake;
63  Control.bHandBrake = hand_brake;
64  Control.bReverse = reverse;
66  Control.Gear = gear;
67  return Control;
68  }
69 
70 #endif // LIBCARLA_INCLUDED_FROM_UE4
71 
72  bool operator!=(const VehicleControl &rhs) const {
73  return
74  throttle != rhs.throttle ||
75  steer != rhs.steer ||
76  brake != rhs.brake ||
77  hand_brake != rhs.hand_brake ||
78  reverse != rhs.reverse ||
79  manual_gear_shift != rhs.manual_gear_shift ||
80  gear != rhs.gear;
81  }
82 
83  bool operator==(const VehicleControl &rhs) const {
84  return !(*this != rhs);
85  }
86 
88  throttle,
89  steer,
90  brake,
91  hand_brake,
92  reverse,
93  manual_gear_shift,
94  gear);
95  };
96 
97 } // namespace rpc
98 } // namespace carla
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:99
VehicleControl(float in_throttle, float in_steer, float in_brake, bool in_hand_brake, bool in_reverse, bool in_manual_gear_shift, int32_t in_gear)
bool operator==(const VehicleControl &rhs) const
MSGPACK_DEFINE_ARRAY(throttle, steer, brake, hand_brake, reverse, manual_gear_shift, gear)
bool operator!=(const VehicleControl &rhs) const