use super::{Actor, ActorBase, TrafficLight};
#[cfg(carla_version_0916)]
use crate::rpc::VehicleTelemetryData;
use crate::{
error::ffi::with_ffi_error,
geom::BoundingBox,
rpc::{
AckermannControllerSettings, TrafficLightState, VehicleAckermannControl, VehicleControl,
VehicleDoor, VehicleFailureState, VehicleLightState, VehiclePhysicsControl,
VehicleWheelLocation,
},
};
use carla_sys::{
carla::traffic_manager::constants::Networking::TM_DEFAULT_PORT,
carla_rust::client::{FfiActor, FfiVehicle},
};
use cxx::SharedPtr;
use derivative::Derivative;
use static_assertions::assert_impl_all;
#[cfg_attr(carla_version_0916, doc = "")]
#[cfg_attr(
carla_version_0916,
doc = " [`carla.Vehicle`]: https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle"
)]
#[cfg_attr(carla_version_0915, doc = "")]
#[cfg_attr(
carla_version_0915,
doc = " [`carla.Vehicle`]: https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle"
)]
#[cfg_attr(carla_version_0914, doc = "")]
#[cfg_attr(
carla_version_0914,
doc = " [`carla.Vehicle`]: https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle"
)]
#[derive(Clone, Derivative)]
#[derivative(Debug)]
#[repr(transparent)]
pub struct Vehicle {
#[derivative(Debug = "ignore")]
inner: SharedPtr<FfiVehicle>,
}
impl Vehicle {
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.set_autopilot](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.set_autopilot)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.set_autopilot](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.set_autopilot)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.set_autopilot](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.set_autopilot)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn set_autopilot(&self, enabled: bool) -> crate::Result<()> {
self.set_autopilot_opt(enabled, TM_DEFAULT_PORT)
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.set_autopilot](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.set_autopilot)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.set_autopilot](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.set_autopilot)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.set_autopilot](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.set_autopilot)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn set_autopilot_opt(&self, enabled: bool, tm_port: u16) -> crate::Result<()> {
with_ffi_error("set_autopilot", |e| {
self.inner.SetAutopilot(enabled, tm_port, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.show_debug_telemetry](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.show_debug_telemetry)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.show_debug_telemetry](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.show_debug_telemetry)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.show_debug_telemetry](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.show_debug_telemetry)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn show_debug_telemetry(&self, enabled: bool) -> crate::Result<()> {
with_ffi_error("show_debug_telemetry", |e| {
self.inner.ShowDebugTelemetry(enabled, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.apply_control](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.apply_control)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.apply_control](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.apply_control)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.apply_control](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.apply_control)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn apply_control(&self, control: &VehicleControl) -> crate::Result<()> {
with_ffi_error("apply_control", |e| {
self.inner.ApplyControl(control, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.get_control](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.get_control)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.get_control](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.get_control)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.get_control](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.get_control)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn control(&self) -> crate::Result<VehicleControl> {
with_ffi_error("get_control", |error| self.inner.GetControl(error))
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.apply_physics_control](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.apply_physics_control)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.apply_physics_control](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.apply_physics_control)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.apply_physics_control](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.apply_physics_control)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn apply_physics_control(&self, control: &VehiclePhysicsControl) -> crate::Result<()> {
let control = control.to_cxx();
with_ffi_error("apply_physics_control", |e| {
self.inner.ApplyPhysicsControl(&control, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.get_physics_control](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.get_physics_control)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.get_physics_control](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.get_physics_control)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.get_physics_control](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.get_physics_control)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn physics_control(&self) -> crate::Result<VehiclePhysicsControl> {
let ptr = with_ffi_error("physics_control", |e| self.inner.GetPhysicsControl(e))?;
Ok(VehiclePhysicsControl::from_cxx(&ptr))
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.apply_ackermann_control](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.apply_ackermann_control)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.apply_ackermann_control](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.apply_ackermann_control)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.apply_ackermann_control](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.apply_ackermann_control)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn apply_ackermann_control(&self, control: &VehicleAckermannControl) -> crate::Result<()> {
with_ffi_error("apply_ackermann_control", |e| {
self.inner.ApplyAckermannControl(control, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.apply_ackermann_controller_settings](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.apply_ackermann_controller_settings)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.apply_ackermann_controller_settings](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.apply_ackermann_controller_settings)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.apply_ackermann_controller_settings](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.apply_ackermann_controller_settings)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn apply_ackermann_controller_settings(
&self,
settings: &AckermannControllerSettings,
) -> crate::Result<()> {
with_ffi_error("apply_ackermann_controller_settings", |e| {
self.inner.ApplyAckermannControllerSettings(settings, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.get_ackermann_controller_settings](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.get_ackermann_controller_settings)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.get_ackermann_controller_settings](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.get_ackermann_controller_settings)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.get_ackermann_controller_settings](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.get_ackermann_controller_settings)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn ackermann_controller_settings(&self) -> crate::Result<AckermannControllerSettings> {
with_ffi_error("ackermann_controller_settings", |e| {
self.inner.GetAckermannControllerSettings(e)
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.open_door](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.open_door)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.open_door](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.open_door)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.open_door](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.open_door)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn open_door(&self, door: VehicleDoor) -> crate::Result<()> {
with_ffi_error("open_door", |e| {
self.inner.OpenDoor(door, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.close_door](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.close_door)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.close_door](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.close_door)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.close_door](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.close_door)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn close_door(&self, door: VehicleDoor) -> crate::Result<()> {
with_ffi_error("close_door", |e| {
self.inner.CloseDoor(door, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.set_light_state](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.set_light_state)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.set_light_state](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.set_light_state)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.set_light_state](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.set_light_state)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn set_light_state(&self, light_state: &VehicleLightState) -> crate::Result<()> {
let ffi_state = light_state.to_ffi();
with_ffi_error("set_light_state", |e| {
self.inner.SetLightState(&ffi_state, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.set_wheel_steer_direction](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.set_wheel_steer_direction)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.set_wheel_steer_direction](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.set_wheel_steer_direction)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.set_wheel_steer_direction](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.set_wheel_steer_direction)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn set_wheel_steer_direction(
&self,
wheel_location: VehicleWheelLocation,
degrees: f32,
) -> crate::Result<()> {
with_ffi_error("set_wheel_steer_direction", |e| {
self.inner
.SetWheelSteerDirection(wheel_location, degrees, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.get_wheel_steer_angle](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.get_wheel_steer_angle)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.get_wheel_steer_angle](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.get_wheel_steer_angle)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.get_wheel_steer_angle](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.get_wheel_steer_angle)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn wheel_steer_angle(&self, wheel_location: VehicleWheelLocation) -> crate::Result<f32> {
with_ffi_error("wheel_steer_angle", |e| {
self.inner.GetWheelSteerAngle(wheel_location, e)
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.get_light_state](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.get_light_state)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.get_light_state](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.get_light_state)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.get_light_state](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.get_light_state)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn light_state(&self) -> crate::Result<VehicleLightState> {
let ffi_state = with_ffi_error("get_light_state", |e| self.inner.GetLightState(e))?;
Ok(VehicleLightState::from_ffi(&ffi_state))
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.get_traffic_light_state](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.get_traffic_light_state)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.get_traffic_light_state](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.get_traffic_light_state)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.get_traffic_light_state](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.get_traffic_light_state)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn traffic_light_state(&self) -> crate::Result<TrafficLightState> {
with_ffi_error("get_traffic_light_state", |e| {
self.inner.GetTrafficLightState(e)
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.is_at_traffic_light](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.is_at_traffic_light)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.is_at_traffic_light](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.is_at_traffic_light)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.is_at_traffic_light](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.is_at_traffic_light)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn is_at_traffic_light(&self) -> crate::Result<bool> {
with_ffi_error("is_at_traffic_light", |e| self.inner.IsAtTrafficLight(e))
}
pub fn traffic_light(&self) -> crate::Result<Option<TrafficLight>> {
let ptr = with_ffi_error("traffic_light", |e| self.inner.GetTrafficLight(e))?;
Ok(TrafficLight::from_cxx(ptr))
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.get_failure_state](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.get_failure_state)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.get_failure_state](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.get_failure_state)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.get_failure_state](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.get_failure_state)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn failure_state(&self) -> crate::Result<VehicleFailureState> {
with_ffi_error("get_failure_state", |e| self.inner.GetFailureState(e))
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.bounding_box](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.bounding_box)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.bounding_box](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.bounding_box)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.bounding_box](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.bounding_box)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn bounding_box(&self) -> crate::Result<BoundingBox> {
let bbox_ptr = with_ffi_error("get_bounding_box", |e| self.inner.GetBoundingBox(e))?;
Ok(BoundingBox::from_native(&bbox_ptr))
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.get_telemetry_data](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.get_telemetry_data)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.get_telemetry_data](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.get_telemetry_data)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.get_telemetry_data](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.get_telemetry_data)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
#[cfg(carla_version_0916)]
pub fn telemetry_data(&self) -> crate::Result<VehicleTelemetryData> {
let ptr = with_ffi_error("telemetry_data", |e| self.inner.GetTelemetryData(e))?;
Ok((&*ptr).into())
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.set_wheel_pitch_angle](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.set_wheel_pitch_angle)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.set_wheel_pitch_angle](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.set_wheel_pitch_angle)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.set_wheel_pitch_angle](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.set_wheel_pitch_angle)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
#[cfg(carla_version_0916)]
pub fn set_wheel_pitch_angle(
&self,
wheel_location: VehicleWheelLocation,
degrees: f32,
) -> crate::Result<()> {
with_ffi_error("set_wheel_pitch_angle", |e| {
self.inner.SetWheelPitchAngle(wheel_location, degrees, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.get_wheel_pitch_angle](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.get_wheel_pitch_angle)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.get_wheel_pitch_angle](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.get_wheel_pitch_angle)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.get_wheel_pitch_angle](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.get_wheel_pitch_angle)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
#[cfg(carla_version_0916)]
pub fn wheel_pitch_angle(&self, wheel_location: VehicleWheelLocation) -> crate::Result<f32> {
with_ffi_error("wheel_pitch_angle", |e| {
self.inner.GetWheelPitchAngle(wheel_location, e)
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.restore_physx_physics](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.restore_physx_physics)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.restore_physx_physics](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.restore_physx_physics)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.restore_physx_physics](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.restore_physx_physics)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
#[cfg(carla_version_0916)]
pub fn restore_phys_x_physics(&self) -> crate::Result<()> {
with_ffi_error("restore_phys_x_physics", |e| {
self.inner.RestorePhysXPhysics(e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.enable_carsim](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.enable_carsim)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.enable_carsim](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.enable_carsim)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.enable_carsim](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.enable_carsim)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn enable_car_sim(&self, simfile_path: &str) -> crate::Result<()> {
with_ffi_error("enable_car_sim", |e| {
self.inner.EnableCarSim(simfile_path, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.use_carsim_road](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.use_carsim_road)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.use_carsim_road](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.use_carsim_road)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.use_carsim_road](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.use_carsim_road)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn use_car_sim_road(&self, enabled: bool) -> crate::Result<()> {
with_ffi_error("use_car_sim_road", |e| {
self.inner.UseCarSimRoad(enabled, e);
})
}
#[cfg_attr(
carla_version_0916,
doc = " See [carla.Vehicle.enable_chrono_physics](https://carla.readthedocs.io/en/0.9.16/python_api/#carla.Vehicle.enable_chrono_physics)"
)]
#[cfg_attr(
carla_version_0915,
doc = " See [carla.Vehicle.enable_chrono_physics](https://carla.readthedocs.io/en/0.9.15/python_api/#carla.Vehicle.enable_chrono_physics)"
)]
#[cfg_attr(
carla_version_0914,
doc = " See [carla.Vehicle.enable_chrono_physics](https://carla.readthedocs.io/en/0.9.14/python_api/#carla.Vehicle.enable_chrono_physics)"
)]
#[cfg_attr(
any(carla_version_0916, carla_version_0915, carla_version_0914),
doc = " in the Python API."
)]
pub fn enable_chrono_physics(
&self,
max_substeps: u64,
max_substep_delta_time: f32,
vehicle_json: &str,
powertrain_json: &str,
tire_json: &str,
base_json_path: &str,
) -> crate::Result<()> {
with_ffi_error("enable_chrono_physics", |e| {
self.inner.EnableChronoPhysics(
max_substeps,
max_substep_delta_time,
vehicle_json,
powertrain_json,
tire_json,
base_json_path,
e,
);
})
}
pub fn into_actor(self) -> Actor {
let ptr = self.inner.to_actor();
unsafe { Actor::from_cxx(ptr).unwrap_unchecked() }
}
pub(crate) fn from_cxx(ptr: SharedPtr<FfiVehicle>) -> Option<Self> {
if ptr.is_null() {
None
} else {
Some(Self { inner: ptr })
}
}
}
impl ActorBase for Vehicle {
fn cxx_actor(&self) -> SharedPtr<FfiActor> {
self.inner.to_actor()
}
}
impl TryFrom<Actor> for Vehicle {
type Error = Actor;
fn try_from(value: Actor) -> Result<Self, Self::Error> {
let ptr = value.inner.to_vehicle();
Self::from_cxx(ptr).ok_or(value)
}
}
assert_impl_all!(Vehicle: Send, Sync);