question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Converting `highway-v0` to continuous control

See original GitHub issue

Hello! I’d like to know what is the best way to make a version of highway-v0 with continuous controls (steering and acceleration).

Looking at the source code, I reckon that the most straightforward way would be to implement a subclass of HighwayEnv and override its step method. It would then call

self.vehicle.act(
    {"acceleration": action[0] * self.ACCELERATION_RANGE,
    "steering": action[1] * self.STEERING_RANGE}
)

and then self.simulate() with no arguments, bypassing the automatic steering and acceleration presets.

However, I’m not sure how to detect lane changes, which are necessary for calculating the reward. Any help would be appreciated, as there’s quite a bit of code to look at.

Great job with the simulations btw!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
eleurentcommented, Jan 16, 2020

That looks great! I chose to use the target lane/velocity instead of the true state in the reward function so as to avoid skipping a reward because of a potential lag in the control response, but your changes make a lot of sense in the case of a Vehicle. I’m closing this issue but please, definitely feel free to open another one if you have more questions! ALSO: if you come up with a new interesting environment, please consider opening a pull request 😃 Edouard

0reactions
0xangelocommented, Jan 15, 2020

Calling Vehicle.create_random totally works! This is what I’m doing now:

    @override(HighwayEnv)
    def _create_vehicles(self):
        self.vehicle = Vehicle.create_random(self.road, 0)
        self.road.vehicles.append(self.vehicle)
        ...

I also had to update _reward, since Vehicle does not have some attributes that MDPVehicle has.

    @override(HighwayEnv)
    def _reward(self, _):
        idx = self._curr_lane()
        action_reward = self.LANE_CHANGE_REWARD if idx != self._old_lane else 0
        self._old_lane = idx
        neighbours = self.road.network.all_side_lanes(self.vehicle.lane_index)
        state_reward = (
            +self.config["collision_reward"] * self.vehicle.crashed
            + self.RIGHT_LANE_REWARD
            * self.vehicle.lane_index[2]   # Changed from vehicle.target_lane_index
            / (len(neighbours) - 1)
            + self.HIGH_VELOCITY_REWARD
            * MDPVehicle.speed_to_index(self.vehicle.velocity)  # Changed from vehicle.velocity_index
            / (MDPVehicle.SPEED_COUNT - 1)
        )
        return utils.remap(
            action_reward + state_reward,
            [
                self.config["collision_reward"],
                self.HIGH_VELOCITY_REWARD + self.RIGHT_LANE_REWARD,
            ],
            [0, 1],
        )

Again, thanks a lot for your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

highway-env Documentation
A goal-conditioned continuous control task in which the ego-vehicle must park in a given space with the appropriate heading.
Read more >
Safe and Efficient Reinforcement Learning for Behavioural ...
Optimistic Planning algorithm with Continuous actions ... perception systems and to act upon by control systems, and that they are ...
Read more >
arXiv:2009.12213v1 [cs.MA] 25 Sep 2020
To this end, we first convert the would-be stochastic game problem into ... For example, an optimal control framework [1] is put forward...
Read more >
How to convert a continuous time controller to a digital controller
Do zero-hold block enough to simulate desecrating continuous-time state-space model of controller? What I want to do is to convert my controller ......
Read more >
用于强化学习的自动驾驶仿真场景highway-env(2): obs,action
在 continuous low-level control 的基础上,增加了一层 speed and steering ... import gym import highway_env env = gym.make("highway-v0") ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found