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"
15 
17 
18 namespace carla {
19 
20 namespace traffic_manager {
21  class TrafficManager;
22 }
23 
24 namespace client {
25 
26  class TrafficLight;
27 
28  class Vehicle : public Actor {
29  public:
30 
35 
36  explicit Vehicle(ActorInitializer init);
37 
38  /// Switch on/off this vehicle's autopilot.
39  void SetAutopilot(bool enabled = true, uint16_t tm_port = TM_DEFAULT_PORT);
40 
41  /// Apply @a control to this vehicle.
42  void ApplyControl(const Control &control);
43 
44  /// Apply physics control to this vehicle.
45  void ApplyPhysicsControl(const PhysicsControl &physics_control);
46 
47  /// Sets a @a LightState to this vehicle.
48  void SetLightState(const LightState &light_state);
49 
50  /// Return the control last applied to this vehicle.
51  ///
52  /// @note This function does not call the simulator, it returns the data
53  /// received in the last tick.
54  Control GetControl() const;
55 
56  /// Return the physics control last applied to this vehicle.
57  ///
58  /// @warning This function does call the simulator.
59  PhysicsControl GetPhysicsControl() const;
60 
61  /// Return the current open lights (LightState) of this vehicle.
62  ///
63  /// @note This function does not call the simulator, it returns the data
64  /// received in the last tick.
65  LightState GetLightState() const;
66 
67  /// Return the speed limit currently affecting this vehicle.
68  ///
69  /// @note This function does not call the simulator, it returns the data
70  /// received in the last tick.
71  float GetSpeedLimit() const;
72 
73  /// Return the state of the traffic light currently affecting this vehicle.
74  ///
75  /// @return Green If no traffic light is affecting the vehicle.
76  ///
77  /// @note This function does not call the simulator, it returns the data
78  /// received in the last tick.
79  rpc::TrafficLightState GetTrafficLightState() const;
80 
81  /// Return whether a traffic light is affecting this vehicle.
82  ///
83  /// @note This function does not call the simulator, it returns the data
84  /// received in the last tick.
85  bool IsAtTrafficLight();
86 
87  /// Retrieve the traffic light actor currently affecting this vehicle.
88  SharedPtr<TrafficLight> GetTrafficLight() const;
89 
90  /// Enables CarSim simulation if it is availiable
91  void EnableCarSim(std::string simfile_path);
92 
93  /// Enables the use of CarSim internal road definition instead of unreal's
94  void UseCarSimRoad(bool enabled);
95 
96  private:
97 
98  const bool _is_control_sticky;
99 
101  };
102 
103 } // namespace client
104 } // namespace carla
static const unsigned short TM_DEFAULT_PORT
Definition: Constants.h:20
const bool _is_control_sticky
Definition: Vehicle.h:98
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:99
Used to initialize Actor classes.
Definition: ActorState.h:93
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