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