Add box extent to player measurements

This commit is contained in:
nsubiron 2018-03-06 16:16:25 +01:00
parent b1e517fd95
commit ffe8b932f9
7 changed files with 36 additions and 11 deletions

View File

@ -19,7 +19,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
name='carla_server.proto', name='carla_server.proto',
package='carla_server', package='carla_server',
syntax='proto3', syntax='proto3',
serialized_pb=_b('\n\x12\x63\x61rla_server.proto\x12\x0c\x63\x61rla_server\"+\n\x08Vector3D\x12\t\n\x01x\x18\x01 \x01(\x02\x12\t\n\x01y\x18\x02 \x01(\x02\x12\t\n\x01z\x18\x03 \x01(\x02\"6\n\nRotation3D\x12\r\n\x05pitch\x18\x01 \x01(\x02\x12\x0b\n\x03yaw\x18\x02 \x01(\x02\x12\x0c\n\x04roll\x18\x03 \x01(\x02\"\x92\x01\n\tTransform\x12(\n\x08location\x18\x01 \x01(\x0b\x32\x16.carla_server.Vector3D\x12/\n\x0borientation\x18\x02 \x01(\x0b\x32\x16.carla_server.Vector3DB\x02\x18\x01\x12*\n\x08rotation\x18\x03 \x01(\x0b\x32\x18.carla_server.Rotation3D\"\x81\x01\n\x06Sensor\x12\n\n\x02id\x18\x01 \x01(\x07\x12\'\n\x04type\x18\x02 \x01(\x0e\x32\x19.carla_server.Sensor.Type\x12\x0c\n\x04name\x18\x03 \x01(\t\"4\n\x04Type\x12\x0b\n\x07UNKNOWN\x10\x00\x12\n\n\x06\x43\x41MERA\x10\x01\x12\x13\n\x0fLIDAR_RAY_TRACE\x10\x02\"x\n\x07Vehicle\x12*\n\ttransform\x18\x01 \x01(\x0b\x32\x17.carla_server.Transform\x12*\n\nbox_extent\x18\x02 \x01(\x0b\x32\x16.carla_server.Vector3D\x12\x15\n\rforward_speed\x18\x03 \x01(\x02\"{\n\nPedestrian\x12*\n\ttransform\x18\x01 \x01(\x0b\x32\x17.carla_server.Transform\x12*\n\nbox_extent\x18\x02 \x01(\x0b\x32\x16.carla_server.Vector3D\x12\x15\n\rforward_speed\x18\x03 \x01(\x02\"\x94\x01\n\x0cTrafficLight\x12*\n\ttransform\x18\x01 \x01(\x0b\x32\x17.carla_server.Transform\x12/\n\x05state\x18\x02 \x01(\x0e\x32 .carla_server.TrafficLight.State\"\'\n\x05State\x12\t\n\x05GREEN\x10\x00\x12\n\n\x06YELLOW\x10\x01\x12\x07\n\x03RED\x10\x02\"Q\n\x0eSpeedLimitSign\x12*\n\ttransform\x18\x01 \x01(\x0b\x32\x17.carla_server.Transform\x12\x13\n\x0bspeed_limit\x18\x02 \x01(\x02\"\xe5\x01\n\x05\x41gent\x12\n\n\x02id\x18\x01 \x01(\x07\x12(\n\x07vehicle\x18\x02 \x01(\x0b\x32\x15.carla_server.VehicleH\x00\x12.\n\npedestrian\x18\x03 \x01(\x0b\x32\x18.carla_server.PedestrianH\x00\x12\x33\n\rtraffic_light\x18\x04 \x01(\x0b\x32\x1a.carla_server.TrafficLightH\x00\x12\x38\n\x10speed_limit_sign\x18\x05 \x01(\x0b\x32\x1c.carla_server.SpeedLimitSignH\x00\x42\x07\n\x05\x61gent\"%\n\x11RequestNewEpisode\x12\x10\n\x08ini_file\x18\x01 \x01(\t\"n\n\x10SceneDescription\x12\x33\n\x12player_start_spots\x18\x01 \x03(\x0b\x32\x17.carla_server.Transform\x12%\n\x07sensors\x18\x02 \x03(\x0b\x32\x14.carla_server.Sensor\"/\n\x0c\x45pisodeStart\x12\x1f\n\x17player_start_spot_index\x18\x01 \x01(\r\"\x1d\n\x0c\x45pisodeReady\x12\r\n\x05ready\x18\x01 \x01(\x08\"^\n\x07\x43ontrol\x12\r\n\x05steer\x18\x01 \x01(\x02\x12\x10\n\x08throttle\x18\x02 \x01(\x02\x12\r\n\x05\x62rake\x18\x03 \x01(\x02\x12\x12\n\nhand_brake\x18\x04 \x01(\x08\x12\x0f\n\x07reverse\x18\x05 \x01(\x08\"\x8a\x04\n\x0cMeasurements\x12\x1a\n\x12platform_timestamp\x18\x01 \x01(\r\x12\x16\n\x0egame_timestamp\x18\x02 \x01(\r\x12J\n\x13player_measurements\x18\x03 \x01(\x0b\x32-.carla_server.Measurements.PlayerMeasurements\x12.\n\x11non_player_agents\x18\x04 \x03(\x0b\x32\x13.carla_server.Agent\x1a\xc9\x02\n\x12PlayerMeasurements\x12*\n\ttransform\x18\x01 \x01(\x0b\x32\x17.carla_server.Transform\x12,\n\x0c\x61\x63\x63\x65leration\x18\x03 \x01(\x0b\x32\x16.carla_server.Vector3D\x12\x15\n\rforward_speed\x18\x04 \x01(\x02\x12\x1a\n\x12\x63ollision_vehicles\x18\x05 \x01(\x02\x12\x1d\n\x15\x63ollision_pedestrians\x18\x06 \x01(\x02\x12\x17\n\x0f\x63ollision_other\x18\x07 \x01(\x02\x12\x1e\n\x16intersection_otherlane\x18\x08 \x01(\x02\x12\x1c\n\x14intersection_offroad\x18\t \x01(\x02\x12\x30\n\x11\x61utopilot_control\x18\n \x01(\x0b\x32\x15.carla_server.ControlB\x03\xf8\x01\x01\x62\x06proto3') serialized_pb=_b('\n\x12\x63\x61rla_server.proto\x12\x0c\x63\x61rla_server\"+\n\x08Vector3D\x12\t\n\x01x\x18\x01 \x01(\x02\x12\t\n\x01y\x18\x02 \x01(\x02\x12\t\n\x01z\x18\x03 \x01(\x02\"6\n\nRotation3D\x12\r\n\x05pitch\x18\x01 \x01(\x02\x12\x0b\n\x03yaw\x18\x02 \x01(\x02\x12\x0c\n\x04roll\x18\x03 \x01(\x02\"\x92\x01\n\tTransform\x12(\n\x08location\x18\x01 \x01(\x0b\x32\x16.carla_server.Vector3D\x12/\n\x0borientation\x18\x02 \x01(\x0b\x32\x16.carla_server.Vector3DB\x02\x18\x01\x12*\n\x08rotation\x18\x03 \x01(\x0b\x32\x18.carla_server.Rotation3D\"\x81\x01\n\x06Sensor\x12\n\n\x02id\x18\x01 \x01(\x07\x12\'\n\x04type\x18\x02 \x01(\x0e\x32\x19.carla_server.Sensor.Type\x12\x0c\n\x04name\x18\x03 \x01(\t\"4\n\x04Type\x12\x0b\n\x07UNKNOWN\x10\x00\x12\n\n\x06\x43\x41MERA\x10\x01\x12\x13\n\x0fLIDAR_RAY_TRACE\x10\x02\"x\n\x07Vehicle\x12*\n\ttransform\x18\x01 \x01(\x0b\x32\x17.carla_server.Transform\x12*\n\nbox_extent\x18\x02 \x01(\x0b\x32\x16.carla_server.Vector3D\x12\x15\n\rforward_speed\x18\x03 \x01(\x02\"{\n\nPedestrian\x12*\n\ttransform\x18\x01 \x01(\x0b\x32\x17.carla_server.Transform\x12*\n\nbox_extent\x18\x02 \x01(\x0b\x32\x16.carla_server.Vector3D\x12\x15\n\rforward_speed\x18\x03 \x01(\x02\"\x94\x01\n\x0cTrafficLight\x12*\n\ttransform\x18\x01 \x01(\x0b\x32\x17.carla_server.Transform\x12/\n\x05state\x18\x02 \x01(\x0e\x32 .carla_server.TrafficLight.State\"\'\n\x05State\x12\t\n\x05GREEN\x10\x00\x12\n\n\x06YELLOW\x10\x01\x12\x07\n\x03RED\x10\x02\"Q\n\x0eSpeedLimitSign\x12*\n\ttransform\x18\x01 \x01(\x0b\x32\x17.carla_server.Transform\x12\x13\n\x0bspeed_limit\x18\x02 \x01(\x02\"\xe5\x01\n\x05\x41gent\x12\n\n\x02id\x18\x01 \x01(\x07\x12(\n\x07vehicle\x18\x02 \x01(\x0b\x32\x15.carla_server.VehicleH\x00\x12.\n\npedestrian\x18\x03 \x01(\x0b\x32\x18.carla_server.PedestrianH\x00\x12\x33\n\rtraffic_light\x18\x04 \x01(\x0b\x32\x1a.carla_server.TrafficLightH\x00\x12\x38\n\x10speed_limit_sign\x18\x05 \x01(\x0b\x32\x1c.carla_server.SpeedLimitSignH\x00\x42\x07\n\x05\x61gent\"%\n\x11RequestNewEpisode\x12\x10\n\x08ini_file\x18\x01 \x01(\t\"n\n\x10SceneDescription\x12\x33\n\x12player_start_spots\x18\x01 \x03(\x0b\x32\x17.carla_server.Transform\x12%\n\x07sensors\x18\x02 \x03(\x0b\x32\x14.carla_server.Sensor\"/\n\x0c\x45pisodeStart\x12\x1f\n\x17player_start_spot_index\x18\x01 \x01(\r\"\x1d\n\x0c\x45pisodeReady\x12\r\n\x05ready\x18\x01 \x01(\x08\"^\n\x07\x43ontrol\x12\r\n\x05steer\x18\x01 \x01(\x02\x12\x10\n\x08throttle\x18\x02 \x01(\x02\x12\r\n\x05\x62rake\x18\x03 \x01(\x02\x12\x12\n\nhand_brake\x18\x04 \x01(\x08\x12\x0f\n\x07reverse\x18\x05 \x01(\x08\"\xb6\x04\n\x0cMeasurements\x12\x1a\n\x12platform_timestamp\x18\x01 \x01(\r\x12\x16\n\x0egame_timestamp\x18\x02 \x01(\r\x12J\n\x13player_measurements\x18\x03 \x01(\x0b\x32-.carla_server.Measurements.PlayerMeasurements\x12.\n\x11non_player_agents\x18\x04 \x03(\x0b\x32\x13.carla_server.Agent\x1a\xf5\x02\n\x12PlayerMeasurements\x12*\n\ttransform\x18\x01 \x01(\x0b\x32\x17.carla_server.Transform\x12*\n\nbox_extent\x18\x0b \x01(\x0b\x32\x16.carla_server.Vector3D\x12,\n\x0c\x61\x63\x63\x65leration\x18\x03 \x01(\x0b\x32\x16.carla_server.Vector3D\x12\x15\n\rforward_speed\x18\x04 \x01(\x02\x12\x1a\n\x12\x63ollision_vehicles\x18\x05 \x01(\x02\x12\x1d\n\x15\x63ollision_pedestrians\x18\x06 \x01(\x02\x12\x17\n\x0f\x63ollision_other\x18\x07 \x01(\x02\x12\x1e\n\x16intersection_otherlane\x18\x08 \x01(\x02\x12\x1c\n\x14intersection_offroad\x18\t \x01(\x02\x12\x30\n\x11\x61utopilot_control\x18\n \x01(\x0b\x32\x15.carla_server.ControlB\x03\xf8\x01\x01\x62\x06proto3')
) )
@ -692,56 +692,63 @@ _MEASUREMENTS_PLAYERMEASUREMENTS = _descriptor.Descriptor(
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
options=None), options=None),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='acceleration', full_name='carla_server.Measurements.PlayerMeasurements.acceleration', index=1, name='box_extent', full_name='carla_server.Measurements.PlayerMeasurements.box_extent', index=1,
number=11, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
_descriptor.FieldDescriptor(
name='acceleration', full_name='carla_server.Measurements.PlayerMeasurements.acceleration', index=2,
number=3, type=11, cpp_type=10, label=1, number=3, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None, has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
options=None), options=None),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='forward_speed', full_name='carla_server.Measurements.PlayerMeasurements.forward_speed', index=2, name='forward_speed', full_name='carla_server.Measurements.PlayerMeasurements.forward_speed', index=3,
number=4, type=2, cpp_type=6, label=1, number=4, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0), has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
options=None), options=None),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='collision_vehicles', full_name='carla_server.Measurements.PlayerMeasurements.collision_vehicles', index=3, name='collision_vehicles', full_name='carla_server.Measurements.PlayerMeasurements.collision_vehicles', index=4,
number=5, type=2, cpp_type=6, label=1, number=5, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0), has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
options=None), options=None),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='collision_pedestrians', full_name='carla_server.Measurements.PlayerMeasurements.collision_pedestrians', index=4, name='collision_pedestrians', full_name='carla_server.Measurements.PlayerMeasurements.collision_pedestrians', index=5,
number=6, type=2, cpp_type=6, label=1, number=6, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0), has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
options=None), options=None),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='collision_other', full_name='carla_server.Measurements.PlayerMeasurements.collision_other', index=5, name='collision_other', full_name='carla_server.Measurements.PlayerMeasurements.collision_other', index=6,
number=7, type=2, cpp_type=6, label=1, number=7, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0), has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
options=None), options=None),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='intersection_otherlane', full_name='carla_server.Measurements.PlayerMeasurements.intersection_otherlane', index=6, name='intersection_otherlane', full_name='carla_server.Measurements.PlayerMeasurements.intersection_otherlane', index=7,
number=8, type=2, cpp_type=6, label=1, number=8, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0), has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
options=None), options=None),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='intersection_offroad', full_name='carla_server.Measurements.PlayerMeasurements.intersection_offroad', index=7, name='intersection_offroad', full_name='carla_server.Measurements.PlayerMeasurements.intersection_offroad', index=8,
number=9, type=2, cpp_type=6, label=1, number=9, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0), has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None, is_extension=False, extension_scope=None,
options=None), options=None),
_descriptor.FieldDescriptor( _descriptor.FieldDescriptor(
name='autopilot_control', full_name='carla_server.Measurements.PlayerMeasurements.autopilot_control', index=8, name='autopilot_control', full_name='carla_server.Measurements.PlayerMeasurements.autopilot_control', index=9,
number=10, type=11, cpp_type=10, label=1, number=10, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None, has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None, message_type=None, enum_type=None, containing_type=None,
@ -760,7 +767,7 @@ _MEASUREMENTS_PLAYERMEASUREMENTS = _descriptor.Descriptor(
oneofs=[ oneofs=[
], ],
serialized_start=1652, serialized_start=1652,
serialized_end=1981, serialized_end=2025,
) )
_MEASUREMENTS = _descriptor.Descriptor( _MEASUREMENTS = _descriptor.Descriptor(
@ -811,7 +818,7 @@ _MEASUREMENTS = _descriptor.Descriptor(
oneofs=[ oneofs=[
], ],
serialized_start=1459, serialized_start=1459,
serialized_end=1981, serialized_end=2025,
) )
_TRANSFORM.fields_by_name['location'].message_type = _VECTOR3D _TRANSFORM.fields_by_name['location'].message_type = _VECTOR3D
@ -846,6 +853,7 @@ _AGENT.fields_by_name['speed_limit_sign'].containing_oneof = _AGENT.oneofs_by_na
_SCENEDESCRIPTION.fields_by_name['player_start_spots'].message_type = _TRANSFORM _SCENEDESCRIPTION.fields_by_name['player_start_spots'].message_type = _TRANSFORM
_SCENEDESCRIPTION.fields_by_name['sensors'].message_type = _SENSOR _SCENEDESCRIPTION.fields_by_name['sensors'].message_type = _SENSOR
_MEASUREMENTS_PLAYERMEASUREMENTS.fields_by_name['transform'].message_type = _TRANSFORM _MEASUREMENTS_PLAYERMEASUREMENTS.fields_by_name['transform'].message_type = _TRANSFORM
_MEASUREMENTS_PLAYERMEASUREMENTS.fields_by_name['box_extent'].message_type = _VECTOR3D
_MEASUREMENTS_PLAYERMEASUREMENTS.fields_by_name['acceleration'].message_type = _VECTOR3D _MEASUREMENTS_PLAYERMEASUREMENTS.fields_by_name['acceleration'].message_type = _VECTOR3D
_MEASUREMENTS_PLAYERMEASUREMENTS.fields_by_name['autopilot_control'].message_type = _CONTROL _MEASUREMENTS_PLAYERMEASUREMENTS.fields_by_name['autopilot_control'].message_type = _CONTROL
_MEASUREMENTS_PLAYERMEASUREMENTS.containing_type = _MEASUREMENTS _MEASUREMENTS_PLAYERMEASUREMENTS.containing_type = _MEASUREMENTS

View File

@ -82,6 +82,12 @@ public:
return Transform.GetRotation().GetForwardVector(); return Transform.GetRotation().GetForwardVector();
} }
UFUNCTION(BlueprintCallable)
FVector GetBoundsExtent() const
{
return BoundsExtent;
}
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
float GetForwardSpeed() const float GetForwardSpeed() const
{ {
@ -220,6 +226,9 @@ private:
UPROPERTY(VisibleAnywhere) UPROPERTY(VisibleAnywhere)
FTransform Transform; FTransform Transform;
UPROPERTY(VisibleAnywhere)
FVector BoundsExtent;
UPROPERTY(VisibleAnywhere) UPROPERTY(VisibleAnywhere)
float ForwardSpeed = 0.0f; float ForwardSpeed = 0.0f;

View File

@ -103,6 +103,7 @@ void FCarlaEncoder::Encode(
Data.game_timestamp = PlayerState.GetGameTimeStamp(); Data.game_timestamp = PlayerState.GetGameTimeStamp();
auto &Player = Data.player_measurements; auto &Player = Data.player_measurements;
::Encode(PlayerState.GetTransform(), Player.transform); ::Encode(PlayerState.GetTransform(), Player.transform);
::Encode(PlayerState.GetBoundsExtent(), Player.box_extent);
::Encode(PlayerState.GetAcceleration(), Player.acceleration); ::Encode(PlayerState.GetAcceleration(), Player.acceleration);
Player.forward_speed = PlayerState.GetForwardSpeed(); Player.forward_speed = PlayerState.GetForwardSpeed();
Player.collision_vehicles = PlayerState.GetCollisionIntensityCars(); Player.collision_vehicles = PlayerState.GetCollisionIntensityCars();

View File

@ -42,6 +42,8 @@ void ACarlaVehicleController::Possess(APawn *aPawn)
// Get custom player state. // Get custom player state.
CarlaPlayerState = Cast<ACarlaPlayerState>(PlayerState); CarlaPlayerState = Cast<ACarlaPlayerState>(PlayerState);
check(CarlaPlayerState != nullptr); check(CarlaPlayerState != nullptr);
// We can set bounds extent already as it's not going to change.
CarlaPlayerState->BoundsExtent = GetPossessedVehicle()->GetVehicleBoundsExtent();
// Set HUD input. // Set HUD input.
CarlaHUD = Cast<ACarlaHUD>(GetHUD()); CarlaHUD = Cast<ACarlaHUD>(GetHUD());
if (CarlaHUD != nullptr) { if (CarlaHUD != nullptr) {

View File

@ -156,6 +156,8 @@ extern "C" {
struct carla_player_measurements { struct carla_player_measurements {
/** World transform of the player. */ /** World transform of the player. */
struct carla_transform transform; struct carla_transform transform;
/** Extent of the bounding box of the player. */
struct carla_vector3d box_extent;
/** Current acceleration of the player. */ /** Current acceleration of the player. */
struct carla_vector3d acceleration; struct carla_vector3d acceleration;
/** Forward speed in km/h. */ /** Forward speed in km/h. */

View File

@ -155,6 +155,7 @@ namespace server {
auto *player = message->mutable_player_measurements(); auto *player = message->mutable_player_measurements();
DEBUG_ASSERT(player != nullptr); DEBUG_ASSERT(player != nullptr);
Set(player->mutable_transform(), values.player_measurements.transform); Set(player->mutable_transform(), values.player_measurements.transform);
Set(player->mutable_box_extent(), values.player_measurements.box_extent);
Set(player->mutable_acceleration(), values.player_measurements.acceleration); Set(player->mutable_acceleration(), values.player_measurements.acceleration);
player->set_forward_speed(values.player_measurements.forward_speed); player->set_forward_speed(values.player_measurements.forward_speed);
player->set_collision_vehicles(values.player_measurements.collision_vehicles); player->set_collision_vehicles(values.player_measurements.collision_vehicles);

View File

@ -126,6 +126,8 @@ message Measurements {
message PlayerMeasurements { message PlayerMeasurements {
Transform transform = 1; Transform transform = 1;
Vector3D box_extent = 11;
Vector3D acceleration = 3; Vector3D acceleration = 3;
float forward_speed = 4; float forward_speed = 4;