def vehicle_to_carla_measurements( vehicle: carla.Vehicle, # pylint: disable=no-member ) -> Mapping[str, Any]: """Wraps all the `get_` calls from the `CARLA` interface.""" control = vehicle.get_control() _transform = vehicle.get_transform() location = _transform.location rotation = _transform.rotation velocity = vehicle.get_velocity() acceleration = vehicle.get_acceleration() orientation = _transform.get_forward_vector() angular_velocity = vehicle.get_angular_velocity() speed_limit = vehicle.get_speed_limit() is_at_traffic_light = vehicle.is_at_traffic_light() traffic_light_state = vehicle.get_traffic_light_state().conjugate() return dict( control=control, location=location, rotation=rotation, velocity=velocity, acceleration=acceleration, orientation=orientation, angular_velocity=angular_velocity, speed_limit=speed_limit, is_at_traffic_light=is_at_traffic_light, traffic_light_state=traffic_light_state, )
def convert_vehicle_from_source_to_agent(self, source: carla.Vehicle) -> Vehicle: control: VehicleControl = self.convert_control_from_source_to_agent( source.get_control()) # this is cheating here, vehicle does not know its own location transform: Transform = self.convert_transform_from_source_to_agent( source.get_transform()) velocity: Vector3D = self.convert_vector3d_from_source_to_agent( source.get_velocity()) return Vehicle(velocity=velocity, transform=transform, control=control)