From d2d974d42e475226677a012baedca736c4466c37 Mon Sep 17 00:00:00 2001 From: Pascal Perle Date: Fri, 1 May 2020 18:29:50 +0200 Subject: [PATCH 1/6] Added documentation references. --- PythonAPI/carla/source/libcarla/Actor.cpp | 104 ++++----- PythonAPI/carla/source/libcarla/AdRss.cpp | 66 +++--- PythonAPI/carla/source/libcarla/Blueprint.cpp | 60 ++--- PythonAPI/carla/source/libcarla/Client.cpp | 54 ++--- PythonAPI/carla/source/libcarla/Control.cpp | 106 ++++----- PythonAPI/carla/source/libcarla/Geom.cpp | 98 ++++----- .../carla/source/libcarla/LightManager.cpp | 74 +++---- PythonAPI/carla/source/libcarla/Map.cpp | 206 +++++++++--------- PythonAPI/carla/source/libcarla/Sensor.cpp | 6 +- .../carla/source/libcarla/SensorData.cpp | 94 ++++---- PythonAPI/carla/source/libcarla/Snapshot.cpp | 36 +-- .../carla/source/libcarla/TrafficManager.cpp | 35 +-- PythonAPI/carla/source/libcarla/Weather.cpp | 24 +- PythonAPI/carla/source/libcarla/World.cpp | 96 ++++---- PythonAPI/carla/source/libcarla/libcarla.cpp | 5 + 15 files changed, 535 insertions(+), 529 deletions(-) diff --git a/PythonAPI/carla/source/libcarla/Actor.cpp b/PythonAPI/carla/source/libcarla/Actor.cpp index 9735efb2b5e..e83ef5c27bd 100644 --- a/PythonAPI/carla/source/libcarla/Actor.cpp +++ b/PythonAPI/carla/source/libcarla/Actor.cpp @@ -63,31 +63,31 @@ void export_actor() { class_>("Actor", no_init) // work-around, force return copy to resolve Actor instead of ActorState. - .add_property("id", CALL_RETURNING_COPY(cc::Actor, GetId)) - .add_property("type_id", CALL_RETURNING_COPY(cc::Actor, GetTypeId)) - .add_property("parent", CALL_RETURNING_COPY(cc::Actor, GetParent)) - .add_property("semantic_tags", &GetSemanticTags) - .add_property("is_alive", CALL_RETURNING_COPY(cc::Actor, IsAlive)) + .add_property("id", CALL_RETURNING_COPY(cc::Actor, GetId), "@DocString(Actor.id)") + .add_property("type_id", CALL_RETURNING_COPY(cc::Actor, GetTypeId), "@DocString(Actor.type_id)") + .add_property("parent", CALL_RETURNING_COPY(cc::Actor, GetParent), "@DocString(Actor.parent)") + .add_property("semantic_tags", &GetSemanticTags, "@DocString(Actor.semantic_tags)") + .add_property("is_alive", CALL_RETURNING_COPY(cc::Actor, IsAlive), "@DocString(Actor.is_alive)") .add_property("attributes", +[] (const cc::Actor &self) { boost::python::dict atttribute_dict; for (auto &&attribute_value : self.GetAttributes()) { atttribute_dict[attribute_value.GetId()] = attribute_value.GetValue(); } return atttribute_dict; - }) - .def("get_world", CALL_RETURNING_COPY(cc::Actor, GetWorld)) - .def("get_location", &cc::Actor::GetLocation) - .def("get_transform", &cc::Actor::GetTransform) - .def("get_velocity", &cc::Actor::GetVelocity) - .def("get_angular_velocity", &cc::Actor::GetAngularVelocity) - .def("get_acceleration", &cc::Actor::GetAcceleration) - .def("set_location", &cc::Actor::SetLocation, (arg("location"))) - .def("set_transform", &cc::Actor::SetTransform, (arg("transform"))) - .def("set_velocity", &cc::Actor::SetVelocity, (arg("vector"))) - .def("set_angular_velocity", &cc::Actor::SetAngularVelocity, (arg("vector"))) - .def("add_impulse", &cc::Actor::AddImpulse, (arg("vector"))) - .def("set_simulate_physics", &cc::Actor::SetSimulatePhysics, (arg("enabled") = true)) - .def("destroy", CALL_WITHOUT_GIL(cc::Actor, Destroy)) + }, "@DocString(Actor.attributes)") + .def("get_world", CALL_RETURNING_COPY(cc::Actor, GetWorld), "@DocString(Actor.get_world)") + .def("get_location", &cc::Actor::GetLocation, "@DocString(Actor.get_location)") + .def("get_transform", &cc::Actor::GetTransform, "@DocString(Actor.get_transform)") + .def("get_velocity", &cc::Actor::GetVelocity, "@DocString(Actor.get_velocity)") + .def("get_angular_velocity", &cc::Actor::GetAngularVelocity, "@DocString(Actor.get_angular_velocity)") + .def("get_acceleration", &cc::Actor::GetAcceleration, "@DocString(Actor.get_acceleration)") + .def("set_location", &cc::Actor::SetLocation, (arg("location")), "@DocString(Actor.set_location)") + .def("set_transform", &cc::Actor::SetTransform, (arg("transform")), "@DocString(Actor.set_transform)") + .def("set_velocity", &cc::Actor::SetVelocity, (arg("vector")), "@DocString(Actor.set_velocity)") + .def("set_angular_velocity", &cc::Actor::SetAngularVelocity, (arg("vector")), "@DocString(Actor.set_angular_velocity)") + .def("add_impulse", &cc::Actor::AddImpulse, (arg("vector")), "@DocString(Actor.add_impulse)") + .def("set_simulate_physics", &cc::Actor::SetSimulatePhysics, (arg("enabled") = true), "@DocString(Actor.set_simulate_physics)") + .def("destroy", CALL_WITHOUT_GIL(cc::Actor, Destroy), "@DocString(Actor.destroy)") .def(self_ns::str(self_ns::self)) ; @@ -110,40 +110,40 @@ void export_actor() { class_, boost::noncopyable, boost::shared_ptr>("Vehicle", no_init) .add_property("bounding_box", CALL_RETURNING_COPY(cc::Vehicle, GetBoundingBox)) - .def("apply_control", &cc::Vehicle::ApplyControl, (arg("control"))) - .def("get_control", &cc::Vehicle::GetControl) - .def("set_light_state", &cc::Vehicle::SetLightState, (arg("light_state"))) - .def("get_light_state", CONST_CALL_WITHOUT_GIL(cc::Vehicle, GetLightState)) - .def("apply_physics_control", &cc::Vehicle::ApplyPhysicsControl, (arg("physics_control"))) - .def("get_physics_control", CONST_CALL_WITHOUT_GIL(cc::Vehicle, GetPhysicsControl)) - .def("set_autopilot", CALL_WITHOUT_GIL_2(cc::Vehicle, SetAutopilot, bool, uint16_t), (arg("enabled") = true, arg("tm_port") = TM_DEFAULT_PORT)) - .def("get_speed_limit", &cc::Vehicle::GetSpeedLimit) - .def("get_traffic_light_state", &cc::Vehicle::GetTrafficLightState) - .def("is_at_traffic_light", &cc::Vehicle::IsAtTrafficLight) - .def("get_traffic_light", &cc::Vehicle::GetTrafficLight) + .def("apply_control", &cc::Vehicle::ApplyControl, (arg("control")), "@DocString(Vehicle.apply_control)") + .def("get_control", &cc::Vehicle::GetControl, "@DocString(Vehicle.get_control)") + .def("set_light_state", &cc::Vehicle::SetLightState, (arg("light_state")), "@DocString(Vehicle.set_light_state)") + .def("get_light_state", CONST_CALL_WITHOUT_GIL(cc::Vehicle, GetLightState), "@DocString(Vehicle.get_light_state)") + .def("apply_physics_control", &cc::Vehicle::ApplyPhysicsControl, (arg("physics_control")), "@DocString(Vehicle.apply_physics_control)") + .def("get_physics_control", CONST_CALL_WITHOUT_GIL(cc::Vehicle, GetPhysicsControl), "@DocString(Vehicle.get_physics_control)") + .def("set_autopilot", CALL_WITHOUT_GIL_2(cc::Vehicle, SetAutopilot, bool, uint16_t), (arg("enabled") = true, arg("tm_port") = TM_DEFAULT_PORT), "@DocString(Vehicle.set_autopilot)") + .def("get_speed_limit", &cc::Vehicle::GetSpeedLimit, "@DocString(Vehicle.get_speed_limit)") + .def("get_traffic_light_state", &cc::Vehicle::GetTrafficLightState, "@DocString(Vehicle.get_traffic_light_state)") + .def("is_at_traffic_light", &cc::Vehicle::IsAtTrafficLight, "@DocString(Vehicle.is_at_traffic_light)") + .def("get_traffic_light", &cc::Vehicle::GetTrafficLight, "@DocString(Vehicle.get_traffic_light)") .def(self_ns::str(self_ns::self)) ; class_, boost::noncopyable, boost::shared_ptr>("Walker", no_init) .add_property("bounding_box", CALL_RETURNING_COPY(cc::Walker, GetBoundingBox)) - .def("apply_control", &ApplyControl, (arg("control"))) - .def("apply_control", &ApplyControl, (arg("control"))) - .def("get_control", &cc::Walker::GetWalkerControl) + .def("apply_control", &ApplyControl, (arg("control")), "@DocString(Walker.apply_control)") + .def("apply_control", &ApplyControl, (arg("control")), "@DocString(Walker.apply_control)") + .def("get_control", &cc::Walker::GetWalkerControl, "@DocString(Walker.get_control)") .def(self_ns::str(self_ns::self)) ; class_, boost::noncopyable, boost::shared_ptr>("WalkerAIController", no_init) - .def("start", &cc::WalkerAIController::Start) - .def("stop", &cc::WalkerAIController::Stop) - .def("go_to_location", &cc::WalkerAIController::GoToLocation, (arg("destination"))) - .def("set_max_speed", &cc::WalkerAIController::SetMaxSpeed, (arg("speed"))) + .def("start", &cc::WalkerAIController::Start, "@DocString(WalkerAIController.start)") + .def("stop", &cc::WalkerAIController::Stop, "@DocString(WalkerAIController.stop)") + .def("go_to_location", &cc::WalkerAIController::GoToLocation, (arg("destination")), "@DocString(WalkerAIController.go_to_location)") + .def("set_max_speed", &cc::WalkerAIController::SetMaxSpeed, (arg("speed")), "@DocString(WalkerAIController.set_max_speed)") .def(self_ns::str(self_ns::self)) ; class_, boost::noncopyable, boost::shared_ptr>( "TrafficSign", no_init) - .add_property("trigger_volume", CALL_RETURNING_COPY(cc::TrafficSign, GetTriggerVolume)) + .add_property("trigger_volume", CALL_RETURNING_COPY(cc::TrafficSign, GetTriggerVolume), "@DocString(TrafficSign.trigger_volume)") ; enum_("TrafficLightState") @@ -157,20 +157,20 @@ void export_actor() { class_, boost::noncopyable, boost::shared_ptr>( "TrafficLight", no_init) - .add_property("state", &cc::TrafficLight::GetState) - .def("set_state", &cc::TrafficLight::SetState, (arg("state"))) - .def("get_state", &cc::TrafficLight::GetState) - .def("set_green_time", &cc::TrafficLight::SetGreenTime, (arg("green_time"))) - .def("get_green_time", &cc::TrafficLight::GetGreenTime) - .def("set_yellow_time", &cc::TrafficLight::SetYellowTime, (arg("yellow_time"))) - .def("get_yellow_time", &cc::TrafficLight::GetYellowTime) - .def("set_red_time", &cc::TrafficLight::SetRedTime, (arg("red_time"))) - .def("get_red_time", &cc::TrafficLight::GetRedTime) - .def("get_elapsed_time", &cc::TrafficLight::GetElapsedTime) - .def("freeze", &cc::TrafficLight::Freeze, (arg("freeze"))) - .def("is_frozen", &cc::TrafficLight::IsFrozen) - .def("get_pole_index", &cc::TrafficLight::GetPoleIndex) - .def("get_group_traffic_lights", &GetGroupTrafficLights) + .add_property("state", &cc::TrafficLight::GetState, "@DocString(TrafficLight.state)") + .def("set_state", &cc::TrafficLight::SetState, (arg("state")), "@DocString(TrafficLight.set_state)") + .def("get_state", &cc::TrafficLight::GetState, "@DocString(TrafficLight.get_state)") + .def("set_green_time", &cc::TrafficLight::SetGreenTime, (arg("green_time")), "@DocString(TrafficLight.set_green_time)") + .def("get_green_time", &cc::TrafficLight::GetGreenTime, "@DocString(TrafficLight.get_green_time)") + .def("set_yellow_time", &cc::TrafficLight::SetYellowTime, (arg("yellow_time")), "@DocString(TrafficLight.set_yellow_time)") + .def("get_yellow_time", &cc::TrafficLight::GetYellowTime, "@DocString(TrafficLight.get_yellow_time)") + .def("set_red_time", &cc::TrafficLight::SetRedTime, (arg("red_time")), "@DocString(TrafficLight.set_red_time)") + .def("get_red_time", &cc::TrafficLight::GetRedTime, "@DocString(TrafficLight.get_red_time)") + .def("get_elapsed_time", &cc::TrafficLight::GetElapsedTime, "@DocString(TrafficLight.get_elapsed_time)") + .def("freeze", &cc::TrafficLight::Freeze, (arg("freeze")), "@DocString(TrafficLight.freeze)") + .def("is_frozen", &cc::TrafficLight::IsFrozen, "@DocString(TrafficLight.is_frozen)") + .def("get_pole_index", &cc::TrafficLight::GetPoleIndex, "@DocString(TrafficLight.get_pole_index)") + .def("get_group_traffic_lights", &GetGroupTrafficLights, "@DocString(TrafficLight.get_group_traffic_lights)") .def(self_ns::str(self_ns::self)) ; } diff --git a/PythonAPI/carla/source/libcarla/AdRss.cpp b/PythonAPI/carla/source/libcarla/AdRss.cpp index 4615b80a733..568d4b207af 100644 --- a/PythonAPI/carla/source/libcarla/AdRss.cpp +++ b/PythonAPI/carla/source/libcarla/AdRss.cpp @@ -97,25 +97,25 @@ void export_ad_rss() { namespace csd = carla::sensor::data; class_("RssEgoDynamicsOnRoute") - .def_readwrite("timestamp", &carla::rss::EgoDynamicsOnRoute::timestamp) + .def_readwrite("timestamp", &carla::rss::EgoDynamicsOnRoute::timestamp, "@DocString(RssEgoDynamicsOnRoute.timestamp)") .def_readwrite("time_since_epoch_check_start_ms", - &carla::rss::EgoDynamicsOnRoute::time_since_epoch_check_start_ms) - .def_readwrite("time_since_epoch_check_end_ms", &carla::rss::EgoDynamicsOnRoute::time_since_epoch_check_end_ms) - .def_readwrite("ego_speed", &carla::rss::EgoDynamicsOnRoute::ego_speed) - .def_readwrite("min_stopping_distance", &carla::rss::EgoDynamicsOnRoute::min_stopping_distance) - .def_readwrite("ego_center", &carla::rss::EgoDynamicsOnRoute::ego_center) - .def_readwrite("ego_heading", &carla::rss::EgoDynamicsOnRoute::ego_heading) - .def_readwrite("ego_center_within_route", &carla::rss::EgoDynamicsOnRoute::ego_center_within_route) - .def_readwrite("crossing_border", &carla::rss::EgoDynamicsOnRoute::crossing_border) - .def_readwrite("route_heading", &carla::rss::EgoDynamicsOnRoute::route_heading) - .def_readwrite("route_nominal_center", &carla::rss::EgoDynamicsOnRoute::route_nominal_center) - .def_readwrite("heading_diff", &carla::rss::EgoDynamicsOnRoute::heading_diff) - .def_readwrite("route_speed_lat", &carla::rss::EgoDynamicsOnRoute::route_speed_lat) - .def_readwrite("route_speed_lon", &carla::rss::EgoDynamicsOnRoute::route_speed_lon) - .def_readwrite("route_accel_lat", &carla::rss::EgoDynamicsOnRoute::route_accel_lat) - .def_readwrite("route_accel_lon", &carla::rss::EgoDynamicsOnRoute::route_accel_lon) - .def_readwrite("avg_route_accel_lat", &carla::rss::EgoDynamicsOnRoute::avg_route_accel_lat) - .def_readwrite("avg_route_accel_lon", &carla::rss::EgoDynamicsOnRoute::avg_route_accel_lon) + &carla::rss::EgoDynamicsOnRoute::time_since_epoch_check_start_ms, "@DocString(RssEgoDynamicsOnRoute.time_since_epoch_check_start_ms)") + .def_readwrite("time_since_epoch_check_end_ms", &carla::rss::EgoDynamicsOnRoute::time_since_epoch_check_end_ms, "@DocString(RssEgoDynamicsOnRoute.time_since_epoch_check_end_ms)") + .def_readwrite("ego_speed", &carla::rss::EgoDynamicsOnRoute::ego_speed, "@DocString(RssEgoDynamicsOnRoute.ego_speed)") + .def_readwrite("min_stopping_distance", &carla::rss::EgoDynamicsOnRoute::min_stopping_distance, "@DocString(RssEgoDynamicsOnRoute.min_stopping_distance)") + .def_readwrite("ego_center", &carla::rss::EgoDynamicsOnRoute::ego_center, "@DocString(RssEgoDynamicsOnRoute.ego_center)") + .def_readwrite("ego_heading", &carla::rss::EgoDynamicsOnRoute::ego_heading, "@DocString(RssEgoDynamicsOnRoute.ego_heading)") + .def_readwrite("ego_center_within_route", &carla::rss::EgoDynamicsOnRoute::ego_center_within_route, "@DocString(RssEgoDynamicsOnRoute.ego_center_within_route)") + .def_readwrite("crossing_border", &carla::rss::EgoDynamicsOnRoute::crossing_border, "@DocString(RssEgoDynamicsOnRoute.crossing_border)") + .def_readwrite("route_heading", &carla::rss::EgoDynamicsOnRoute::route_heading, "@DocString(RssEgoDynamicsOnRoute.route_heading)") + .def_readwrite("route_nominal_center", &carla::rss::EgoDynamicsOnRoute::route_nominal_center, "@DocString(RssEgoDynamicsOnRoute.route_nominal_center)") + .def_readwrite("heading_diff", &carla::rss::EgoDynamicsOnRoute::heading_diff, "@DocString(RssEgoDynamicsOnRoute.heading_diff)") + .def_readwrite("route_speed_lat", &carla::rss::EgoDynamicsOnRoute::route_speed_lat, "@DocString(RssEgoDynamicsOnRoute.route_speed_lat)") + .def_readwrite("route_speed_lon", &carla::rss::EgoDynamicsOnRoute::route_speed_lon, "@DocString(RssEgoDynamicsOnRoute.route_speed_lon)") + .def_readwrite("route_accel_lat", &carla::rss::EgoDynamicsOnRoute::route_accel_lat, "@DocString(RssEgoDynamicsOnRoute.route_accel_lat)") + .def_readwrite("route_accel_lon", &carla::rss::EgoDynamicsOnRoute::route_accel_lon, "@DocString(RssEgoDynamicsOnRoute.route_accel_lon)") + .def_readwrite("avg_route_accel_lat", &carla::rss::EgoDynamicsOnRoute::avg_route_accel_lat, "@DocString(RssEgoDynamicsOnRoute.avg_route_accel_lat)") + .def_readwrite("avg_route_accel_lon", &carla::rss::EgoDynamicsOnRoute::avg_route_accel_lon, "@DocString(RssEgoDynamicsOnRoute.avg_route_accel_lon)") .def(self_ns::str(self_ns::self)); enum_("RssRoadBoundariesMode") @@ -131,28 +131,28 @@ void export_ad_rss() { class_, boost::noncopyable, boost::shared_ptr>( "RssResponse", no_init) - .add_property("response_valid", &csd::RssResponse::GetResponseValid) - .add_property("proper_response", CALL_RETURNING_COPY(csd::RssResponse, GetProperResponse)) - .add_property("acceleration_restriction", CALL_RETURNING_COPY(csd::RssResponse, GetAccelerationRestriction)) - .add_property("rss_state_snapshot", CALL_RETURNING_COPY(csd::RssResponse, GetRssStateSnapshot)) - .add_property("ego_dynamics_on_route", CALL_RETURNING_COPY(csd::RssResponse, GetEgoDynamicsOnRoute)) + .add_property("response_valid", &csd::RssResponse::GetResponseValid, "@DocString(RssResponse.response_valid)") + .add_property("proper_response", CALL_RETURNING_COPY(csd::RssResponse, GetProperResponse), "@DocString(RssResponse.proper_response)") + .add_property("acceleration_restriction", CALL_RETURNING_COPY(csd::RssResponse, GetAccelerationRestriction), "@DocString(RssResponse.acceleration_restriction)") + .add_property("rss_state_snapshot", CALL_RETURNING_COPY(csd::RssResponse, GetRssStateSnapshot), "@DocString(RssResponse.rss_state_snapshot)") + .add_property("ego_dynamics_on_route", CALL_RETURNING_COPY(csd::RssResponse, GetEgoDynamicsOnRoute), "@DocString(RssResponse.ego_dynamics_on_route)") .def(self_ns::str(self_ns::self)); class_, boost::noncopyable, boost::shared_ptr>("RssSensor", no_init) - .add_property("ego_vehicle_dynamics", &GetEgoVehicleDynamics, &cc::RssSensor::SetEgoVehicleDynamics) - .add_property("other_vehicle_dynamics", &GetOtherVehicleDynamics, &cc::RssSensor::SetOtherVehicleDynamics) - .add_property("road_boundaries_mode", &GetRoadBoundariesMode, &cc::RssSensor::SetRoadBoundariesMode) - .add_property("visualization_mode", &GetVisualizationMode, &cc::RssSensor::SetVisualizationMode) - .add_property("routing_targets", &GetRoutingTargets) - .def("append_routing_target", &cc::RssSensor::AppendRoutingTarget, (arg("routing_target"))) - .def("reset_routing_targets", &cc::RssSensor::ResetRoutingTargets) - .def("drop_route", &cc::RssSensor::DropRoute) + .add_property("ego_vehicle_dynamics", &GetEgoVehicleDynamics, &cc::RssSensor::SetEgoVehicleDynamics, "@DocString(RssSensor.ego_vehicle_dynamics)") + .add_property("other_vehicle_dynamics", &GetOtherVehicleDynamics, &cc::RssSensor::SetOtherVehicleDynamics, "@DocString(RssSensor.other_vehicle_dynamics)") + .add_property("road_boundaries_mode", &GetRoadBoundariesMode, &cc::RssSensor::SetRoadBoundariesMode, "@DocString(RssSensor.road_boundaries_mode)") + .add_property("visualization_mode", &GetVisualizationMode, &cc::RssSensor::SetVisualizationMode, "@DocString(RssSensor.visualization_mode)") + .add_property("routing_targets", &GetRoutingTargets, "@DocString(RssSensor.routing_targets)") + .def("append_routing_target", &cc::RssSensor::AppendRoutingTarget, (arg("routing_target")), "@DocString(RssSensor.append_routing_target)") + .def("reset_routing_targets", &cc::RssSensor::ResetRoutingTargets, "@DocString(RssSensor.reset_routing_targets)") + .def("drop_route", &cc::RssSensor::DropRoute, "@DocString(RssSensor.drop_route)") .def(self_ns::str(self_ns::self)); class_>("RssRestrictor", no_init) - .def(init<>()) + .def(init<>(), "@RssRestrictor(RssSensor.__init__)") .def("restrict_vehicle_control", &carla::rss::RssRestrictor::RestrictVehicleControl, - (arg("vehicle_control"), arg("restriction"), arg("ego_dynamics_on_route"), arg("vehicle_physics"))) + (arg("vehicle_control"), arg("restriction"), arg("ego_dynamics_on_route"), arg("vehicle_physics")), "@RssRestrictor(RssSensor.restrict_vehicle_control)") .def(self_ns::str(self_ns::self)); } diff --git a/PythonAPI/carla/source/libcarla/Blueprint.cpp b/PythonAPI/carla/source/libcarla/Blueprint.cpp index 009834c7885..e55c336738f 100644 --- a/PythonAPI/carla/source/libcarla/Blueprint.cpp +++ b/PythonAPI/carla/source/libcarla/Blueprint.cpp @@ -87,26 +87,26 @@ void export_blueprint() { class_("Color") .def(init( - (arg("r")=0, arg("g")=0, arg("b")=0, arg("a")=255))) - .def_readwrite("r", &csd::Color::r) - .def_readwrite("g", &csd::Color::g) - .def_readwrite("b", &csd::Color::b) - .def_readwrite("a", &csd::Color::a) - .def("__eq__", &csd::Color::operator==) - .def("__ne__", &csd::Color::operator!=) + (arg("r")=0, arg("g")=0, arg("b")=0, arg("a")=255), "@DocString(Color.__init__)")) + .def_readwrite("r", &csd::Color::r, "@DocString(Color.r)") + .def_readwrite("g", &csd::Color::g, "@DocString(Color.g)") + .def_readwrite("b", &csd::Color::b, "@DocString(Color.b)") + .def_readwrite("a", &csd::Color::a, "@DocString(Color.a)") + .def("__eq__", &csd::Color::operator==, "@DocString(Color.__eq__)") + .def("__ne__", &csd::Color::operator!=, "@DocString(Color.__ne__)") .def(self_ns::str(self_ns::self)) ; class_("ActorAttribute", no_init) - .add_property("id", CALL_RETURNING_COPY(cc::ActorAttribute, GetId)) - .add_property("type", &cc::ActorAttribute::GetType) - .add_property("recommended_values", CALL_RETURNING_LIST(cc::ActorAttribute, GetRecommendedValues)) - .add_property("is_modifiable", &cc::ActorAttribute::IsModifiable) - .def("as_bool", &cc::ActorAttribute::As) - .def("as_int", &cc::ActorAttribute::As) - .def("as_float", &cc::ActorAttribute::As) - .def("as_str", &cc::ActorAttribute::As) - .def("as_color", &cc::ActorAttribute::As) + .add_property("id", CALL_RETURNING_COPY(cc::ActorAttribute, GetId), "@DocString(ActorAttribute.id)") + .add_property("type", &cc::ActorAttribute::GetType, "@DocString(ActorAttribute.type)") + .add_property("recommended_values", CALL_RETURNING_LIST(cc::ActorAttribute, GetRecommendedValues), "@DocString(ActorAttribute.recommended_values)") + .add_property("is_modifiable", &cc::ActorAttribute::IsModifiable, "@DocString(ActorAttribute.is_modifiable)") + .def("as_bool", &cc::ActorAttribute::As, "@DocString(ActorAttribute.as_bool)") + .def("as_int", &cc::ActorAttribute::As, "@DocString(ActorAttribute.as_int)") + .def("as_float", &cc::ActorAttribute::As, "@DocString(ActorAttribute.as_float)") + .def("as_str", &cc::ActorAttribute::As, "@DocString(ActorAttribute.as_str)") + .def("as_color", &cc::ActorAttribute::As, "@DocString(ActorAttribute.as_color)") .def("__eq__", &cc::ActorAttributeValueAccess::operator==) .def("__eq__", &cc::ActorAttributeValueAccess::operator==) .def("__eq__", &cc::ActorAttributeValueAccess::operator==) @@ -128,28 +128,28 @@ void export_blueprint() { ; class_("ActorBlueprint", no_init) - .add_property("id", CALL_RETURNING_COPY(cc::ActorBlueprint, GetId)) - .add_property("tags", CALL_RETURNING_LIST(cc::ActorBlueprint, GetTags)) - .def("has_tag", &cc::ActorBlueprint::ContainsTag) - .def("match_tags", &cc::ActorBlueprint::MatchTags) - .def("has_attribute", &cc::ActorBlueprint::ContainsAttribute) - .def("get_attribute", CALL_RETURNING_COPY_1(cc::ActorBlueprint, GetAttribute, const std::string &)) - .def("set_attribute", &cc::ActorBlueprint::SetAttribute) - .def("__len__", &cc::ActorBlueprint::size) - .def("__iter__", range(&cc::ActorBlueprint::begin, &cc::ActorBlueprint::end)) + .add_property("id", CALL_RETURNING_COPY(cc::ActorBlueprint, GetId), "@DocString(ActorBlueprint.id)") + .add_property("tags", CALL_RETURNING_LIST(cc::ActorBlueprint, GetTags), "@DocString(ActorBlueprint.tags)") + .def("has_tag", &cc::ActorBlueprint::ContainsTag, "@DocString(ActorBlueprint.has_tag)") + .def("match_tags", &cc::ActorBlueprint::MatchTags, "@DocString(ActorBlueprint.match_tags)") + .def("has_attribute", &cc::ActorBlueprint::ContainsAttribute, "@DocString(ActorBlueprint.has_attribute)") + .def("get_attribute", CALL_RETURNING_COPY_1(cc::ActorBlueprint, GetAttribute, const std::string &), "@DocString(ActorBlueprint.get_attribute)") + .def("set_attribute", &cc::ActorBlueprint::SetAttribute, "@DocString(ActorBlueprint.set_attribute)") + .def("__len__", &cc::ActorBlueprint::size, "@DocString(ActorBlueprint.__len__)") + .def("__iter__", range(&cc::ActorBlueprint::begin, &cc::ActorBlueprint::end), "@DocString(ActorBlueprint.__iter__)") .def(self_ns::str(self_ns::self)) ; class_>("BlueprintLibrary", no_init) .def("find", +[](const cc::BlueprintLibrary &self, const std::string &key) -> cc::ActorBlueprint { return self.at(key); - }, (arg("id"))) - .def("filter", &cc::BlueprintLibrary::Filter, (arg("wildcard_pattern"))) + }, (arg("id")), "@DocString(BlueprintLibrary.find)") + .def("filter", &cc::BlueprintLibrary::Filter, (arg("wildcard_pattern")), "@DocString(BlueprintLibrary.filter)") .def("__getitem__", +[](const cc::BlueprintLibrary &self, size_t pos) -> cc::ActorBlueprint { return self.at(pos); - }) - .def("__len__", &cc::BlueprintLibrary::size) - .def("__iter__", range(&cc::BlueprintLibrary::begin, &cc::BlueprintLibrary::end)) + }, "@DocString(BlueprintLibrary.__getitem__)") + .def("__len__", &cc::BlueprintLibrary::size, "@DocString(BlueprintLibrary.__len__)") + .def("__iter__", range(&cc::BlueprintLibrary::begin, &cc::BlueprintLibrary::end), "@DocString(BlueprintLibrary.__iter__)") .def(self_ns::str(self_ns::self)) ; } diff --git a/PythonAPI/carla/source/libcarla/Client.cpp b/PythonAPI/carla/source/libcarla/Client.cpp index 8fbcee5ee1c..05563729b70 100644 --- a/PythonAPI/carla/source/libcarla/Client.cpp +++ b/PythonAPI/carla/source/libcarla/Client.cpp @@ -161,36 +161,36 @@ void export_client() { namespace rpc = carla::rpc; class_("OpendriveGenerationParameters", - init((arg("vertex_distance")=2.0, arg("max_road_length")=50.0, arg("wall_height")=1.0, arg("additional_width")=0.6, arg("smooth_junctions")=true, arg("enable_mesh_visibility")=true))) - .def_readwrite("vertex_distance", &rpc::OpendriveGenerationParameters::vertex_distance) - .def_readwrite("max_road_length", &rpc::OpendriveGenerationParameters::max_road_length) - .def_readwrite("wall_height", &rpc::OpendriveGenerationParameters::wall_height) - .def_readwrite("additional_width", &rpc::OpendriveGenerationParameters::additional_width) - .def_readwrite("smooth_junctions", &rpc::OpendriveGenerationParameters::smooth_junctions) - .def_readwrite("enable_mesh_visibility", &rpc::OpendriveGenerationParameters::enable_mesh_visibility) + init((arg("vertex_distance")=2.0, arg("max_road_length")=50.0, arg("wall_height")=1.0, arg("additional_width")=0.6, arg("smooth_junctions")=true, arg("enable_mesh_visibility")=true), "@DocString(OpendriveGenerationParameters.__init__)")) + .def_readwrite("vertex_distance", &rpc::OpendriveGenerationParameters::vertex_distance, "@DocString(OpendriveGenerationParameters.vertex_distance)") + .def_readwrite("max_road_length", &rpc::OpendriveGenerationParameters::max_road_length, "@DocString(OpendriveGenerationParameters.max_road_length)") + .def_readwrite("wall_height", &rpc::OpendriveGenerationParameters::wall_height, "@DocString(OpendriveGenerationParameters.wall_height)") + .def_readwrite("additional_width", &rpc::OpendriveGenerationParameters::additional_width, "@DocString(OpendriveGenerationParameters.additional_width)") + .def_readwrite("smooth_junctions", &rpc::OpendriveGenerationParameters::smooth_junctions, "@DocString(OpendriveGenerationParameters.smooth_junctions)") + .def_readwrite("enable_mesh_visibility", &rpc::OpendriveGenerationParameters::enable_mesh_visibility, "@DocString(OpendriveGenerationParameters.enable_mesh_visibility)") ; class_("Client", - init((arg("host"), arg("port"), arg("worker_threads")=0u))) - .def("set_timeout", &::SetTimeout, (arg("seconds"))) - .def("get_client_version", &cc::Client::GetClientVersion) - .def("get_server_version", CONST_CALL_WITHOUT_GIL(cc::Client, GetServerVersion)) - .def("get_world", &cc::Client::GetWorld) - .def("get_available_maps", &GetAvailableMaps) - .def("reload_world", CONST_CALL_WITHOUT_GIL(cc::Client, ReloadWorld)) - .def("load_world", CONST_CALL_WITHOUT_GIL_1(cc::Client, LoadWorld, std::string), (arg("map_name"))) + init((arg("host"), arg("port"), arg("worker_threads")=0u), "@DocString(Client.__init__)")) + .def("set_timeout", &::SetTimeout, (arg("seconds")), "@DocString(Client.set_timeout)") + .def("get_client_version", &cc::Client::GetClientVersion, "@DocString(Client.get_client_version)") + .def("get_server_version", CONST_CALL_WITHOUT_GIL(cc::Client, GetServerVersion), "@DocString(Client.get_server_version)") + .def("get_world", &cc::Client::GetWorld, "@DocString(Client.get_world)") + .def("get_available_maps", &GetAvailableMaps, "@DocString(Client.get_available_maps)") + .def("reload_world", CONST_CALL_WITHOUT_GIL(cc::Client, ReloadWorld), "@DocString(Client.reload_world)") + .def("load_world", CONST_CALL_WITHOUT_GIL_1(cc::Client, LoadWorld, std::string), (arg("map_name")), "@DocString(Client.load_world)") .def("generate_opendrive_world", CONST_CALL_WITHOUT_GIL_2(cc::Client, GenerateOpenDriveWorld, std::string, - rpc::OpendriveGenerationParameters), (arg("opendrive"), arg("parameters")=rpc::OpendriveGenerationParameters())) - .def("start_recorder", CALL_WITHOUT_GIL_1(cc::Client, StartRecorder, std::string), (arg("name"))) - .def("stop_recorder", &cc::Client::StopRecorder) - .def("show_recorder_file_info", CALL_WITHOUT_GIL_2(cc::Client, ShowRecorderFileInfo, std::string, bool), (arg("name"), arg("show_all"))) - .def("show_recorder_collisions", CALL_WITHOUT_GIL_3(cc::Client, ShowRecorderCollisions, std::string, char, char), (arg("name"), arg("type1"), arg("type2"))) - .def("show_recorder_actors_blocked", CALL_WITHOUT_GIL_3(cc::Client, ShowRecorderActorsBlocked, std::string, double, double), (arg("name"), arg("min_time"), arg("min_distance"))) - .def("replay_file", CALL_WITHOUT_GIL_4(cc::Client, ReplayFile, std::string, double, double, uint32_t), (arg("name"), arg("time_start"), arg("duration"), arg("follow_id"))) - .def("set_replayer_time_factor", &cc::Client::SetReplayerTimeFactor, (arg("time_factor"))) - .def("set_replayer_ignore_hero", &cc::Client::SetReplayerIgnoreHero, (arg("ignore_hero"))) - .def("apply_batch", &ApplyBatchCommands, (arg("commands"), arg("do_tick")=false)) - .def("apply_batch_sync", &ApplyBatchCommandsSync, (arg("commands"), arg("do_tick")=false)) - .def("get_trafficmanager", CONST_CALL_WITHOUT_GIL_1(cc::Client, GetInstanceTM, uint16_t), (arg("port")=TM_DEFAULT_PORT)) + rpc::OpendriveGenerationParameters), (arg("opendrive"), arg("parameters")=rpc::OpendriveGenerationParameters()), "@DocString(Client.generate_opendrive_world)") + .def("start_recorder", CALL_WITHOUT_GIL_1(cc::Client, StartRecorder, std::string), (arg("name")), "@DocString(Client.start_recorder)") + .def("stop_recorder", &cc::Client::StopRecorder, "@DocString(Client.stop_recorder)") + .def("show_recorder_file_info", CALL_WITHOUT_GIL_2(cc::Client, ShowRecorderFileInfo, std::string, bool), (arg("name"), arg("show_all")), "@DocString(Client.show_recorder_file_info)") + .def("show_recorder_collisions", CALL_WITHOUT_GIL_3(cc::Client, ShowRecorderCollisions, std::string, char, char), (arg("name"), arg("type1"), arg("type2")), "@DocString(Client.show_recorder_collisions)") + .def("show_recorder_actors_blocked", CALL_WITHOUT_GIL_3(cc::Client, ShowRecorderActorsBlocked, std::string, double, double), (arg("name"), arg("min_time"), arg("min_distance")), "@DocString(Client.show_recorder_actors_blocked)") + .def("replay_file", CALL_WITHOUT_GIL_4(cc::Client, ReplayFile, std::string, double, double, uint32_t), (arg("name"), arg("time_start"), arg("duration"), arg("follow_id")), "@DocString(Client.replay_file)") + .def("set_replayer_time_factor", &cc::Client::SetReplayerTimeFactor, (arg("time_factor")), "@DocString(Client.set_replayer_time_factor)") + .def("set_replayer_ignore_hero", &cc::Client::SetReplayerIgnoreHero, (arg("ignore_hero")), "@DocString(Client.set_replayer_ignore_hero)") + .def("apply_batch", &ApplyBatchCommands, (arg("commands"), arg("do_tick")=false), "@DocString(Client.apply_batch)") + .def("apply_batch_sync", &ApplyBatchCommandsSync, (arg("commands"), arg("do_tick")=false), "@DocString(Client.apply_batch_sync)") + .def("get_trafficmanager", CONST_CALL_WITHOUT_GIL_1(cc::Client, GetInstanceTM, uint16_t), (arg("port")=TM_DEFAULT_PORT), "@DocString(Client.get_trafficmanager)") ; } diff --git a/PythonAPI/carla/source/libcarla/Control.cpp b/PythonAPI/carla/source/libcarla/Control.cpp index c6af7568acf..9e4b1eb133c 100644 --- a/PythonAPI/carla/source/libcarla/Control.cpp +++ b/PythonAPI/carla/source/libcarla/Control.cpp @@ -274,16 +274,16 @@ void export_control() { arg("hand_brake") = false, arg("reverse") = false, arg("manual_gear_shift") = false, - arg("gear") = 0))) - .def_readwrite("throttle", &cr::VehicleControl::throttle) - .def_readwrite("steer", &cr::VehicleControl::steer) - .def_readwrite("brake", &cr::VehicleControl::brake) - .def_readwrite("hand_brake", &cr::VehicleControl::hand_brake) - .def_readwrite("reverse", &cr::VehicleControl::reverse) - .def_readwrite("manual_gear_shift", &cr::VehicleControl::manual_gear_shift) - .def_readwrite("gear", &cr::VehicleControl::gear) - .def("__eq__", &cr::VehicleControl::operator==) - .def("__ne__", &cr::VehicleControl::operator!=) + arg("gear") = 0), "@DocString(VehicleControl.__init__)")) + .def_readwrite("throttle", &cr::VehicleControl::throttle, "@DocString(VehicleControl.throttle)") + .def_readwrite("steer", &cr::VehicleControl::steer, "@DocString(VehicleControl.steer)") + .def_readwrite("brake", &cr::VehicleControl::brake, "@DocString(VehicleControl.brake)") + .def_readwrite("hand_brake", &cr::VehicleControl::hand_brake, "@DocString(VehicleControl.hand_brake)") + .def_readwrite("reverse", &cr::VehicleControl::reverse, "@DocString(VehicleControl.reverse)") + .def_readwrite("manual_gear_shift", &cr::VehicleControl::manual_gear_shift, "@DocString(VehicleControl.manual_gear_shift)") + .def_readwrite("gear", &cr::VehicleControl::gear, "@DocString(VehicleControl.gear)") + .def("__eq__", &cr::VehicleControl::operator==, "@DocString(VehicleControl.__eq__)") + .def("__ne__", &cr::VehicleControl::operator!=, "@DocString(VehicleControl.__ne__)") .def(self_ns::str(self_ns::self)) ; @@ -291,19 +291,19 @@ void export_control() { .def(init( (arg("direction") = cg::Vector3D{1.0f, 0.0f, 0.0f}, arg("speed") = 0.0f, - arg("jump") = false))) - .def_readwrite("direction", &cr::WalkerControl::direction) - .def_readwrite("speed", &cr::WalkerControl::speed) - .def_readwrite("jump", &cr::WalkerControl::jump) - .def("__eq__", &cr::WalkerControl::operator==) - .def("__ne__", &cr::WalkerControl::operator!=) + arg("jump") = false), "@DocString(WalkerControl.__init__)")) + .def_readwrite("direction", &cr::WalkerControl::direction, "@DocString(WalkerControl.direction)") + .def_readwrite("speed", &cr::WalkerControl::speed, "@DocString(WalkerControl.speed)") + .def_readwrite("jump", &cr::WalkerControl::jump, "@DocString(WalkerControl.jump)") + .def("__eq__", &cr::WalkerControl::operator==, "@DocString(WalkerControl.__eq__)") + .def("__ne__", &cr::WalkerControl::operator!=, "@DocString(WalkerControl.__ne__)") .def(self_ns::str(self_ns::self)) ; class_("WalkerBoneControl") - .def("__init__", raw_function(WalkerBoneControl_init)) + .def("__init__", raw_function(WalkerBoneControl_init), "@DocString(WalkerBoneControl.__init__)") .def(init<>()) - .add_property("bone_transforms", &GetBonesTransform, &SetBonesTransform) + .add_property("bone_transforms", &GetBonesTransform, &SetBonesTransform, "@DocString(WalkerBoneControl.bone_transforms)") .def(self_ns::str(self_ns::self)) ; @@ -316,12 +316,12 @@ void export_control() { .def(init( (arg("ratio")=1.0f, arg("down_ratio")=0.5f, - arg("up_ratio")=0.65f))) - .def_readwrite("ratio", &cr::GearPhysicsControl::ratio) - .def_readwrite("down_ratio", &cr::GearPhysicsControl::down_ratio) - .def_readwrite("up_ratio", &cr::GearPhysicsControl::up_ratio) - .def("__eq__", &cr::GearPhysicsControl::operator==) - .def("__ne__", &cr::GearPhysicsControl::operator!=) + arg("up_ratio")=0.65f), "@DocString(GearPhysicsControl.__init__)")) + .def_readwrite("ratio", &cr::GearPhysicsControl::ratio, "@DocString(GearPhysicsControl.ratio)") + .def_readwrite("down_ratio", &cr::GearPhysicsControl::down_ratio, "@DocString(GearPhysicsControl.down_ratio)") + .def_readwrite("up_ratio", &cr::GearPhysicsControl::up_ratio, "@DocString(GearPhysicsControl.up_ratio)") + .def("__eq__", &cr::GearPhysicsControl::operator==, "@DocString(GearPhysicsControl.__eq__)") + .def("__ne__", &cr::GearPhysicsControl::operator!=, "@DocString(GearPhysicsControl.__ne__)") .def(self_ns::str(self_ns::self)) ; @@ -338,43 +338,43 @@ void export_control() { arg("radius")=30.0f, arg("max_brake_torque")=1500.0f, arg("max_handbrake_torque")=3000.0f, - arg("position")=cg::Vector3D{0.0f, 0.0f, 0.0f}))) - .def_readwrite("tire_friction", &cr::WheelPhysicsControl::tire_friction) - .def_readwrite("damping_rate", &cr::WheelPhysicsControl::damping_rate) - .def_readwrite("max_steer_angle", &cr::WheelPhysicsControl::max_steer_angle) - .def_readwrite("radius", &cr::WheelPhysicsControl::radius) - .def_readwrite("max_brake_torque", &cr::WheelPhysicsControl::max_brake_torque) - .def_readwrite("max_handbrake_torque", &cr::WheelPhysicsControl::max_handbrake_torque) - .def_readwrite("position", &cr::WheelPhysicsControl::position) - .def("__eq__", &cr::WheelPhysicsControl::operator==) - .def("__ne__", &cr::WheelPhysicsControl::operator!=) + arg("position")=cg::Vector3D{0.0f, 0.0f, 0.0f}), "@DocString(WheelPhysicsControl.__init__)")) + .def_readwrite("tire_friction", &cr::WheelPhysicsControl::tire_friction, "@DocString(WheelPhysicsControl.tire_friction)") + .def_readwrite("damping_rate", &cr::WheelPhysicsControl::damping_rate, "@DocString(WheelPhysicsControl.damping_rate)") + .def_readwrite("max_steer_angle", &cr::WheelPhysicsControl::max_steer_angle, "@DocString(WheelPhysicsControl.max_steer_angle)") + .def_readwrite("radius", &cr::WheelPhysicsControl::radius, "@DocString(WheelPhysicsControl.radius)") + .def_readwrite("max_brake_torque", &cr::WheelPhysicsControl::max_brake_torque, "@DocString(WheelPhysicsControl.max_brake_torque)") + .def_readwrite("max_handbrake_torque", &cr::WheelPhysicsControl::max_handbrake_torque, "@DocString(WheelPhysicsControl.max_handbrake_torque)") + .def_readwrite("position", &cr::WheelPhysicsControl::position, "@DocString(WheelPhysicsControl.position)") + .def("__eq__", &cr::WheelPhysicsControl::operator==, "@DocString(WheelPhysicsControl.__eq__)") + .def("__ne__", &cr::WheelPhysicsControl::operator!=, "@DocString(WheelPhysicsControl.__ne__)") .def(self_ns::str(self_ns::self)) ; class_("VehiclePhysicsControl", no_init) - .def("__init__", raw_function(VehiclePhysicsControl_init)) + .def("__init__", raw_function(VehiclePhysicsControl_init), "@DocString(VehiclePhysicsControl.__init__)") .def(init<>()) - .add_property("torque_curve", &GetTorqueCurve, &SetTorqueCurve) - .def_readwrite("max_rpm", &cr::VehiclePhysicsControl::max_rpm) - .def_readwrite("moi", &cr::VehiclePhysicsControl::moi) + .add_property("torque_curve", &GetTorqueCurve, &SetTorqueCurve, "@DocString(VehiclePhysicsControl.torque_curve)") + .def_readwrite("max_rpm", &cr::VehiclePhysicsControl::max_rpm, "@DocString(VehiclePhysicsControl.max_rpm)") + .def_readwrite("moi", &cr::VehiclePhysicsControl::moi, "@DocString(VehiclePhysicsControl.moi)") .def_readwrite("damping_rate_full_throttle", - &cr::VehiclePhysicsControl::damping_rate_full_throttle) + &cr::VehiclePhysicsControl::damping_rate_full_throttle, "@DocString(VehiclePhysicsControl.damping_rate_full_throttle)") .def_readwrite("damping_rate_zero_throttle_clutch_engaged", - &cr::VehiclePhysicsControl::damping_rate_zero_throttle_clutch_engaged) + &cr::VehiclePhysicsControl::damping_rate_zero_throttle_clutch_engaged, "@DocString(VehiclePhysicsControl.damping_rate_zero_throttle_clutch_engaged)") .def_readwrite("damping_rate_zero_throttle_clutch_disengaged", - &cr::VehiclePhysicsControl::damping_rate_zero_throttle_clutch_disengaged) - .def_readwrite("use_gear_autobox", &cr::VehiclePhysicsControl::use_gear_autobox) - .def_readwrite("gear_switch_time", &cr::VehiclePhysicsControl::gear_switch_time) - .def_readwrite("clutch_strength", &cr::VehiclePhysicsControl::clutch_strength) - .def_readwrite("final_ratio", &cr::VehiclePhysicsControl::final_ratio) - .add_property("forward_gears", &GetForwardGears, &SetForwardGears) - .def_readwrite("mass", &cr::VehiclePhysicsControl::mass) - .def_readwrite("drag_coefficient", &cr::VehiclePhysicsControl::drag_coefficient) - .def_readwrite("center_of_mass", &cr::VehiclePhysicsControl::center_of_mass) - .add_property("steering_curve", &GetSteeringCurve, &SetSteeringCurve) - .add_property("wheels", &GetWheels, &SetWheels) - .def("__eq__", &cr::VehiclePhysicsControl::operator==) - .def("__ne__", &cr::VehiclePhysicsControl::operator!=) + &cr::VehiclePhysicsControl::damping_rate_zero_throttle_clutch_disengaged, "@DocString(VehiclePhysicsControl.damping_rate_zero_throttle_clutch_disengaged)") + .def_readwrite("use_gear_autobox", &cr::VehiclePhysicsControl::use_gear_autobox, "@DocString(VehiclePhysicsControl.use_gear_autobox)") + .def_readwrite("gear_switch_time", &cr::VehiclePhysicsControl::gear_switch_time, "@DocString(VehiclePhysicsControl.gear_switch_time)") + .def_readwrite("clutch_strength", &cr::VehiclePhysicsControl::clutch_strength, "@DocString(VehiclePhysicsControl.clutch_strength)") + .def_readwrite("final_ratio", &cr::VehiclePhysicsControl::final_ratio, "@DocString(VehiclePhysicsControl.final_ratio)") + .add_property("forward_gears", &GetForwardGears, &SetForwardGears, "@DocString(VehiclePhysicsControl.forward_gears)") + .def_readwrite("mass", &cr::VehiclePhysicsControl::mass, "@DocString(VehiclePhysicsControl.mass)") + .def_readwrite("drag_coefficient", &cr::VehiclePhysicsControl::drag_coefficient, "@DocString(VehiclePhysicsControl.drag_coefficient)") + .def_readwrite("center_of_mass", &cr::VehiclePhysicsControl::center_of_mass, "@DocString(VehiclePhysicsControl.center_of_mass)") + .add_property("steering_curve", &GetSteeringCurve, &SetSteeringCurve, "@DocString(VehiclePhysicsControl.steering_curve)") + .add_property("wheels", &GetWheels, &SetWheels, "@DocString(VehiclePhysicsControl.wheels)") + .def("__eq__", &cr::VehiclePhysicsControl::operator==, "@DocString(VehiclePhysicsControl.__eq__)") + .def("__ne__", &cr::VehiclePhysicsControl::operator!=, "@DocString(VehiclePhysicsControl.__ne__)") .def(self_ns::str(self_ns::self)) ; } diff --git a/PythonAPI/carla/source/libcarla/Geom.cpp b/PythonAPI/carla/source/libcarla/Geom.cpp index c516637e5ba..5b26473e900 100644 --- a/PythonAPI/carla/source/libcarla/Geom.cpp +++ b/PythonAPI/carla/source/libcarla/Geom.cpp @@ -95,11 +95,11 @@ void export_geom() { ; class_("Vector2D") - .def(init((arg("x")=0.0f, arg("y")=0.0f))) - .def_readwrite("x", &cg::Vector2D::x) - .def_readwrite("y", &cg::Vector2D::y) - .def("__eq__", &cg::Vector2D::operator==) - .def("__ne__", &cg::Vector2D::operator!=) + .def(init((arg("x")=0.0f, arg("y")=0.0f), "@DocString(Vector2D.__init__)")) + .def_readwrite("x", &cg::Vector2D::x, "@DocString(Vector2D.x)") + .def_readwrite("y", &cg::Vector2D::y, "@DocString(Vector2D.y)") + .def("__eq__", &cg::Vector2D::operator==, "@DocString(Vector2D.__eq__)") + .def("__ne__", &cg::Vector2D::operator!=, "@DocString(Vector2D.__ne__)") .def(self += self) .def(self + self) .def(self -= self) @@ -117,13 +117,13 @@ void export_geom() { implicitly_convertible(); class_("Vector3D") - .def(init((arg("x")=0.0f, arg("y")=0.0f, arg("z")=0.0f))) - .def(init((arg("rhs")))) - .def_readwrite("x", &cg::Vector3D::x) - .def_readwrite("y", &cg::Vector3D::y) - .def_readwrite("z", &cg::Vector3D::z) - .def("__eq__", &cg::Vector3D::operator==) - .def("__ne__", &cg::Vector3D::operator!=) + .def(init((arg("x")=0.0f, arg("y")=0.0f, arg("z")=0.0f), "@DocString(Vector2D.__init__)")) + .def(init((arg("rhs")), "@DocString(Vector2D.__init__)")) + .def_readwrite("x", &cg::Vector3D::x, "@DocString(Vector2D.x)") + .def_readwrite("y", &cg::Vector3D::y, "@DocString(Vector2D.y)") + .def_readwrite("z", &cg::Vector3D::z, "@DocString(Vector2D.z)") + .def("__eq__", &cg::Vector3D::operator==, "@DocString(Vector2D.__eq__)") + .def("__ne__", &cg::Vector3D::operator!=, "@DocString(Vector2D.__ne__)") .def(self += self) .def(self + self) .def(self -= self) @@ -138,41 +138,41 @@ void export_geom() { ; class_>("Location") - .def(init((arg("x")=0.0f, arg("y")=0.0f, arg("z")=0.0f))) - .def(init((arg("rhs")))) - .add_property("x", +[](const cg::Location &self) { return self.x; }, +[](cg::Location &self, float x) { self.x = x; }) - .add_property("y", +[](const cg::Location &self) { return self.y; }, +[](cg::Location &self, float y) { self.y = y; }) - .add_property("z", +[](const cg::Location &self) { return self.z; }, +[](cg::Location &self, float z) { self.z = z; }) - .def("distance", &cg::Location::Distance, (arg("location"))) - .def("__eq__", &cg::Location::operator==) - .def("__ne__", &cg::Location::operator!=) + .def(init((arg("x")=0.0f, arg("y")=0.0f, arg("z")=0.0f), "@DocString(Location.__init__)")) + .def(init((arg("rhs")), "@DocString(Location.__init__)")) + .add_property("x", +[](const cg::Location &self) { return self.x; }, +[](cg::Location &self, float x) { self.x = x; }, "@DocString(Location.x)") + .add_property("y", +[](const cg::Location &self) { return self.y; }, +[](cg::Location &self, float y) { self.y = y; }, "@DocString(Location.y)") + .add_property("z", +[](const cg::Location &self) { return self.z; }, +[](cg::Location &self, float z) { self.z = z; }, "@DocString(Location.z)") + .def("distance", &cg::Location::Distance, (arg("location")), "@DocString(Location.distance)") + .def("__eq__", &cg::Location::operator==, "@DocString(Location.__eq__)") + .def("__ne__", &cg::Location::operator!=, "@DocString(Location.__ne__)") .def(self_ns::str(self_ns::self)) ; class_("Rotation") - .def(init((arg("pitch")=0.0f, arg("yaw")=0.0f, arg("roll")=0.0f))) - .def_readwrite("pitch", &cg::Rotation::pitch) - .def_readwrite("yaw", &cg::Rotation::yaw) - .def_readwrite("roll", &cg::Rotation::roll) - .def("get_forward_vector", &cg::Rotation::GetForwardVector) - .def("__eq__", &cg::Rotation::operator==) - .def("__ne__", &cg::Rotation::operator!=) + .def(init((arg("pitch")=0.0f, arg("yaw")=0.0f, arg("roll")=0.0f), "@DocString(Rotation.__init__)")) + .def_readwrite("pitch", &cg::Rotation::pitch, "@DocString(Rotation.pitch)") + .def_readwrite("yaw", &cg::Rotation::yaw, "@DocString(Rotation.yaw)") + .def_readwrite("roll", &cg::Rotation::roll, "@DocString(Rotation.roll)") + .def("get_forward_vector", &cg::Rotation::GetForwardVector, "@DocString(Rotation.get_forward_vector)") + .def("__eq__", &cg::Rotation::operator==, "@DocString(Rotation.__eq__)") + .def("__ne__", &cg::Rotation::operator!=, "@DocString(Rotation.__ne__)") .def(self_ns::str(self_ns::self)) ; class_("Transform") .def(init( - (arg("location")=cg::Location(), arg("rotation")=cg::Rotation()))) - .def_readwrite("location", &cg::Transform::location) - .def_readwrite("rotation", &cg::Transform::rotation) - .def("transform", &TransformList) + (arg("location")=cg::Location(), arg("rotation")=cg::Rotation()), "@DocString(Transform.__init__)")) + .def_readwrite("location", &cg::Transform::location, "@DocString(Transform.location)") + .def_readwrite("rotation", &cg::Transform::rotation, "@DocString(Transform.rotation)") + .def("transform", &TransformList, "@DocString(Transform.transform)") .def("transform", +[](const cg::Transform &self, cg::Vector3D &location) { self.TransformPoint(location); return location; - }, arg("in_point")) - .def("get_forward_vector", &cg::Transform::GetForwardVector) - .def("__eq__", &cg::Transform::operator==) - .def("__ne__", &cg::Transform::operator!=) + }, arg("in_point"), "@DocString(Transform.transform)") + .def("get_forward_vector", &cg::Transform::GetForwardVector, "@DocString(Transform.get_forward_vector)") + .def("__eq__", &cg::Transform::operator==, "@DocString(Transform.__eq__)") + .def("__ne__", &cg::Transform::operator!=, "@DocString(Transform.__ne__)") .def(self_ns::str(self_ns::self)) ; @@ -183,24 +183,24 @@ void export_geom() { class_("BoundingBox") .def(init( - (arg("location")=cg::Location(), arg("extent")=cg::Vector3D()))) - .def_readwrite("location", &cg::BoundingBox::location) - .def_readwrite("extent", &cg::BoundingBox::extent) - .def("contains", &cg::BoundingBox::Contains, arg("point"), arg("bbox_transform")) - .def("get_local_vertices", CALL_RETURNING_LIST(cg::BoundingBox, GetLocalVertices)) - .def("get_world_vertices", CALL_RETURNING_LIST_1(cg::BoundingBox, GetWorldVertices, const cg::Transform&), arg("bbox_transform")) - .def("__eq__", &cg::BoundingBox::operator==) - .def("__ne__", &cg::BoundingBox::operator!=) + (arg("location")=cg::Location(), arg("extent")=cg::Vector3D()), "@DocString(BoundingBox.__init__)")) + .def_readwrite("location", &cg::BoundingBox::location, "@DocString(BoundingBox.location)") + .def_readwrite("extent", &cg::BoundingBox::extent, "@DocString(BoundingBox.extent)") + .def("contains", &cg::BoundingBox::Contains, arg("point"), arg("bbox_transform"), "@DocString(BoundingBox.contains)") + .def("get_local_vertices", CALL_RETURNING_LIST(cg::BoundingBox, GetLocalVertices), "@DocString(BoundingBox.get_local_vertices)") + .def("get_world_vertices", CALL_RETURNING_LIST_1(cg::BoundingBox, GetWorldVertices, const cg::Transform&), arg("bbox_transform"), "@DocString(BoundingBox.get_world_vertices)") + .def("__eq__", &cg::BoundingBox::operator==, "@DocString(BoundingBox.__eq__)") + .def("__ne__", &cg::BoundingBox::operator!=, "@DocString(BoundingBox.__ne__)") .def(self_ns::str(self_ns::self)) ; class_("GeoLocation") - .def(init((arg("latitude")=0.0, arg("longitude")=0.0, arg("altitude")=0.0))) - .def_readwrite("latitude", &cg::GeoLocation::latitude) - .def_readwrite("longitude", &cg::GeoLocation::longitude) - .def_readwrite("altitude", &cg::GeoLocation::altitude) - .def("__eq__", &cg::GeoLocation::operator==) - .def("__ne__", &cg::GeoLocation::operator!=) + .def(init((arg("latitude")=0.0, arg("longitude")=0.0, arg("altitude")=0.0), "@DocString(GeoLocation.__init__)")) + .def_readwrite("latitude", &cg::GeoLocation::latitude, "@DocString(GeoLocation.latitude)") + .def_readwrite("longitude", &cg::GeoLocation::longitude, "@DocString(GeoLocation.longitude)") + .def_readwrite("altitude", &cg::GeoLocation::altitude, "@DocString(GeoLocation.altitude)") + .def("__eq__", &cg::GeoLocation::operator==, "@DocString(GeoLocation.__eq__)") + .def("__ne__", &cg::GeoLocation::operator!=, "@DocString(GeoLocation.__ne__)") .def(self_ns::str(self_ns::self)) ; } diff --git a/PythonAPI/carla/source/libcarla/LightManager.cpp b/PythonAPI/carla/source/libcarla/LightManager.cpp index 887572a76f4..ba7aaf3c252 100644 --- a/PythonAPI/carla/source/libcarla/LightManager.cpp +++ b/PythonAPI/carla/source/libcarla/LightManager.cpp @@ -302,49 +302,49 @@ void export_lightmanager() { ; class_("LightState") - .def(init((arg("intensity")=0.0f, arg("color")=csd::Color(), arg("group")=cr::LightState::LightGroup::None, arg("active")=false ))) - .def_readwrite("intensity", &cc::LightState::_intensity) - .def_readwrite("color", &cc::LightState::_color) - .def_readwrite("group", &cc::LightState::_group) - .def_readwrite("active", &cc::LightState::_active) + .def(init((arg("intensity")=0.0f, arg("color")=csd::Color(), arg("group")=cr::LightState::LightGroup::None, arg("active")=false ), "@DocString(LightState.__init__)")) + .def_readwrite("intensity", &cc::LightState::_intensity, "@DocString(LightState.intensity)") + .def_readwrite("color", &cc::LightState::_color, "@DocString(LightState.color)") + .def_readwrite("group", &cc::LightState::_group, "@DocString(LightState.group)") + .def_readwrite("active", &cc::LightState::_active, "@DocString(LightState.active)") ; class_>("Light", no_init) - .add_property("color", &cc::Light::GetColor) - .add_property("id", &cc::Light::GetId) - .add_property("intensity", &cc::Light::GetIntensity) - .add_property("is_on", &cc::Light::IsOn) - .add_property("location", &cc::Light::GetLocation) - .add_property("light_group", &cc::Light::GetLightGroup) - .add_property("light_state", &cc::Light::GetLightState) - .def("set_color", &cc::Light::SetColor, (arg("color"))) - .def("set_intensity", &cc::Light::SetIntensity, (arg("intensity"))) - .def("set_light_group", &cc::Light::SetLightGroup, (arg("light_group"))) - .def("set_light_state", &cc::Light::SetLightState, (arg("light_state"))) - .def("turn_on", &cc::Light::TurnOn) - .def("turn_off", &cc::Light::TurnOff) + .add_property("color", &cc::Light::GetColor, "@DocString(Light.color)") + .add_property("id", &cc::Light::GetId, "@DocString(Light.id)") + .add_property("intensity", &cc::Light::GetIntensity, "@DocString(Light.intensity)") + .add_property("is_on", &cc::Light::IsOn, "@DocString(Light.is_on)") + .add_property("location", &cc::Light::GetLocation, "@DocString(Light.location)") + .add_property("light_group", &cc::Light::GetLightGroup, "@DocString(Light.light_group)") + .add_property("light_state", &cc::Light::GetLightState, "@DocString(Light.light_state)") + .def("set_color", &cc::Light::SetColor, (arg("color")), "@DocString(Light.set_color)") + .def("set_intensity", &cc::Light::SetIntensity, (arg("intensity")), "@DocString(Light.set_intensity)") + .def("set_light_group", &cc::Light::SetLightGroup, (arg("light_group")), "@DocString(Light.set_light_group)") + .def("set_light_state", &cc::Light::SetLightState, (arg("light_state")), "@DocString(Light.set_light_state)") + .def("turn_on", &cc::Light::TurnOn, "@DocString(Light.turn_on)") + .def("turn_off", &cc::Light::TurnOff, "@DocString(Light.turn_off)") ; class_>("LightManager", no_init) - .def("get_all_lights", CALL_RETURNING_LIST_1(cc::LightManager, GetAllLights, cr::LightState::LightGroup), (args("light_group") = cr::LightState::LightGroup::None )) - .def("turn_on", &LightManagerTurnOn, (arg("lights"))) - .def("turn_off", &LightManagerTurnOff, (arg("lights"))) - .def("set_active", &LightManagerSetActive, (arg("lights"), arg("active"))) - .def("is_active", &LightManagerIsActive, (arg("lights"))) - .def("get_turned_on_lights", CALL_RETURNING_LIST_1(cc::LightManager, GetTurnedOnLights, cr::LightState::LightGroup), (args("light_group") = cr::LightState::LightGroup::None )) - .def("get_turned_off_lights", CALL_RETURNING_LIST_1(cc::LightManager, GetTurnedOffLights, cr::LightState::LightGroup), (args("light_group") = cr::LightState::LightGroup::None )) - .def("set_color", &LightManagerSetColor, (arg("lights"), arg("color"))) - .def("set_colors", &LightManagerSetVectorColor, (arg("lights"), arg("colors"))) - .def("get_color", &LightManagerGetColor, (arg("lights"))) - .def("set_intensity", &LightManagerSetIntensity, (arg("lights"), arg("intensity"))) - .def("set_intensities", &LightManagerSetVectorIntensity, (arg("lights"), arg("intensities"))) - .def("get_intensity", &LightManagerGetIntensity, (arg("lights"))) - .def("set_light_group", &LightManagerSetLightGroup, (arg("lights"), arg("light_group"))) - .def("set_light_groups", &LightManagerSetVectorLightGroup, (arg("lights"), arg("light_groups"))) - .def("get_light_group", &LightManagerGetLightGroup, (arg("lights"))) - .def("set_light_state", &LightManagerSetLightState, (arg("lights"), arg("light_state"))) - .def("set_light_states", &LightManagerSetVectorLightState, (arg("lights"), arg("light_states"))) - .def("get_light_state", &LightManagerGetLightState, (arg("lights"))) + .def("get_all_lights", CALL_RETURNING_LIST_1(cc::LightManager, GetAllLights, cr::LightState::LightGroup), (args("light_group") = cr::LightState::LightGroup::None ), "@DocString(LightManager.get_all_lights)") + .def("turn_on", &LightManagerTurnOn, (arg("lights")), "@DocString(LightManager.turn_on)") + .def("turn_off", &LightManagerTurnOff, (arg("lights")), "@DocString(LightManager.turn_off)") + .def("set_active", &LightManagerSetActive, (arg("lights"), arg("active")), "@DocString(LightManager.set_active)") + .def("is_active", &LightManagerIsActive, (arg("lights")), "@DocString(LightManager.is_active)") + .def("get_turned_on_lights", CALL_RETURNING_LIST_1(cc::LightManager, GetTurnedOnLights, cr::LightState::LightGroup), (args("light_group") = cr::LightState::LightGroup::None ), "@DocString(LightManager.get_turned_on_lights)") + .def("get_turned_off_lights", CALL_RETURNING_LIST_1(cc::LightManager, GetTurnedOffLights, cr::LightState::LightGroup), (args("light_group") = cr::LightState::LightGroup::None ), "@DocString(LightManager.get_turned_off_lights)") + .def("set_color", &LightManagerSetColor, (arg("lights"), arg("color")), "@DocString(LightManager.set_color)") + .def("set_colors", &LightManagerSetVectorColor, (arg("lights"), arg("colors")), "@DocString(LightManager.set_colors)") + .def("get_color", &LightManagerGetColor, (arg("lights")), "@DocString(LightManager.get_color)") + .def("set_intensity", &LightManagerSetIntensity, (arg("lights"), arg("intensity")), "@DocString(LightManager.set_intensity)") + .def("set_intensities", &LightManagerSetVectorIntensity, (arg("lights"), arg("intensities")), "@DocString(LightManager.set_intensities)") + .def("get_intensity", &LightManagerGetIntensity, (arg("lights")), "@DocString(LightManager.get_intensity)") + .def("set_light_group", &LightManagerSetLightGroup, (arg("lights"), arg("light_group")), "@DocString(LightManager.set_light_group)") + .def("set_light_groups", &LightManagerSetVectorLightGroup, (arg("lights"), arg("light_groups")), "@DocString(LightManager.set_light_groups)") + .def("get_light_group", &LightManagerGetLightGroup, (arg("lights")), "@DocString(LightManager.get_light_group)") + .def("set_light_state", &LightManagerSetLightState, (arg("lights"), arg("light_state")), "@DocString(LightManager.set_light_state)") + .def("set_light_states", &LightManagerSetVectorLightState, (arg("lights"), arg("light_states")), "@DocString(LightManager.set_light_states)") + .def("get_light_state", &LightManagerGetLightState, (arg("lights")), "@DocString(LightManager.get_light_state)") ; } diff --git a/PythonAPI/carla/source/libcarla/Map.cpp b/PythonAPI/carla/source/libcarla/Map.cpp index f07073a646e..5092bcc736d 100644 --- a/PythonAPI/carla/source/libcarla/Map.cpp +++ b/PythonAPI/carla/source/libcarla/Map.cpp @@ -155,21 +155,21 @@ void export_map() { // =========================================================================== class_>("Map", no_init) - .def(init((arg("name"), arg("xodr_content")))) - .add_property("name", CALL_RETURNING_COPY(cc::Map, GetName)) - .def("get_spawn_points", CALL_RETURNING_LIST(cc::Map, GetRecommendedSpawnPoints)) - .def("get_waypoint", &cc::Map::GetWaypoint, (arg("location"), arg("project_to_road")=true, arg("lane_type")=cr::Lane::LaneType::Driving)) - .def("get_waypoint_xodr", &cc::Map::GetWaypointXODR, (arg("road_id"), arg("lane_id"), arg("s"))) - .def("get_topology", &GetTopology) - .def("generate_waypoints", CALL_RETURNING_LIST_1(cc::Map, GenerateWaypoints, double), (args("distance"))) - .def("transform_to_geolocation", &ToGeolocation, (arg("location"))) - .def("to_opendrive", CALL_RETURNING_COPY(cc::Map, GetOpenDrive)) - .def("save_to_disk", &SaveOpenDriveToDisk, (arg("path")="")) - .def("get_crosswalks", CALL_RETURNING_LIST(cc::Map, GetAllCrosswalkZones)) - .def("get_all_landmarks", CALL_RETURNING_LIST(cc::Map, GetAllLandmarks)) - .def("get_all_landmarks_from_id", CALL_RETURNING_LIST_1(cc::Map, GetLandmarksFromId, std::string), (args("opendrive_id"))) - .def("get_all_landmarks_of_type", CALL_RETURNING_LIST_1(cc::Map, GetAllLandmarksOfType, std::string), (args("type"))) - .def("get_landmark_group", CALL_RETURNING_LIST_1(cc::Map, GetLandmarkGroup, cc::Landmark), args("landmark")) + .def(init((arg("name"), arg("xodr_content")), "@DocString(Map.__init__)")) + .add_property("name", CALL_RETURNING_COPY(cc::Map, GetName), "@DocString(Map.name)") + .def("get_spawn_points", CALL_RETURNING_LIST(cc::Map, GetRecommendedSpawnPoints), "@DocString(Map.get_spawn_points)") + .def("get_waypoint", &cc::Map::GetWaypoint, (arg("location"), arg("project_to_road")=true, arg("lane_type")=cr::Lane::LaneType::Driving), "@DocString(Map.get_waypoint)") + .def("get_waypoint_xodr", &cc::Map::GetWaypointXODR, (arg("road_id"), arg("lane_id"), arg("s")), "@DocString(Map.get_waypoint_xodr)") + .def("get_topology", &GetTopology, "@DocString(Map.get_topology)") + .def("generate_waypoints", CALL_RETURNING_LIST_1(cc::Map, GenerateWaypoints, double), (args("distance")), "@DocString(Map.generate_waypoints)") + .def("transform_to_geolocation", &ToGeolocation, (arg("location")), "@DocString(Map.transform_to_geolocation)") + .def("to_opendrive", CALL_RETURNING_COPY(cc::Map, GetOpenDrive), "@DocString(Map.to_opendrive)") + .def("save_to_disk", &SaveOpenDriveToDisk, (arg("path")=""), "@DocString(Map.save_to_disk)") + .def("get_crosswalks", CALL_RETURNING_LIST(cc::Map, GetAllCrosswalkZones), "@DocString(Map.get_crosswalks)") + .def("get_all_landmarks", CALL_RETURNING_LIST(cc::Map, GetAllLandmarks), "@DocString(Map.get_all_landmarks)") + .def("get_all_landmarks_from_id", CALL_RETURNING_LIST_1(cc::Map, GetLandmarksFromId, std::string), (args("opendrive_id")), "@DocString(Map.get_all_landmarks_from_id)") + .def("get_all_landmarks_of_type", CALL_RETURNING_LIST_1(cc::Map, GetAllLandmarksOfType, std::string), (args("type")), "@DocString(Map.get_all_landmarks_of_type)") + .def("get_landmark_group", CALL_RETURNING_LIST_1(cc::Map, GetLandmarkGroup, cc::Landmark), args("landmark"), "@DocString(Map.get_landmark_group)") .def(self_ns::str(self_ns::self)) ; @@ -178,106 +178,106 @@ void export_map() { // =========================================================================== class_("LaneMarking", no_init) - .add_property("type", &cre::LaneMarking::type) - .add_property("color", &cre::LaneMarking::color) - .add_property("lane_change", &cre::LaneMarking::lane_change) - .add_property("width", &cre::LaneMarking::width) + .add_property("type", &cre::LaneMarking::type, "@DocString(LaneMarking.type)") + .add_property("color", &cre::LaneMarking::color, "@DocString(LaneMarking.color)") + .add_property("lane_change", &cre::LaneMarking::lane_change, "@DocString(LaneMarking.lane_change)") + .add_property("width", &cre::LaneMarking::width, "@DocString(LaneMarking.width)") ; class_>("Waypoint", no_init) - .add_property("id", &cc::Waypoint::GetId) - .add_property("transform", CALL_RETURNING_COPY(cc::Waypoint, GetTransform)) - .add_property("is_intersection", &cc::Waypoint::IsJunction) // deprecated - .add_property("is_junction", &cc::Waypoint::IsJunction) - .add_property("lane_width", &cc::Waypoint::GetLaneWidth) - .add_property("road_id", &cc::Waypoint::GetRoadId) - .add_property("section_id", &cc::Waypoint::GetSectionId) - .add_property("lane_id", &cc::Waypoint::GetLaneId) - .add_property("s", &cc::Waypoint::GetDistance) - .add_property("junction_id", &cc::Waypoint::GetJunctionId) - .add_property("lane_change", &cc::Waypoint::GetLaneChange) - .add_property("lane_type", &cc::Waypoint::GetType) - .add_property("right_lane_marking", CALL_RETURNING_OPTIONAL(cc::Waypoint, GetRightLaneMarking)) - .add_property("left_lane_marking", CALL_RETURNING_OPTIONAL(cc::Waypoint, GetLeftLaneMarking)) - .def("next", CALL_RETURNING_LIST_1(cc::Waypoint, GetNext, double), (args("distance"))) - .def("previous", CALL_RETURNING_LIST_1(cc::Waypoint, GetPrevious, double), (args("distance"))) - .def("next_until_lane_end", CALL_RETURNING_LIST_1(cc::Waypoint, GetNextUntilLaneEnd, double), (args("distance"))) - .def("previous_until_lane_start", CALL_RETURNING_LIST_1(cc::Waypoint, GetPreviousUntilLaneStart, double), (args("distance", "stop_at_junction"))) - .def("get_right_lane", &cc::Waypoint::GetRight) - .def("get_left_lane", &cc::Waypoint::GetLeft) - .def("get_junction", &cc::Waypoint::GetJunction) - .def("get_landmarks", CALL_RETURNING_LIST_2(cc::Waypoint, GetAllLandmakrsInDistance, double, bool), (arg("distance"), arg("stop_at_junction")=false)) - .def("get_landmarks_of_type", CALL_RETURNING_LIST_3(cc::Waypoint, GetLandmakrsOfTypeInDistance, double, std::string, bool), (arg("distance"), arg("type"), arg("stop_at_junction")=false)) + .add_property("id", &cc::Waypoint::GetId, "@DocString(Waypoint.id)") + .add_property("transform", CALL_RETURNING_COPY(cc::Waypoint, GetTransform), "@DocString(Waypoint.transform)") + .add_property("is_intersection", &cc::Waypoint::IsJunction, "@DocString(Waypoint.is_intersection)") // deprecated + .add_property("is_junction", &cc::Waypoint::IsJunction, "@DocString(Waypoint.is_junction)") + .add_property("lane_width", &cc::Waypoint::GetLaneWidth, "@DocString(Waypoint.lane_width)") + .add_property("road_id", &cc::Waypoint::GetRoadId, "@DocString(Waypoint.road_id)") + .add_property("section_id", &cc::Waypoint::GetSectionId, "@DocString(Waypoint.section_id)") + .add_property("lane_id", &cc::Waypoint::GetLaneId, "@DocString(Waypoint.lane_id)") + .add_property("s", &cc::Waypoint::GetDistance, "@DocString(Waypoint.s)") + .add_property("junction_id", &cc::Waypoint::GetJunctionId, "@DocString(Waypoint.junction_id)") + .add_property("lane_change", &cc::Waypoint::GetLaneChange, "@DocString(Waypoint.lane_change)") + .add_property("lane_type", &cc::Waypoint::GetType, "@DocString(Waypoint.lane_type)") + .add_property("right_lane_marking", CALL_RETURNING_OPTIONAL(cc::Waypoint, GetRightLaneMarking), "@DocString(Waypoint.right_lane_marking)") + .add_property("left_lane_marking", CALL_RETURNING_OPTIONAL(cc::Waypoint, GetLeftLaneMarking), "@DocString(Waypoint.left_lane_marking)") + .def("next", CALL_RETURNING_LIST_1(cc::Waypoint, GetNext, double), (args("distance")), "@DocString(Waypoint.next)") + .def("previous", CALL_RETURNING_LIST_1(cc::Waypoint, GetPrevious, double), (args("distance")), "@DocString(Waypoint.previous)") + .def("next_until_lane_end", CALL_RETURNING_LIST_1(cc::Waypoint, GetNextUntilLaneEnd, double), (args("distance")), "@DocString(Waypoint.next_until_lane_end)") + .def("previous_until_lane_start", CALL_RETURNING_LIST_1(cc::Waypoint, GetPreviousUntilLaneStart, double), (args("distance", "stop_at_junction")), "@DocString(Waypoint.previous_until_lane_start)") + .def("get_right_lane", &cc::Waypoint::GetRight, "@DocString(Waypoint.get_right_lane)") + .def("get_left_lane", &cc::Waypoint::GetLeft, "@DocString(Waypoint.get_left_lane)") + .def("get_junction", &cc::Waypoint::GetJunction, "@DocString(Waypoint.get_junction)") + .def("get_landmarks", CALL_RETURNING_LIST_2(cc::Waypoint, GetAllLandmakrsInDistance, double, bool), (arg("distance"), arg("stop_at_junction")=false), "@DocString(Waypoint.get_landmarks)") + .def("get_landmarks_of_type", CALL_RETURNING_LIST_3(cc::Waypoint, GetLandmakrsOfTypeInDistance, double, std::string, bool), (arg("distance"), arg("type"), arg("stop_at_junction")=false), "@DocString(Waypoint.get_landmarks_of_type)") .def(self_ns::str(self_ns::self)) ; class_>("Junction", no_init) - .add_property("id", &cc::Junction::GetId) - .add_property("bounding_box", &cc::Junction::GetBoundingBox) - .def("get_waypoints", &GetJunctionWaypoints) + .add_property("id", &cc::Junction::GetId, "@DocString(Junction.id)") + .add_property("bounding_box", &cc::Junction::GetBoundingBox, "@DocString(Junction.bounding_box)") + .def("get_waypoints", &GetJunctionWaypoints, "@DocString(Junction.get_waypoints)") ; class_("LandmarkType", no_init) - .add_static_property("Danger", &cr::SignalType::Danger) - .add_static_property("LanesMerging", &cr::SignalType::LanesMerging) - .add_static_property("CautionPedestrian", &cr::SignalType::CautionPedestrian) - .add_static_property("CautionBicycle", &cr::SignalType::CautionBicycle) - .add_static_property("LevelCrossing", &cr::SignalType::LevelCrossing) - .add_static_property("StopSign", &cr::SignalType::StopSign) - .add_static_property("YieldSign", &cr::SignalType::YieldSign) - .add_static_property("MandatoryTurnDirection", &cr::SignalType::MandatoryTurnDirection) - .add_static_property("MandatoryLeftRightDirection", &cr::SignalType::MandatoryLeftRightDirection) - .add_static_property("TwoChoiceTurnDirection", &cr::SignalType::TwoChoiceTurnDirection) - .add_static_property("Roundabout", &cr::SignalType::Roundabout) - .add_static_property("PassRightLeft", &cr::SignalType::PassRightLeft) - .add_static_property("AccessForbidden", &cr::SignalType::AccessForbidden) - .add_static_property("AccessForbiddenMotorvehicles", &cr::SignalType::AccessForbiddenMotorvehicles) - .add_static_property("AccessForbiddenTrucks", &cr::SignalType::AccessForbiddenTrucks) - .add_static_property("AccessForbiddenBicycle", &cr::SignalType::AccessForbiddenBicycle) - .add_static_property("AccessForbiddenWeight", &cr::SignalType::AccessForbiddenWeight) - .add_static_property("AccessForbiddenWidth", &cr::SignalType::AccessForbiddenWidth) - .add_static_property("AccessForbiddenHeight", &cr::SignalType::AccessForbiddenHeight) - .add_static_property("AccessForbiddenWrongDirection", &cr::SignalType::AccessForbiddenWrongDirection) - .add_static_property("ForbiddenUTurn", &cr::SignalType::ForbiddenUTurn) - .add_static_property("MaximumSpeed", &cr::SignalType::MaximumSpeed) - .add_static_property("ForbiddenOvertakingMotorvehicles", &cr::SignalType::ForbiddenOvertakingMotorvehicles) - .add_static_property("ForbiddenOvertakingTrucks", &cr::SignalType::ForbiddenOvertakingTrucks) - .add_static_property("AbsoluteNoStop", &cr::SignalType::AbsoluteNoStop) - .add_static_property("RestrictedStop", &cr::SignalType::RestrictedStop) - .add_static_property("HasWayNextIntersection", &cr::SignalType::HasWayNextIntersection) - .add_static_property("PriorityWay", &cr::SignalType::PriorityWay) - .add_static_property("PriorityWayEnd", &cr::SignalType::PriorityWayEnd) - .add_static_property("CityBegin", &cr::SignalType::CityBegin) - .add_static_property("CityEnd", &cr::SignalType::CityEnd) - .add_static_property("Highway", &cr::SignalType::Highway) - .add_static_property("DeadEnd", &cr::SignalType::DeadEnd) - .add_static_property("RecomendedSpeed", &cr::SignalType::RecomendedSpeed) - .add_static_property("RecomendedSpeedEnd", &cr::SignalType::RecomendedSpeedEnd) + .add_static_property("Danger", &cr::SignalType::Danger, "@DocString(LandmarkType.Danger)") + .add_static_property("LanesMerging", &cr::SignalType::LanesMerging, "@DocString(LandmarkType.LanesMerging)") + .add_static_property("CautionPedestrian", &cr::SignalType::CautionPedestrian, "@DocString(LandmarkType.CautionPedestrian)") + .add_static_property("CautionBicycle", &cr::SignalType::CautionBicycle, "@DocString(LandmarkType.CautionBicycle)") + .add_static_property("LevelCrossing", &cr::SignalType::LevelCrossing, "@DocString(LandmarkType.LevelCrossing)") + .add_static_property("StopSign", &cr::SignalType::StopSign, "@DocString(LandmarkType.StopSign)") + .add_static_property("YieldSign", &cr::SignalType::YieldSign, "@DocString(LandmarkType.YieldSign)") + .add_static_property("MandatoryTurnDirection", &cr::SignalType::MandatoryTurnDirection, "@DocString(LandmarkType.MandatoryTurnDirection)") + .add_static_property("MandatoryLeftRightDirection", &cr::SignalType::MandatoryLeftRightDirection, "@DocString(LandmarkType.MandatoryLeftRightDirection)") + .add_static_property("TwoChoiceTurnDirection", &cr::SignalType::TwoChoiceTurnDirection, "@DocString(LandmarkType.TwoChoiceTurnDirection)") + .add_static_property("Roundabout", &cr::SignalType::Roundabout, "@DocString(LandmarkType.Roundabout)") + .add_static_property("PassRightLeft", &cr::SignalType::PassRightLeft, "@DocString(LandmarkType.PassRightLeft)") + .add_static_property("AccessForbidden", &cr::SignalType::AccessForbidden, "@DocString(LandmarkType.AccessForbidden)") + .add_static_property("AccessForbiddenMotorvehicles", &cr::SignalType::AccessForbiddenMotorvehicles, "@DocString(LandmarkType.AccessForbiddenMotorvehicles)") + .add_static_property("AccessForbiddenTrucks", &cr::SignalType::AccessForbiddenTrucks, "@DocString(LandmarkType.AccessForbiddenTrucks)") + .add_static_property("AccessForbiddenBicycle", &cr::SignalType::AccessForbiddenBicycle, "@DocString(LandmarkType.AccessForbiddenBicycle)") + .add_static_property("AccessForbiddenWeight", &cr::SignalType::AccessForbiddenWeight, "@DocString(LandmarkType.AccessForbiddenWeight)") + .add_static_property("AccessForbiddenWidth", &cr::SignalType::AccessForbiddenWidth, "@DocString(LandmarkType.AccessForbiddenWidth)") + .add_static_property("AccessForbiddenHeight", &cr::SignalType::AccessForbiddenHeight, "@DocString(LandmarkType.AccessForbiddenHeight)") + .add_static_property("AccessForbiddenWrongDirection", &cr::SignalType::AccessForbiddenWrongDirection, "@DocString(LandmarkType.AccessForbiddenWrongDirection)") + .add_static_property("ForbiddenUTurn", &cr::SignalType::ForbiddenUTurn, "@DocString(LandmarkType.ForbiddenUTurn)") + .add_static_property("MaximumSpeed", &cr::SignalType::MaximumSpeed, "@DocString(LandmarkType.MaximumSpeed)") + .add_static_property("ForbiddenOvertakingMotorvehicles", &cr::SignalType::ForbiddenOvertakingMotorvehicles, "@DocString(LandmarkType.ForbiddenOvertakingMotorvehicles)") + .add_static_property("ForbiddenOvertakingTrucks", &cr::SignalType::ForbiddenOvertakingTrucks, "@DocString(LandmarkType.ForbiddenOvertakingTrucks)") + .add_static_property("AbsoluteNoStop", &cr::SignalType::AbsoluteNoStop, "@DocString(LandmarkType.AbsoluteNoStop)") + .add_static_property("RestrictedStop", &cr::SignalType::RestrictedStop, "@DocString(LandmarkType.RestrictedStop)") + .add_static_property("HasWayNextIntersection", &cr::SignalType::HasWayNextIntersection, "@DocString(LandmarkType.HasWayNextIntersection)") + .add_static_property("PriorityWay", &cr::SignalType::PriorityWay, "@DocString(LandmarkType.PriorityWay)") + .add_static_property("PriorityWayEnd", &cr::SignalType::PriorityWayEnd, "@DocString(LandmarkType.PriorityWayEnd)") + .add_static_property("CityBegin", &cr::SignalType::CityBegin, "@DocString(LandmarkType.CityBegin)") + .add_static_property("CityEnd", &cr::SignalType::CityEnd, "@DocString(LandmarkType.CityEnd)") + .add_static_property("Highway", &cr::SignalType::Highway, "@DocString(LandmarkType.Highway)") + .add_static_property("DeadEnd", &cr::SignalType::DeadEnd, "@DocString(LandmarkType.DeadEnd)") + .add_static_property("RecomendedSpeed", &cr::SignalType::RecomendedSpeed, "@DocString(LandmarkType.RecomendedSpeed)") + .add_static_property("RecomendedSpeedEnd", &cr::SignalType::RecomendedSpeedEnd, "@DocString(LandmarkType.RecomendedSpeedEnd)") ; class_>("Landmark", no_init) - .add_property("road_id", &cc::Landmark::GetRoadId) - .add_property("distance", &cc::Landmark::GetDistance) - .add_property("s", &cc::Landmark::GetS) - .add_property("t", &cc::Landmark::GetT) - .add_property("id", &cc::Landmark::GetId) - .add_property("name", &cc::Landmark::GetName) - .add_property("is_dynamic", &cc::Landmark::IsDynamic) - .add_property("orientation", &cc::Landmark::GetOrientation) - .add_property("z_offset", &cc::Landmark::GetZOffset) - .add_property("country", &cc::Landmark::GetCountry) - .add_property("type", &cc::Landmark::GetType) - .add_property("sub_type", &cc::Landmark::GetSubType) - .add_property("value", &cc::Landmark::GetValue) - .add_property("unit", &cc::Landmark::GetUnit) - .add_property("height", &cc::Landmark::GetHeight) - .add_property("width", &cc::Landmark::GetWidth) - .add_property("text", &cc::Landmark::GetText) - .add_property("h_offset", &cc::Landmark::GethOffset) - .add_property("pitch", &cc::Landmark::GetPitch) - .add_property("roll", &cc::Landmark::GetRoll) - .add_property("waypoint", &cc::Landmark::GetWaypoint) - .add_property("transform", CALL_RETURNING_COPY(cc::Landmark, GetTransform)) - .def("get_lane_validities", &GetLaneValidities) + .add_property("road_id", &cc::Landmark::GetRoadId, "@DocString(Landmark.road_id)") + .add_property("distance", &cc::Landmark::GetDistance, "@DocString(Landmark.distance)") + .add_property("s", &cc::Landmark::GetS, "@DocString(Landmark.s)") + .add_property("t", &cc::Landmark::GetT, "@DocString(Landmark.t)") + .add_property("id", &cc::Landmark::GetId, "@DocString(Landmark.id)") + .add_property("name", &cc::Landmark::GetName, "@DocString(Landmark.name)") + .add_property("is_dynamic", &cc::Landmark::IsDynamic, "@DocString(Landmark.is_dynamic)") + .add_property("orientation", &cc::Landmark::GetOrientation, "@DocString(Landmark.orientation)") + .add_property("z_offset", &cc::Landmark::GetZOffset, "@DocString(Landmark.z_offset)") + .add_property("country", &cc::Landmark::GetCountry, "@DocString(Landmark.country)") + .add_property("type", &cc::Landmark::GetType, "@DocString(Landmark.type)") + .add_property("sub_type", &cc::Landmark::GetSubType, "@DocString(Landmark.sub_type)") + .add_property("value", &cc::Landmark::GetValue, "@DocString(Landmark.value)") + .add_property("unit", &cc::Landmark::GetUnit, "@DocString(Landmark.unit)") + .add_property("height", &cc::Landmark::GetHeight, "@DocString(Landmark.height)") + .add_property("width", &cc::Landmark::GetWidth, "@DocString(Landmark.width)") + .add_property("text", &cc::Landmark::GetText, "@DocString(Landmark.text)") + .add_property("h_offset", &cc::Landmark::GethOffset, "@DocString(Landmark.h_offset)") + .add_property("pitch", &cc::Landmark::GetPitch, "@DocString(Landmark.pitch)") + .add_property("roll", &cc::Landmark::GetRoll, "@DocString(Landmark.roll)") + .add_property("waypoint", &cc::Landmark::GetWaypoint, "@DocString(Landmark.waypoint)") + .add_property("transform", CALL_RETURNING_COPY(cc::Landmark, GetTransform), "@DocString(Landmark.transform)") + .def("get_lane_validities", &GetLaneValidities, "@DocString(Landmark.get_lane_validities)") ; } diff --git a/PythonAPI/carla/source/libcarla/Sensor.cpp b/PythonAPI/carla/source/libcarla/Sensor.cpp index 45b5ab99d8f..6dbe9b810b6 100644 --- a/PythonAPI/carla/source/libcarla/Sensor.cpp +++ b/PythonAPI/carla/source/libcarla/Sensor.cpp @@ -19,9 +19,9 @@ void export_sensor() { namespace cc = carla::client; class_, boost::noncopyable, boost::shared_ptr>("Sensor", no_init) - .add_property("is_listening", &cc::Sensor::IsListening) - .def("listen", &SubscribeToStream, (arg("callback"))) - .def("stop", &cc::Sensor::Stop) + .add_property("is_listening", &cc::Sensor::IsListening, "@DocString(Sensor.is_listening)") + .def("listen", &SubscribeToStream, (arg("callback")), "@DocString(Sensor.listen)") + .def("stop", &cc::Sensor::Stop, "@DocString(Sensor.stop)") .def(self_ns::str(self_ns::self)) ; diff --git a/PythonAPI/carla/source/libcarla/SensorData.cpp b/PythonAPI/carla/source/libcarla/SensorData.cpp index b9f2a59ba53..d07fdd0bdc0 100644 --- a/PythonAPI/carla/source/libcarla/SensorData.cpp +++ b/PythonAPI/carla/source/libcarla/SensorData.cpp @@ -197,10 +197,10 @@ void export_sensor_data() { namespace css = carla::sensor::s11n; class_>("SensorData", no_init) - .add_property("frame", &cs::SensorData::GetFrame) - .add_property("frame_number", &cs::SensorData::GetFrame) // deprecated. - .add_property("timestamp", &cs::SensorData::GetTimestamp) - .add_property("transform", CALL_RETURNING_COPY(cs::SensorData, GetSensorTransform)) + .add_property("frame", &cs::SensorData::GetFrame, "@DocString(SensorData.frame)") + .add_property("frame_number", &cs::SensorData::GetFrame, "@DocString(SensorData.frame_number)") // deprecated. + .add_property("timestamp", &cs::SensorData::GetTimestamp, "@DocString(SensorData.timestamp)") + .add_property("transform", CALL_RETURNING_COPY(cs::SensorData, GetSensorTransform), "@DocString(SensorData.transform)") ; enum_("ColorConverter") @@ -211,93 +211,93 @@ void export_sensor_data() { ; class_, boost::noncopyable, boost::shared_ptr>("Image", no_init) - .add_property("width", &csd::Image::GetWidth) - .add_property("height", &csd::Image::GetHeight) - .add_property("fov", &csd::Image::GetFOVAngle) - .add_property("raw_data", &GetRawDataAsBuffer) - .def("convert", &ConvertImage, (arg("color_converter"))) - .def("save_to_disk", &SaveImageToDisk, (arg("path"), arg("color_converter")=EColorConverter::Raw)) - .def("__len__", &csd::Image::size) - .def("__iter__", iterator()) + .add_property("width", &csd::Image::GetWidth, "@DocString(Image.width)") + .add_property("height", &csd::Image::GetHeight, "@DocString(Image.height)") + .add_property("fov", &csd::Image::GetFOVAngle, "@DocString(Image.fov)") + .add_property("raw_data", &GetRawDataAsBuffer, "@DocString(Image.raw_data)") + .def("convert", &ConvertImage, (arg("color_converter")), "@DocString(Image.convert)") + .def("save_to_disk", &SaveImageToDisk, (arg("path"), arg("color_converter")=EColorConverter::Raw), "@DocString(Image.save_to_disk)") + .def("__len__", &csd::Image::size, "@DocString(Image.__len__)") + .def("__iter__", iterator(), "@DocString(Image.__iter__)") .def("__getitem__", +[](const csd::Image &self, size_t pos) -> csd::Color { return self.at(pos); - }) + }, "@DocString(Image.__getitem__)") .def("__setitem__", +[](csd::Image &self, size_t pos, csd::Color color) { self.at(pos) = color; - }) + }, "@DocString(Image.__setitem__)") .def(self_ns::str(self_ns::self)) ; class_, boost::noncopyable, boost::shared_ptr>("LidarMeasurement", no_init) - .add_property("horizontal_angle", &csd::LidarMeasurement::GetHorizontalAngle) - .add_property("channels", &csd::LidarMeasurement::GetChannelCount) - .add_property("raw_data", &GetRawDataAsBuffer) - .def("get_point_count", &csd::LidarMeasurement::GetPointCount, (arg("channel"))) - .def("save_to_disk", &SavePointCloudToDisk, (arg("path"))) - .def("__len__", &csd::LidarMeasurement::size) - .def("__iter__", iterator()) + .add_property("horizontal_angle", &csd::LidarMeasurement::GetHorizontalAngle, "@DocString(LidarMeasurement.horizontal_angle)") + .add_property("channels", &csd::LidarMeasurement::GetChannelCount, "@DocString(LidarMeasurement.channels)") + .add_property("raw_data", &GetRawDataAsBuffer, "@DocString(LidarMeasurement.raw_data)") + .def("get_point_count", &csd::LidarMeasurement::GetPointCount, (arg("channel")), "@DocString(LidarMeasurement.get_point_count)") + .def("save_to_disk", &SavePointCloudToDisk, (arg("path")), "@DocString(LidarMeasurement.save_to_disk)") + .def("__len__", &csd::LidarMeasurement::size, "@DocString(LidarMeasurement.__len__)") + .def("__iter__", iterator(), "@DocString(LidarMeasurement.__iter__)") .def("__getitem__", +[](const csd::LidarMeasurement &self, size_t pos) -> cr::Location { return self.at(pos); - }) + }, "@DocString(LidarMeasurement.__getitem__)") .def("__setitem__", +[](csd::LidarMeasurement &self, size_t pos, const cr::Location &point) { self.at(pos) = point; - }) + }, "@DocString(LidarMeasurement.__setitem__)") .def(self_ns::str(self_ns::self)) ; class_, boost::noncopyable, boost::shared_ptr>("CollisionEvent", no_init) - .add_property("actor", &csd::CollisionEvent::GetActor) - .add_property("other_actor", &csd::CollisionEvent::GetOtherActor) - .add_property("normal_impulse", CALL_RETURNING_COPY(csd::CollisionEvent, GetNormalImpulse)) + .add_property("actor", &csd::CollisionEvent::GetActor, "@DocString(CollisionEvent.actor)") + .add_property("other_actor", &csd::CollisionEvent::GetOtherActor, "@DocString(CollisionEvent.other_actor)") + .add_property("normal_impulse", CALL_RETURNING_COPY(csd::CollisionEvent, GetNormalImpulse), "@DocString(CollisionEvent.normal_impulse)") .def(self_ns::str(self_ns::self)) ; class_, boost::noncopyable, boost::shared_ptr>("ObstacleDetectionEvent", no_init) - .add_property("actor", &csd::ObstacleDetectionEvent::GetActor) - .add_property("other_actor", &csd::ObstacleDetectionEvent::GetOtherActor) - .add_property("distance", CALL_RETURNING_COPY(csd::ObstacleDetectionEvent, GetDistance)) + .add_property("actor", &csd::ObstacleDetectionEvent::GetActor, "@DocString(ObstacleDetectionEvent.actor)") + .add_property("other_actor", &csd::ObstacleDetectionEvent::GetOtherActor, "@DocString(ObstacleDetectionEvent.other_actor)") + .add_property("distance", CALL_RETURNING_COPY(csd::ObstacleDetectionEvent, GetDistance), "@DocString(ObstacleDetectionEvent.distance)") .def(self_ns::str(self_ns::self)) ; class_, boost::noncopyable, boost::shared_ptr>("LaneInvasionEvent", no_init) - .add_property("actor", &csd::LaneInvasionEvent::GetActor) - .add_property("crossed_lane_markings", CALL_RETURNING_LIST(csd::LaneInvasionEvent, GetCrossedLaneMarkings)) + .add_property("actor", &csd::LaneInvasionEvent::GetActor, "@DocString(LaneInvasionEvent.actor)") + .add_property("crossed_lane_markings", CALL_RETURNING_LIST(csd::LaneInvasionEvent, GetCrossedLaneMarkings), "@DocString(LaneInvasionEvent.crossed_lane_markings)") .def(self_ns::str(self_ns::self)) ; class_, boost::noncopyable, boost::shared_ptr>("GnssMeasurement", no_init) - .add_property("latitude", &csd::GnssMeasurement::GetLatitude) - .add_property("longitude", &csd::GnssMeasurement::GetLongitude) - .add_property("altitude", &csd::GnssMeasurement::GetAltitude) + .add_property("latitude", &csd::GnssMeasurement::GetLatitude, "@DocString(GnssMeasurement.latitude)") + .add_property("longitude", &csd::GnssMeasurement::GetLongitude, "@DocString(GnssMeasurement.longitude)") + .add_property("altitude", &csd::GnssMeasurement::GetAltitude, "@DocString(GnssMeasurement.altitude)") .def(self_ns::str(self_ns::self)) ; class_, boost::noncopyable, boost::shared_ptr>("IMUMeasurement", no_init) - .add_property("accelerometer", &csd::IMUMeasurement::GetAccelerometer) - .add_property("gyroscope", &csd::IMUMeasurement::GetGyroscope) - .add_property("compass", &csd::IMUMeasurement::GetCompass) + .add_property("accelerometer", &csd::IMUMeasurement::GetAccelerometer, "@DocString(IMUMeasurement.accelerometer)") + .add_property("gyroscope", &csd::IMUMeasurement::GetGyroscope, "@DocString(IMUMeasurement.gyroscope)") + .add_property("compass", &csd::IMUMeasurement::GetCompass, "@DocString(IMUMeasurement.compass)") .def(self_ns::str(self_ns::self)) ; class_, boost::noncopyable, boost::shared_ptr>("RadarMeasurement", no_init) - .add_property("raw_data", &GetRawDataAsBuffer) - .def("get_detection_count", &csd::RadarMeasurement::GetDetectionAmount) - .def("__len__", &csd::RadarMeasurement::size) - .def("__iter__", iterator()) + .add_property("raw_data", &GetRawDataAsBuffer, "@DocString(RadarMeasurement.raw_data)") + .def("get_detection_count", &csd::RadarMeasurement::GetDetectionAmount, "@DocString(RadarMeasurement.get_detection_count)") + .def("__len__", &csd::RadarMeasurement::size, "@DocString(RadarMeasurement.__len__)") + .def("__iter__", iterator(), "@DocString(RadarMeasurement.__iter__)") .def("__getitem__", +[](const csd::RadarMeasurement &self, size_t pos) -> css::RadarDetection { return self.at(pos); - }) + }, "@DocString(RadarMeasurement.__getitem__)") .def("__setitem__", +[](csd::RadarMeasurement &self, size_t pos, const css::RadarDetection &detection) { self.at(pos) = detection; - }) + }, "@DocString(RadarMeasurement.__setitem__)") .def(self_ns::str(self_ns::self)) ; class_("RadarDetection") - .def_readwrite("velocity", &css::RadarDetection::velocity) - .def_readwrite("azimuth", &css::RadarDetection::azimuth) - .def_readwrite("altitude", &css::RadarDetection::altitude) - .def_readwrite("depth", &css::RadarDetection::depth) + .def_readwrite("velocity", &css::RadarDetection::velocity, "@DocString(RadarDetection.velocity)") + .def_readwrite("azimuth", &css::RadarDetection::azimuth, "@DocString(RadarDetection.azimuth)") + .def_readwrite("altitude", &css::RadarDetection::altitude, "@DocString(RadarDetection.altitude)") + .def_readwrite("depth", &css::RadarDetection::depth, "@DocString(RadarDetection.depth)") .def(self_ns::str(self_ns::self)) ; } diff --git a/PythonAPI/carla/source/libcarla/Snapshot.cpp b/PythonAPI/carla/source/libcarla/Snapshot.cpp index 45603f426ea..4715c42684e 100644 --- a/PythonAPI/carla/source/libcarla/Snapshot.cpp +++ b/PythonAPI/carla/source/libcarla/Snapshot.cpp @@ -32,30 +32,30 @@ void export_snapshot() { namespace cc = carla::client; class_("ActorSnapshot", no_init) - .def_readonly("id", &cc::ActorSnapshot::id) - .def("get_transform", +[](const cc::ActorSnapshot &self) { return self.transform; }) - .def("get_velocity", +[](const cc::ActorSnapshot &self) { return self.velocity; }) - .def("get_angular_velocity", +[](const cc::ActorSnapshot &self) { return self.angular_velocity; }) - .def("get_acceleration", +[](const cc::ActorSnapshot &self) { return self.acceleration; }) + .def_readonly("id", &cc::ActorSnapshot::id, "@DocString(ActorSnapshot.id)") + .def("get_transform", +[](const cc::ActorSnapshot &self) { return self.transform; }, "@DocString(ActorSnapshot.get_transform)") + .def("get_velocity", +[](const cc::ActorSnapshot &self) { return self.velocity; }, "@DocString(ActorSnapshot.get_velocity)") + .def("get_angular_velocity", +[](const cc::ActorSnapshot &self) { return self.angular_velocity; }, "@DocString(ActorSnapshot.get_angular_velocity)") + .def("get_acceleration", +[](const cc::ActorSnapshot &self) { return self.acceleration; }, "@DocString(ActorSnapshot.get_acceleration)") .def(self_ns::str(self_ns::self)) ; class_("WorldSnapshot", no_init) - .add_property("id", &cc::WorldSnapshot::GetId) - .add_property("frame", +[](const cc::WorldSnapshot &self) { return self.GetTimestamp().frame; }) - .add_property("timestamp", CALL_RETURNING_COPY(cc::WorldSnapshot, GetTimestamp)) + .add_property("id", &cc::WorldSnapshot::GetId, "@DocString(WorldSnapshot.id)") + .add_property("frame", +[](const cc::WorldSnapshot &self) { return self.GetTimestamp().frame; }, "@DocString(WorldSnapshot.frame)") + .add_property("timestamp", CALL_RETURNING_COPY(cc::WorldSnapshot, GetTimestamp), "@DocString(WorldSnapshot.timestamp)") /// Deprecated, use timestamp @{ - .add_property("frame_count", +[](const cc::WorldSnapshot &self) { return self.GetTimestamp().frame; }) - .add_property("elapsed_seconds", +[](const cc::WorldSnapshot &self) { return self.GetTimestamp().elapsed_seconds; }) - .add_property("delta_seconds", +[](const cc::WorldSnapshot &self) { return self.GetTimestamp().delta_seconds; }) - .add_property("platform_timestamp", +[](const cc::WorldSnapshot &self) { return self.GetTimestamp().platform_timestamp; }) + .add_property("frame_count", +[](const cc::WorldSnapshot &self) { return self.GetTimestamp().frame; }, "@DocString(WorldSnapshot.frame_count)") + .add_property("elapsed_seconds", +[](const cc::WorldSnapshot &self) { return self.GetTimestamp().elapsed_seconds; }, "@DocString(WorldSnapshot.elapsed_seconds)") + .add_property("delta_seconds", +[](const cc::WorldSnapshot &self) { return self.GetTimestamp().delta_seconds; }, "@DocString(WorldSnapshot.delta_seconds)") + .add_property("platform_timestamp", +[](const cc::WorldSnapshot &self) { return self.GetTimestamp().platform_timestamp; }, "@DocString(WorldSnapshot.platform_timestamp)") /// @} - .def("has_actor", &cc::WorldSnapshot::Contains, (arg("actor_id"))) - .def("find", CALL_RETURNING_OPTIONAL_1(cc::WorldSnapshot, Find, carla::ActorId), (arg("actor_id"))) - .def("__len__", &cc::WorldSnapshot::size) - .def("__iter__", range(&cc::WorldSnapshot::begin, &cc::WorldSnapshot::end)) - .def("__eq__", &cc::WorldSnapshot::operator==) - .def("__ne__", &cc::WorldSnapshot::operator!=) + .def("has_actor", &cc::WorldSnapshot::Contains, (arg("actor_id")), "@DocString(WorldSnapshot.has_actor)") + .def("find", CALL_RETURNING_OPTIONAL_1(cc::WorldSnapshot, Find, carla::ActorId), (arg("actor_id")), "@DocString(WorldSnapshot.find)") + .def("__len__", &cc::WorldSnapshot::size, "@DocString(WorldSnapshot.__len__)") + .def("__iter__", range(&cc::WorldSnapshot::begin, &cc::WorldSnapshot::end), "@DocString(WorldSnapshot.__iter__)") + .def("__eq__", &cc::WorldSnapshot::operator==, "@DocString(WorldSnapshot.__eq__)") + .def("__ne__", &cc::WorldSnapshot::operator!=, "@DocString(WorldSnapshot.__ne__)") .def(self_ns::str(self_ns::self)) ; } diff --git a/PythonAPI/carla/source/libcarla/TrafficManager.cpp b/PythonAPI/carla/source/libcarla/TrafficManager.cpp index 586211d948c..6ec1067b008 100644 --- a/PythonAPI/carla/source/libcarla/TrafficManager.cpp +++ b/PythonAPI/carla/source/libcarla/TrafficManager.cpp @@ -17,21 +17,22 @@ void export_trafficmanager() { using namespace boost::python; class_("TrafficManager", no_init) - .def("get_port", &carla::traffic_manager::TrafficManager::Port) - .def("vehicle_percentage_speed_difference", &carla::traffic_manager::TrafficManager::SetPercentageSpeedDifference) - .def("global_percentage_speed_difference", &carla::traffic_manager::TrafficManager::SetGlobalPercentageSpeedDifference) - .def("collision_detection", &carla::traffic_manager::TrafficManager::SetCollisionDetection) - .def("force_lane_change", &carla::traffic_manager::TrafficManager::SetForceLaneChange) - .def("auto_lane_change", &carla::traffic_manager::TrafficManager::SetAutoLaneChange) - .def("distance_to_leading_vehicle", &carla::traffic_manager::TrafficManager::SetDistanceToLeadingVehicle) - .def("reset_traffic_lights", &carla::traffic_manager::TrafficManager::ResetAllTrafficLights) - .def("ignore_walkers_percentage", &carla::traffic_manager::TrafficManager::SetPercentageIgnoreWalkers) - .def("ignore_vehicles_percentage", &carla::traffic_manager::TrafficManager::SetPercentageIgnoreVehicles) - .def("ignore_lights_percentage", &carla::traffic_manager::TrafficManager::SetPercentageRunningLight) - .def("ignore_signs_percentage", &carla::traffic_manager::TrafficManager::SetPercentageRunningSign) - .def("set_global_distance_to_leading_vehicle", &carla::traffic_manager::TrafficManager::SetGlobalDistanceToLeadingVehicle) - .def("set_percentage_keep_right_rule", &carla::traffic_manager::TrafficManager::SetKeepRightPercentage) - .def("set_synchronous_mode", &carla::traffic_manager::TrafficManager::SetSynchronousMode) - .def("set_hybrid_physics_mode", &carla::traffic_manager::TrafficManager::SetHybridPhysicsMode) - .def("set_hybrid_physics_radius", &carla::traffic_manager::TrafficManager::SetHybridPhysicsRadius); + .def("get_port", &carla::traffic_manager::TrafficManager::Port, "@DocString(TrafficManager.get_port)") + .def("vehicle_percentage_speed_difference", &carla::traffic_manager::TrafficManager::SetPercentageSpeedDifference, "@DocString(TrafficManager.vehicle_percentage_speed_difference)") + .def("global_percentage_speed_difference", &carla::traffic_manager::TrafficManager::SetGlobalPercentageSpeedDifference, "@DocString(TrafficManager.global_percentage_speed_difference)") + .def("collision_detection", &carla::traffic_manager::TrafficManager::SetCollisionDetection, "@DocString(TrafficManager.collision_detection)") + .def("force_lane_change", &carla::traffic_manager::TrafficManager::SetForceLaneChange, "@DocString(TrafficManager.force_lane_change)") + .def("auto_lane_change", &carla::traffic_manager::TrafficManager::SetAutoLaneChange, "@DocString(TrafficManager.auto_lane_change)") + .def("distance_to_leading_vehicle", &carla::traffic_manager::TrafficManager::SetDistanceToLeadingVehicle, "@DocString(TrafficManager.distance_to_leading_vehicle)") + .def("reset_traffic_lights", &carla::traffic_manager::TrafficManager::ResetAllTrafficLights, "@DocString(TrafficManager.reset_traffic_lights)") + .def("ignore_walkers_percentage", &carla::traffic_manager::TrafficManager::SetPercentageIgnoreWalkers, "@DocString(TrafficManager.ignore_walkers_percentage)") + .def("ignore_vehicles_percentage", &carla::traffic_manager::TrafficManager::SetPercentageIgnoreVehicles, "@DocString(TrafficManager.ignore_vehicles_percentage)") + .def("ignore_lights_percentage", &carla::traffic_manager::TrafficManager::SetPercentageRunningLight, "@DocString(TrafficManager.ignore_lights_percentage)") + .def("ignore_signs_percentage", &carla::traffic_manager::TrafficManager::SetPercentageRunningSign, "@DocString(TrafficManager.ignore_signs_percentage)") + .def("set_global_distance_to_leading_vehicle", &carla::traffic_manager::TrafficManager::SetGlobalDistanceToLeadingVehicle, "@DocString(TrafficManager.set_global_distance_to_leading_vehicle)") + .def("set_percentage_keep_right_rule", &carla::traffic_manager::TrafficManager::SetKeepRightPercentage, "@DocString(TrafficManager.set_percentage_keep_right_rule)") + .def("set_synchronous_mode", &carla::traffic_manager::TrafficManager::SetSynchronousMode, "@DocString(TrafficManager.set_synchronous_mode)") + .def("set_hybrid_physics_mode", &carla::traffic_manager::TrafficManager::SetHybridPhysicsMode, "@DocString(TrafficManager.set_hybrid_physics_mode)") + .def("set_hybrid_physics_radius", &carla::traffic_manager::TrafficManager::SetHybridPhysicsRadius, "@DocString(TrafficManager.set_hybrid_physics_radius)") + ; } diff --git a/PythonAPI/carla/source/libcarla/Weather.cpp b/PythonAPI/carla/source/libcarla/Weather.cpp index b2d73e5442d..7a8b0e9d0b9 100644 --- a/PythonAPI/carla/source/libcarla/Weather.cpp +++ b/PythonAPI/carla/source/libcarla/Weather.cpp @@ -38,18 +38,18 @@ void export_weather() { arg("sun_altitude_angle")=0.0f, arg("fog_density")=0.0f, arg("fog_distance")=0.0f, - arg("wetness")=0.0f))) - .def_readwrite("cloudiness", &cr::WeatherParameters::cloudiness) - .def_readwrite("precipitation", &cr::WeatherParameters::precipitation) - .def_readwrite("precipitation_deposits", &cr::WeatherParameters::precipitation_deposits) - .def_readwrite("wind_intensity", &cr::WeatherParameters::wind_intensity) - .def_readwrite("sun_azimuth_angle", &cr::WeatherParameters::sun_azimuth_angle) - .def_readwrite("sun_altitude_angle", &cr::WeatherParameters::sun_altitude_angle) - .def_readwrite("fog_density", &cr::WeatherParameters::fog_density) - .def_readwrite("fog_distance", &cr::WeatherParameters::fog_distance) - .def_readwrite("wetness", &cr::WeatherParameters::wetness) - .def("__eq__", &cr::WeatherParameters::operator==) - .def("__ne__", &cr::WeatherParameters::operator!=) + arg("wetness")=0.0f), "@DocString(WeatherParameters.__init__)")) + .def_readwrite("cloudiness", &cr::WeatherParameters::cloudiness, "@DocString(WeatherParameters.cloudiness)") + .def_readwrite("precipitation", &cr::WeatherParameters::precipitation, "@DocString(WeatherParameters.precipitation)") + .def_readwrite("precipitation_deposits", &cr::WeatherParameters::precipitation_deposits, "@DocString(WeatherParameters.precipitation_deposits)") + .def_readwrite("wind_intensity", &cr::WeatherParameters::wind_intensity, "@DocString(WeatherParameters.wind_intensity)") + .def_readwrite("sun_azimuth_angle", &cr::WeatherParameters::sun_azimuth_angle, "@DocString(WeatherParameters.sun_azimuth_angle)") + .def_readwrite("sun_altitude_angle", &cr::WeatherParameters::sun_altitude_angle, "@DocString(WeatherParameters.sun_altitude_angle)") + .def_readwrite("fog_density", &cr::WeatherParameters::fog_density, "@DocString(WeatherParameters.fog_density)") + .def_readwrite("fog_distance", &cr::WeatherParameters::fog_distance, "@DocString(WeatherParameters.fog_distance)") + .def_readwrite("wetness", &cr::WeatherParameters::wetness, "@DocString(WeatherParameters.wetness)") + .def("__eq__", &cr::WeatherParameters::operator==, "@DocString(WeatherParameters.__eq__)") + .def("__ne__", &cr::WeatherParameters::operator!=, "@DocString(WeatherParameters.__ne__)") .def(self_ns::str(self_ns::self)) ; diff --git a/PythonAPI/carla/source/libcarla/World.cpp b/PythonAPI/carla/source/libcarla/World.cpp index 038a4942a1f..a686f627d2d 100644 --- a/PythonAPI/carla/source/libcarla/World.cpp +++ b/PythonAPI/carla/source/libcarla/World.cpp @@ -72,23 +72,23 @@ void export_world() { (arg("frame")=0u, arg("elapsed_seconds")=0.0, arg("delta_seconds")=0.0, - arg("platform_timestamp")=0.0))) - .def_readwrite("frame", &cc::Timestamp::frame) - .def_readwrite("frame_count", &cc::Timestamp::frame) // deprecated. - .def_readwrite("elapsed_seconds", &cc::Timestamp::elapsed_seconds) - .def_readwrite("delta_seconds", &cc::Timestamp::delta_seconds) - .def_readwrite("platform_timestamp", &cc::Timestamp::platform_timestamp) - .def("__eq__", &cc::Timestamp::operator==) - .def("__ne__", &cc::Timestamp::operator!=) + arg("platform_timestamp")=0.0), "@DocString(Timestamp.__init__)")) + .def_readwrite("frame", &cc::Timestamp::frame, "@DocString(Timestamp.frame)") + .def_readwrite("frame_count", &cc::Timestamp::frame, "@DocString(Timestamp.frame_count)") // deprecated. + .def_readwrite("elapsed_seconds", &cc::Timestamp::elapsed_seconds, "@DocString(Timestamp.elapsed_seconds)") + .def_readwrite("delta_seconds", &cc::Timestamp::delta_seconds, "@DocString(Timestamp.delta_seconds)") + .def_readwrite("platform_timestamp", &cc::Timestamp::platform_timestamp, "@DocString(Timestamp.platform_timestamp)") + .def("__eq__", &cc::Timestamp::operator==, "@DocString(Timestamp.__eq__)") + .def("__ne__", &cc::Timestamp::operator!=, "@DocString(Timestamp.__ne__)") .def(self_ns::str(self_ns::self)) ; class_>("ActorList", no_init) - .def("find", &cc::ActorList::Find, (arg("id"))) - .def("filter", &cc::ActorList::Filter, (arg("wildcard_pattern"))) - .def("__getitem__", &cc::ActorList::at) - .def("__len__", &cc::ActorList::size) - .def("__iter__", range(&cc::ActorList::begin, &cc::ActorList::end)) + .def("find", &cc::ActorList::Find, (arg("id")), "@DocString(ActorList.find)") + .def("filter", &cc::ActorList::Filter, (arg("wildcard_pattern")), "@DocString(ActorList.filter)") + .def("__getitem__", &cc::ActorList::at, "@DocString(ActorList.__getitem__)") + .def("__len__", &cc::ActorList::size, "@DocString(ActorList.__len__)") + .def("__iter__", range(&cc::ActorList::begin, &cc::ActorList::end), "@DocString(ActorList.__iter__)") .def(self_ns::str(self_ns::self)) ; @@ -96,9 +96,9 @@ void export_world() { .def(init( (arg("synchronous_mode")=false, arg("no_rendering_mode")=false, - arg("fixed_delta_seconds")=0.0))) - .def_readwrite("synchronous_mode", &cr::EpisodeSettings::synchronous_mode) - .def_readwrite("no_rendering_mode", &cr::EpisodeSettings::no_rendering_mode) + arg("fixed_delta_seconds")=0.0), "@DocString(WorldSettings.__init__)")) + .def_readwrite("synchronous_mode", &cr::EpisodeSettings::synchronous_mode, "@DocString(WorldSettings.synchronous_mode)") + .def_readwrite("no_rendering_mode", &cr::EpisodeSettings::no_rendering_mode, "@DocString(WorldSettings.no_rendering_mode)") .add_property("fixed_delta_seconds", +[](const cr::EpisodeSettings &self) { return OptionalToPythonObject(self.fixed_delta_seconds); @@ -106,9 +106,9 @@ void export_world() { +[](cr::EpisodeSettings &self, object value) { double fds = (value == object{} ? 0.0 : extract(value)); self.fixed_delta_seconds = fds > 0.0 ? fds : boost::optional{}; - }) - .def("__eq__", &cc::Timestamp::operator==) - .def("__ne__", &cc::Timestamp::operator!=) + }, "@DocString(WorldSettings.fixed_delta_seconds)") + .def("__eq__", &cc::Timestamp::operator==, "@DocString(WorldSettings.__eq__)") + .def("__ne__", &cc::Timestamp::operator!=, "@DocString(WorldSettings.__ne__)") .def(self_ns::str(self_ns::self)) ; @@ -133,30 +133,30 @@ void export_world() { arg("attachment_type")=cr::AttachmentType::Rigid) class_("World", no_init) - .add_property("id", &cc::World::GetId) - .add_property("debug", &cc::World::MakeDebugHelper) - .def("get_blueprint_library", CONST_CALL_WITHOUT_GIL(cc::World, GetBlueprintLibrary)) - .def("get_map", CONST_CALL_WITHOUT_GIL(cc::World, GetMap)) - .def("get_random_location_from_navigation", CALL_RETURNING_OPTIONAL_WITHOUT_GIL(cc::World, GetRandomLocationFromNavigation)) - .def("get_spectator", CONST_CALL_WITHOUT_GIL(cc::World, GetSpectator)) - .def("get_settings", CONST_CALL_WITHOUT_GIL(cc::World, GetSettings)) - .def("apply_settings", CALL_WITHOUT_GIL_1(cc::World, ApplySettings, cr::EpisodeSettings), arg("settings")) - .def("get_weather", CONST_CALL_WITHOUT_GIL(cc::World, GetWeather)) - .def("set_weather", &cc::World::SetWeather) - .def("get_snapshot", &cc::World::GetSnapshot) - .def("get_actor", CONST_CALL_WITHOUT_GIL_1(cc::World, GetActor, carla::ActorId), (arg("actor_id"))) - .def("get_actors", CONST_CALL_WITHOUT_GIL(cc::World, GetActors)) - .def("get_actors", &GetActorsById, (arg("actor_ids"))) - .def("spawn_actor", SPAWN_ACTOR_WITHOUT_GIL(SpawnActor)) - .def("try_spawn_actor", SPAWN_ACTOR_WITHOUT_GIL(TrySpawnActor)) - .def("wait_for_tick", &WaitForTick, (arg("seconds")=10.0)) - .def("on_tick", &OnTick, (arg("callback"))) - .def("remove_on_tick", &cc::World::RemoveOnTick, (arg("callback_id"))) - .def("tick", &Tick, (arg("seconds")=10.0)) - .def("set_pedestrians_cross_factor", CALL_WITHOUT_GIL_1(cc::World, SetPedestriansCrossFactor, float), (arg("percentage"))) - .def("get_traffic_sign", CONST_CALL_WITHOUT_GIL_1(cc::World, GetTrafficSign, cc::Landmark), arg("landmark")) - .def("get_traffic_light", CONST_CALL_WITHOUT_GIL_1(cc::World, GetTrafficLight, cc::Landmark), arg("landmark")) - .def("get_lightmanager", CONST_CALL_WITHOUT_GIL(cc::World, GetLightManager)) + .add_property("id", &cc::World::GetId, "@DocString(World.id)") + .add_property("debug", &cc::World::MakeDebugHelper, "@DocString(World.debug)") + .def("get_blueprint_library", CONST_CALL_WITHOUT_GIL(cc::World, GetBlueprintLibrary), "@DocString(World.get_blueprint_library)") + .def("get_map", CONST_CALL_WITHOUT_GIL(cc::World, GetMap), "@DocString(World.get_map)") + .def("get_random_location_from_navigation", CALL_RETURNING_OPTIONAL_WITHOUT_GIL(cc::World, GetRandomLocationFromNavigation), "@DocString(World.get_random_location_from_navigation)") + .def("get_spectator", CONST_CALL_WITHOUT_GIL(cc::World, GetSpectator), "@DocString(World.get_spectator)") + .def("get_settings", CONST_CALL_WITHOUT_GIL(cc::World, GetSettings), "@DocString(World.get_settings)") + .def("apply_settings", CALL_WITHOUT_GIL_1(cc::World, ApplySettings, cr::EpisodeSettings), arg("settings"), "@DocString(World.apply_settings)") + .def("get_weather", CONST_CALL_WITHOUT_GIL(cc::World, GetWeather), "@DocString(World.get_weather)") + .def("set_weather", &cc::World::SetWeather, "@DocString(World.set_weather)") + .def("get_snapshot", &cc::World::GetSnapshot, "@DocString(World.get_snapshot)") + .def("get_actor", CONST_CALL_WITHOUT_GIL_1(cc::World, GetActor, carla::ActorId), (arg("actor_id")), "@DocString(World.get_actor)") + .def("get_actors", CONST_CALL_WITHOUT_GIL(cc::World, GetActors), "@DocString(World.get_actors)") + .def("get_actors", &GetActorsById, (arg("actor_ids")), "@DocString(World.get_actors)") + .def("spawn_actor", SPAWN_ACTOR_WITHOUT_GIL(SpawnActor), "@DocString(World.spawn_actor)") + .def("try_spawn_actor", SPAWN_ACTOR_WITHOUT_GIL(TrySpawnActor), "@DocString(World.try_spawn_actor)") + .def("wait_for_tick", &WaitForTick, (arg("seconds")=10.0), "@DocString(World.wait_for_tick)") + .def("on_tick", &OnTick, (arg("callback")), "@DocString(World.on_tick)") + .def("remove_on_tick", &cc::World::RemoveOnTick, (arg("callback_id")), "@DocString(World.remove_on_tick)") + .def("tick", &Tick, (arg("seconds")=10.0), "@DocString(World.tick)") + .def("set_pedestrians_cross_factor", CALL_WITHOUT_GIL_1(cc::World, SetPedestriansCrossFactor, float), (arg("percentage")), "@DocString(World.set_pedestrians_cross_factor)") + .def("get_traffic_sign", CONST_CALL_WITHOUT_GIL_1(cc::World, GetTrafficSign, cc::Landmark), arg("landmark"), "@DocString(World.get_traffic_sign)") + .def("get_traffic_light", CONST_CALL_WITHOUT_GIL_1(cc::World, GetTrafficLight, cc::Landmark), arg("landmark"), "@DocString(World.get_traffic_light)") + .def("get_lightmanager", CONST_CALL_WITHOUT_GIL(cc::World, GetLightManager), "@DocString(World.get_lightmanager)") .def(self_ns::str(self_ns::self)) ; @@ -168,14 +168,14 @@ void export_world() { arg("size")=0.1f, arg("color")=cc::DebugHelper::Color(255u, 0u, 0u), arg("life_time")=-1.0f, - arg("persistent_lines")=true)) + arg("persistent_lines")=true), "@DocString(DebugHelper.draw_point)") .def("draw_line", &cc::DebugHelper::DrawLine, (arg("begin"), arg("end"), arg("thickness")=0.1f, arg("color")=cc::DebugHelper::Color(255u, 0u, 0u), arg("life_time")=-1.0f, - arg("persistent_lines")=true)) + arg("persistent_lines")=true), "@DocString(DebugHelper.draw_line)") .def("draw_arrow", &cc::DebugHelper::DrawArrow, (arg("begin"), arg("end"), @@ -183,20 +183,20 @@ void export_world() { arg("arrow_size")=0.1f, arg("color")=cc::DebugHelper::Color(255u, 0u, 0u), arg("life_time")=-1.0f, - arg("persistent_lines")=true)) + arg("persistent_lines")=true), "@DocString(DebugHelper.draw_arrow)") .def("draw_box", &cc::DebugHelper::DrawBox, (arg("box"), arg("rotation"), arg("thickness")=0.1f, arg("color")=cc::DebugHelper::Color(255u, 0u, 0u), arg("life_time")=-1.0f, - arg("persistent_lines")=true)) + arg("persistent_lines")=true), "@DocString(DebugHelper.draw_box)") .def("draw_string", &cc::DebugHelper::DrawString, (arg("location"), arg("text"), arg("draw_shadow")=false, arg("color")=cc::DebugHelper::Color(255u, 0u, 0u), arg("life_time")=-1.0f, - arg("persistent_lines")=true)) + arg("persistent_lines")=true), "@DocString(DebugHelper.draw_string)") ; } diff --git a/PythonAPI/carla/source/libcarla/libcarla.cpp b/PythonAPI/carla/source/libcarla/libcarla.cpp index 13888676b95..0714347755e 100644 --- a/PythonAPI/carla/source/libcarla/libcarla.cpp +++ b/PythonAPI/carla/source/libcarla/libcarla.cpp @@ -205,6 +205,11 @@ static auto MakeCallback(boost::python::object callback) { BOOST_PYTHON_MODULE(libcarla) { using namespace boost::python; + + docstring_options doc_options; + doc_options.disable_all(); + doc_options.enable_user_defined(); + PyEval_InitThreads(); scope().attr("__path__") = "libcarla"; export_geom(); From 3b976cedee74c918444a61c8be62d6417460d283 Mon Sep 17 00:00:00 2001 From: Pascal Perle Date: Fri, 1 May 2020 18:30:29 +0200 Subject: [PATCH 2/6] Added python script to generate documentation for python from yml. --- PythonAPI/carla/generate_type_hints.py | 79 ++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 PythonAPI/carla/generate_type_hints.py diff --git a/PythonAPI/carla/generate_type_hints.py b/PythonAPI/carla/generate_type_hints.py new file mode 100644 index 00000000000..21d6b147861 --- /dev/null +++ b/PythonAPI/carla/generate_type_hints.py @@ -0,0 +1,79 @@ +import glob +import re +import sys +from typing import List, Any + +import yaml + + +def safe_list(obj: Any) -> List: + if obj is None: + return [] + return obj + + +def get_docstring(doc_file: str) -> dict: + docstrings = dict() + + with open(doc_file, 'r') as yaml_file: + documentations = yaml.safe_load(yaml_file) + + for documentation in documentations: + for class_doc in documentation.get('classes', []): + docstrings[class_doc['class_name']] = class_doc['doc'] + for method in class_doc.get('methods', []): + params = [] + details = method.get('doc', '') + for param in safe_list(method.get('params', [])): + details += f"\t@param {param['param_name']}: {param.get('doc', '')}" + param_sig = f"{param['param_name']}: {param.get('type', None)}" + if param.get('default', None): + param_sig += f" = {param['default']}" + params.append(param_sig) + + details += f"\t@return: {method.get('return', None)}" + signature = f"{method['def_name']}({', '.join(params)}) -> {method.get('return', None)}\n\n" + docstrings[f'{class_doc["class_name"]}.{method["def_name"]}'] = signature + details + + for instance_variable in safe_list(class_doc.get('instance_variables', [])): + if instance_variable.get('doc', None): + docstrings[f'{class_doc["class_name"]}.{instance_variable["var_name"]}'] = f"{instance_variable.get('type', None)}: {instance_variable['doc']}" + + return docstrings + + +def escape(line: str) -> str: + return line.replace('\\', '\\\\').replace('\n', r'\n').replace('"', '\\"') + + +def substitute(source_file: str, docstrings: dict) -> None: + with open(source_file) as input_file: + lines = input_file.readlines() + + output_data = [] + + pattern = re.compile(r'@DocString\((.+?)\)') + for line in lines: + for match in pattern.finditer(line): + docstring = docstrings.get(match.group(1), None) + if docstring is None: + docstring = "no documentation available" + line = line.replace(match.group(0), escape(docstring)) + output_data.append(line) + + with open(source_file, 'w') as output_file: + for item in output_data: + output_file.write(item) + + +if __name__ == '__main__': + doc_files = glob.glob(sys.argv[1]) # carla/PythonAPI/docs/*.yml + docstrings = {} + for doc_file in doc_files: + new_docs = get_docstring(doc_file) + docstrings = {**docstrings, **new_docs} + + source_files = glob.glob(sys.argv[2]) # carla/PythonAPI/carla/source/libcarla_template/*.cpp + for source_file in source_files: + substitute(source_file, docstrings) + From f303055544136bb4749156bddf795b01f1400900 Mon Sep 17 00:00:00 2001 From: Pascal Perle Date: Fri, 1 May 2020 20:21:25 +0200 Subject: [PATCH 3/6] Fixed "Python version 3.5 does not support a 'F' prefix" --- PythonAPI/carla/generate_type_hints.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PythonAPI/carla/generate_type_hints.py b/PythonAPI/carla/generate_type_hints.py index 21d6b147861..d46ecb2b61d 100644 --- a/PythonAPI/carla/generate_type_hints.py +++ b/PythonAPI/carla/generate_type_hints.py @@ -25,19 +25,19 @@ def get_docstring(doc_file: str) -> dict: params = [] details = method.get('doc', '') for param in safe_list(method.get('params', [])): - details += f"\t@param {param['param_name']}: {param.get('doc', '')}" - param_sig = f"{param['param_name']}: {param.get('type', None)}" + details += "\t@param " + str(param['param_name']) + ": " + str(param.get('doc', '')) + param_sig = str({param['param_name']}) + ": " + str(param.get('type', None)) if param.get('default', None): - param_sig += f" = {param['default']}" + param_sig += " = " + str(param['default']) params.append(param_sig) - details += f"\t@return: {method.get('return', None)}" - signature = f"{method['def_name']}({', '.join(params)}) -> {method.get('return', None)}\n\n" - docstrings[f'{class_doc["class_name"]}.{method["def_name"]}'] = signature + details + details += "\t@return: " + str(method.get('return', None)) + signature = str(method['def_name']) + "(" + str(', '.join(params)) + ") -> " + str(method.get('return', None)) + "\n\n" + docstrings[str(class_doc["class_name"]) + "." + str(method["def_name"])] = signature + details for instance_variable in safe_list(class_doc.get('instance_variables', [])): if instance_variable.get('doc', None): - docstrings[f'{class_doc["class_name"]}.{instance_variable["var_name"]}'] = f"{instance_variable.get('type', None)}: {instance_variable['doc']}" + docstrings[str(class_doc["class_name"]) + "." + str(instance_variable["var_name"])] = str(instance_variable.get('type', None)) + ": " + str(instance_variable['doc']) return docstrings From a9e83b45ea3694e0798f4ae48777cadc17640d39 Mon Sep 17 00:00:00 2001 From: Pascal Perle Date: Fri, 1 May 2020 20:43:40 +0200 Subject: [PATCH 4/6] Removed unnecessary brackets --- PythonAPI/carla/generate_type_hints.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PythonAPI/carla/generate_type_hints.py b/PythonAPI/carla/generate_type_hints.py index d46ecb2b61d..57ad1d10a05 100644 --- a/PythonAPI/carla/generate_type_hints.py +++ b/PythonAPI/carla/generate_type_hints.py @@ -26,7 +26,7 @@ def get_docstring(doc_file: str) -> dict: details = method.get('doc', '') for param in safe_list(method.get('params', [])): details += "\t@param " + str(param['param_name']) + ": " + str(param.get('doc', '')) - param_sig = str({param['param_name']}) + ": " + str(param.get('type', None)) + param_sig = str(param['param_name']) + ": " + str(param.get('type', None)) if param.get('default', None): param_sig += " = " + str(param['default']) params.append(param_sig) From ff05df2d1c3026759d114d1a734002391ae6b344 Mon Sep 17 00:00:00 2001 From: Pascal Perle Date: Fri, 1 May 2020 20:47:36 +0200 Subject: [PATCH 5/6] Added documentation generation to BuildPythonAPI.sh --- Util/BuildTools/BuildPythonAPI.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Util/BuildTools/BuildPythonAPI.sh b/Util/BuildTools/BuildPythonAPI.sh index 1c04f3970a9..bd403ca088a 100755 --- a/Util/BuildTools/BuildPythonAPI.sh +++ b/Util/BuildTools/BuildPythonAPI.sh @@ -94,8 +94,15 @@ if ${BUILD_FOR_PYTHON3} ; then log "Building Python API for Python 3." + cp -R source/libcarla/ source/libcarla_temp/ # copy original files to temp folder + /usr/bin/env python3 -m pip install pyyaml + /usr/bin/env python3 generate_type_hints.py "${CARLA_PYTHONAPI_ROOT_FOLDER}/docs/*.yml" "${CARLA_PYTHONAPI_SOURCE_FOLDER}/source/libcarla/*.cpp" # replace template with docs + /usr/bin/env python3 setup.py bdist_egg + rm -r source/libcarla + mv source/libcarla_temp source/libcarla # replace temp data with template files + fi # ============================================================================== From 4bf81ee8180140e7ada02488b2db1be9e02c502f Mon Sep 17 00:00:00 2001 From: Pascal Perle Date: Fri, 1 May 2020 21:04:19 +0200 Subject: [PATCH 6/6] Updated CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2bc46f60d9..59fb514096c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ + * Added documentation in Python. + ## CARLA 0.9.9 * Introduced hybrid mode for Traffic Manager