From 3ea23d682631b3447e4b867ce24d6766c115aa52 Mon Sep 17 00:00:00 2001 From: xqgex Date: Thu, 9 Mar 2023 03:53:51 -0500 Subject: [PATCH] Add keyword arguments for carla.TrafficManager Python API functions (#6246) * Update TrafficManager.cpp * Update CHANGELOG.md * Remove all default values except for set_path and set_route --- CHANGELOG.md | 1 + .../carla/source/libcarla/TrafficManager.cpp | 58 +++++++++---------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7c995800..4c06692bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * `Client.set_replayer_ignore_spectator(bool)` * `start_replaying.py` using flag `--move-spectator` * Added maps, vehicles, pedestrians and props catalogues to the documentation + * Add keyword arguments for `carla.TrafficManager` Python API functions ## CARLA 0.9.14 diff --git a/PythonAPI/carla/source/libcarla/TrafficManager.cpp b/PythonAPI/carla/source/libcarla/TrafficManager.cpp index 2bf2bed13..2bed4792e 100644 --- a/PythonAPI/carla/source/libcarla/TrafficManager.cpp +++ b/PythonAPI/carla/source/libcarla/TrafficManager.cpp @@ -86,34 +86,34 @@ void export_trafficmanager() { class_("TrafficManager", no_init) .def("get_port", &ctm::TrafficManager::Port) - .def("vehicle_percentage_speed_difference", &ctm::TrafficManager::SetPercentageSpeedDifference) - .def("vehicle_lane_offset", &ctm::TrafficManager::SetLaneOffset) - .def("set_desired_speed", &ctm::TrafficManager::SetDesiredSpeed) - .def("global_percentage_speed_difference", &ctm::TrafficManager::SetGlobalPercentageSpeedDifference) - .def("global_lane_offset", &ctm::TrafficManager::SetGlobalLaneOffset) - .def("update_vehicle_lights", &ctm::TrafficManager::SetUpdateVehicleLights) - .def("collision_detection", &ctm::TrafficManager::SetCollisionDetection) - .def("force_lane_change", &ctm::TrafficManager::SetForceLaneChange) - .def("auto_lane_change", &ctm::TrafficManager::SetAutoLaneChange) - .def("distance_to_leading_vehicle", &ctm::TrafficManager::SetDistanceToLeadingVehicle) - .def("ignore_walkers_percentage", &ctm::TrafficManager::SetPercentageIgnoreWalkers) - .def("ignore_vehicles_percentage", &ctm::TrafficManager::SetPercentageIgnoreVehicles) - .def("ignore_lights_percentage", &ctm::TrafficManager::SetPercentageRunningLight) - .def("ignore_signs_percentage", &ctm::TrafficManager::SetPercentageRunningSign) - .def("set_global_distance_to_leading_vehicle", &ctm::TrafficManager::SetGlobalDistanceToLeadingVehicle) - .def("keep_right_rule_percentage", &ctm::TrafficManager::SetKeepRightPercentage) - .def("random_left_lanechange_percentage", &ctm::TrafficManager::SetRandomLeftLaneChangePercentage) - .def("random_right_lanechange_percentage", &ctm::TrafficManager::SetRandomRightLaneChangePercentage) - .def("set_synchronous_mode", &ctm::TrafficManager::SetSynchronousMode) - .def("set_hybrid_physics_mode", &ctm::TrafficManager::SetHybridPhysicsMode) - .def("set_hybrid_physics_radius", &ctm::TrafficManager::SetHybridPhysicsRadius) - .def("set_random_device_seed", &ctm::TrafficManager::SetRandomDeviceSeed) - .def("set_osm_mode", &carla::traffic_manager::TrafficManager::SetOSMMode) - .def("set_path", &InterSetCustomPath, (arg("empty_buffer") = true)) - .def("set_route", &InterSetImportedRoute, (arg("empty_buffer") = true)) - .def("set_respawn_dormant_vehicles", &carla::traffic_manager::TrafficManager::SetRespawnDormantVehicles) - .def("set_boundaries_respawn_dormant_vehicles", &carla::traffic_manager::TrafficManager::SetBoundariesRespawnDormantVehicles) - .def("get_next_action", &InterGetNextAction) - .def("get_all_actions", &InterGetActionBuffer) + .def("vehicle_percentage_speed_difference", &ctm::TrafficManager::SetPercentageSpeedDifference, (arg("actor"), arg("percentage"))) + .def("vehicle_lane_offset", &ctm::TrafficManager::SetLaneOffset, (arg("actor"), arg("offset"))) + .def("set_desired_speed", &ctm::TrafficManager::SetDesiredSpeed, (arg("actor"), arg("speed"))) + .def("global_percentage_speed_difference", &ctm::TrafficManager::SetGlobalPercentageSpeedDifference, (arg("percentage"))) + .def("global_lane_offset", &ctm::TrafficManager::SetGlobalLaneOffset, (arg("offset"))) + .def("update_vehicle_lights", &ctm::TrafficManager::SetUpdateVehicleLights, (arg("actor"), arg("do_update"))) + .def("collision_detection", &ctm::TrafficManager::SetCollisionDetection, (arg("reference_actor"), arg("other_actor"), arg("detect_collision"))) + .def("force_lane_change", &ctm::TrafficManager::SetForceLaneChange, (arg("actor"), arg("direction"))) + .def("auto_lane_change", &ctm::TrafficManager::SetAutoLaneChange, (arg("actor"), arg("enable"))) + .def("distance_to_leading_vehicle", &ctm::TrafficManager::SetDistanceToLeadingVehicle, (arg("actor"), arg("distance"))) + .def("ignore_walkers_percentage", &ctm::TrafficManager::SetPercentageIgnoreWalkers, (arg("actor"), arg("perc"))) + .def("ignore_vehicles_percentage", &ctm::TrafficManager::SetPercentageIgnoreVehicles, (arg("actor"), arg("perc"))) + .def("ignore_lights_percentage", &ctm::TrafficManager::SetPercentageRunningLight, (arg("actor"), arg("perc"))) + .def("ignore_signs_percentage", &ctm::TrafficManager::SetPercentageRunningSign, (arg("actor"), arg("perc"))) + .def("set_global_distance_to_leading_vehicle", &ctm::TrafficManager::SetGlobalDistanceToLeadingVehicle, (arg("distance"))) + .def("keep_right_rule_percentage", &ctm::TrafficManager::SetKeepRightPercentage, (arg("actor"), arg("perc"))) + .def("random_left_lanechange_percentage", &ctm::TrafficManager::SetRandomLeftLaneChangePercentage, (arg("actor"), arg("percentage"))) + .def("random_right_lanechange_percentage", &ctm::TrafficManager::SetRandomRightLaneChangePercentage, (arg("actor"), arg("percentage"))) + .def("set_synchronous_mode", &ctm::TrafficManager::SetSynchronousMode, (arg("mode_switch"))) + .def("set_hybrid_physics_mode", &ctm::TrafficManager::SetHybridPhysicsMode, (arg("enabled"))) + .def("set_hybrid_physics_radius", &ctm::TrafficManager::SetHybridPhysicsRadius, (arg("r"))) + .def("set_random_device_seed", &ctm::TrafficManager::SetRandomDeviceSeed, (arg("value"))) + .def("set_osm_mode", &carla::traffic_manager::TrafficManager::SetOSMMode, (arg("mode_switch"))) + .def("set_path", &InterSetCustomPath, (arg("actor"), arg("path"), arg("empty_buffer")=true)) + .def("set_route", &InterSetImportedRoute, (arg("actor"), arg("path"), arg("empty_buffer")=true)) + .def("set_respawn_dormant_vehicles", &carla::traffic_manager::TrafficManager::SetRespawnDormantVehicles, (arg("mode_switch"))) + .def("set_boundaries_respawn_dormant_vehicles", &carla::traffic_manager::TrafficManager::SetBoundariesRespawnDormantVehicles, (arg("lower_bound"), arg("upper_bound"))) + .def("get_next_action", &InterGetNextAction, (arg("actor"))) + .def("get_all_actions", &InterGetActionBuffer, (arg("actor"))) .def("shut_down", &ctm::TrafficManager::ShutDown); }