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