Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This work is still in progress. Also, this PR might contain some radical changes
Description
This PR is an attempt to cope with #81. Instead of fixing the original
PathTracker
, I've decided to wrap aroundBasicAgent
class in Carla PythonAPI. ThisBasicAgent
comes with every distribution of Carla and the API we need (set_destination) haven't changed since 0.9.4. I think using a specific version of PythonAPI might lead to unknown issue in the future, so it is better to always use the compatible one.Besides refractoring the
PathTracker
class, there's some other things I've done in this branch.Changes
1. Autopilot with navigation
Carla's autopilot will randomly choose a way to go at intersection, thus just using
set_autopilot(True)
will not lead one actor to destination defined in scenario. I've mentioned two undocumented API in the issue, but it turned out both of them does not work properly (I guess that's why they don't document it).So instead of using autopilot, I choose to apply the control planned by
BasicAgent.run_step()
. This will navigate the actor to its desired end point. However,BasicAgent
only take traffic light and other vehicle in to account, meaning that some of its behavior might violate driving rules, e.g. it won't stop at stop-sign. There are also some potential undesired behavior, I'll describe in Known issue section below.2. Removal of unused files
There are some files never used in Macad-Gym, most code in them are currently in another file. I've decided to remove them.
Also, since PythonAPI is no longer fixed with one version, I removed the whole folder and added
PYTHONPATH
requirement in Readme.Known issue
1. Endless episode
In scenario SSUI3C_TOWN3, even with correct route and above navigation enabled, the
done
check will never meet. The problem is caused byget_orientation_difference_to_end_in_radians()
. The destination waypoint generate byBasicAgent
(or the GlobalRoutePlanner in current PathTracker) sometime has a strange rotation, resulting inORIENTATION_TO_GOAL_THRESHOLD
can't pass.BasicAgent
itself checks the planned route's length to decide whether the vehicle has reached its destination or not, which is similar to distance check. I wonder is the orientation really important for the done check?I also observed endless episode in some other scenario, like FollowLeadingVehicle.
BasicAgent
has some configurable parameter, such asbase_vehicle_threshold
andbase_tlight_threshold
. These parameters will affect control given byrun_step()
. In scenario FLV, the leading car might stop before traffic light even though it hasn't reached destination because ofbase_tlight_threshold
. And the following car might stop too early because ofbase_vehicle_threshold
. This is similar to some adjustment in autopilot (e.g.set_global_distance_to_leading_vehicle()
), I think each scenario should have their own configuration.2. Undesired Behavior
With the new navigation of autopilot feature enabled, it is very likely to meet some unexpected incident. For example, SSUI3C's planned route is like this:
It is possible that the fire truck turns left first, and it gets in the way of the bike. Vehicle will stop if they are already at their destination, and the bike will stop because of
base_vehicle_threshold
. I've added a feature that if an actor controlled by PathTracker has reached its destination then let Carla's autopilot take over the control.This solution might lead to some other unexpected, especially for the actor controlled by RL algorithm. So, I want to hear your opinion on that.
PS
I know that Macad-Gym is designed for multi-Agent RL training, so these changes might seem redundant. However, an actor with auto control enabled can be seen as a NPC, and to navigate the NPC to some specific destination is a potentially demanded feature. (at least for our group :)