CARLA
Vehicle.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/client/Actor.h"
14 #include "carla/rpc/VehicleDoor.h"
19 
21 
22 namespace carla {
23 
24 namespace traffic_manager {
25  class TrafficManager;
26 }
27 
28 namespace client {
29 
30  class TrafficLight;
31 
32  class Vehicle : public Actor {
33  public:
34 
42 
43 
44  explicit Vehicle(ActorInitializer init);
45 
46  /// Switch on/off this vehicle's autopilot.
47  void SetAutopilot(bool enabled = true, uint16_t tm_port = TM_DEFAULT_PORT);
48 
49  /// Switch on/off this vehicle's autopilot.
50  void ShowDebugTelemetry(bool enabled = true);
51 
52  /// Apply @a control to this vehicle.
53  void ApplyControl(const Control &control);
54 
55  /// Apply @a control to this vehicle.
56  void ApplyAckermannControl(const AckermannControl &control);
57 
58  /// Return the last Ackermann controller settings applied to this vehicle.
59  ///
60  /// @warning This function does call the simulator.
61  rpc::AckermannControllerSettings GetAckermannControllerSettings() const;
62 
63  /// Apply Ackermann control settings to this vehicle
64  void ApplyAckermannControllerSettings(const rpc::AckermannControllerSettings &settings);
65 
66  /// Apply physics control to this vehicle.
67  void ApplyPhysicsControl(const PhysicsControl &physics_control);
68 
69  /// Open a door in this vehicle
70  void OpenDoor(const VehicleDoor door_idx);
71 
72  /// Close a door in this vehicle
73  void CloseDoor(const VehicleDoor door_idx);
74 
75  /// Sets a @a LightState to this vehicle.
76  void SetLightState(const LightState &light_state);
77 
78  /// Sets a @a Rotation to a wheel of the vehicle (affects the bone of the car skeleton, not the physics)
79  void SetWheelSteerDirection(WheelLocation wheel_location, float angle_in_deg);
80 
81  /// Return a @a Rotation from a wheel of the vehicle
82  ///
83  /// @note The function returns the rotation of the vehicle based on the it's physics
84  float GetWheelSteerAngle(WheelLocation wheel_location);
85 
86  /// Return the control last applied to this vehicle.
87  ///
88  /// @note This function does not call the simulator, it returns the data
89  /// received in the last tick.
90  Control GetControl() const;
91 
92  /// Return the physics control last applied to this vehicle.
93  ///
94  /// @warning This function does call the simulator.
95  PhysicsControl GetPhysicsControl() const;
96 
97  /// Return the current open lights (LightState) of this vehicle.
98  ///
99  /// @note This function does not call the simulator, it returns the data
100  /// received in the last tick.
101  LightState GetLightState() const;
102 
103  /// Return the speed limit currently affecting this vehicle.
104  ///
105  /// @note This function does not call the simulator, it returns the data
106  /// received in the last tick.
107  float GetSpeedLimit() const;
108 
109  /// Return the state of the traffic light currently affecting this vehicle.
110  ///
111  /// @return Green If no traffic light is affecting the vehicle.
112  ///
113  /// @note This function does not call the simulator, it returns the data
114  /// received in the last tick.
115  rpc::TrafficLightState GetTrafficLightState() const;
116 
117  /// Return whether a traffic light is affecting this vehicle.
118  ///
119  /// @note This function does not call the simulator, it returns the data
120  /// received in the last tick.
121  bool IsAtTrafficLight();
122 
123  /// Retrieve the traffic light actor currently affecting this vehicle.
124  SharedPtr<TrafficLight> GetTrafficLight() const;
125 
126  /// Enables CarSim simulation if it is availiable
127  void EnableCarSim(std::string simfile_path);
128 
129  /// Enables the use of CarSim internal road definition instead of unreal's
130  void UseCarSimRoad(bool enabled);
131 
132  void EnableChronoPhysics(
133  uint64_t MaxSubsteps,
134  float MaxSubstepDeltaTime,
135  std::string VehicleJSON = "",
136  std::string PowertrainJSON = "",
137  std::string TireJSON = "",
138  std::string BaseJSONPath = "");
139 
140  /// Returns the failure state of the vehicle
141  rpc::VehicleFailureState GetFailureState() const;
142 
143  private:
144 
145  const bool _is_control_sticky;
146 
148  };
149 
150 } // namespace client
151 } // namespace carla
static const unsigned short TM_DEFAULT_PORT
Definition: Constants.h:22
const bool _is_control_sticky
Definition: Vehicle.h:145
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
Used to initialize Actor classes.
This class integrates all the various stages of the traffic manager appropriately using messengers...
Represents an actor in the simulation.
Definition: client/Actor.h:18