Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change env configuration, added option for acceleration/steering velocity input #74

Merged
merged 10 commits into from
Jul 9, 2023

Conversation

hzheng40
Copy link
Member

@hzheng40 hzheng40 commented Jun 20, 2023

Fixes #72 #73
Also linting (sorry)

@hzheng40 hzheng40 added the enhancement New feature or request label Jun 20, 2023
Copy link
Collaborator

@luigiberducci luigiberducci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good. I think would be better to separate the action from update_pose for future extensions to new actions (e.g., discrete).

Please address minor changes in the comments.

self.steer_buffer = np.append(raw_steer, self.steer_buffer)
else:
steer = self.steer_buffer[-1]
self.steer_buffer = self.steer_buffer[:-1]
self.steer_buffer = np.append(raw_steer, self.steer_buffer)

if self.control_input == "speed":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about creating an action abstraction that process the given action and returns acceleration and steering velocity?

This would allow:

  • a cleaner extension to more actions (e.g., discrete, meta-action, etc.), instead of starting nesting if-then-else.
  • better separation between action processing and update_pose

For example, assuming update_pose is only responsible for stepping the dynamics model given acceleration and steering velocity, we could change line 640 as:

# looping over agents  
for i, agent in enumerate(self.agents):
    # update each agent's pose
    accl, sv = self.action_type.act(action)    # action_type implements the conversion to accl, sv
    current_scan = agent.update_pose(accl, sv)
    agent_scans.append(current_scan)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added classes for action types and specific implementations when they take actions to accl and sv.
I kept the accl and sv calculation at where it is right now, and will change that in a new pr with the update_pose changes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the implementation looks good.

Imo base_classes.py contains too many things. I moved it into a separate file action.py

@hzheng40 check if it is ok please

gym/f110_gym/envs/base_classes.py Show resolved Hide resolved
gym/f110_gym/envs/f110_env.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@luigiberducci luigiberducci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move mapping string->integrator in the Integrator definition, to avoid separate implementation in two files

gym/f110_gym/envs/base_classes.py Show resolved Hide resolved
gym/f110_gym/envs/f110_env.py Outdated Show resolved Hide resolved
gym/f110_gym/envs/f110_env.py Outdated Show resolved Hide resolved
hzheng40 and others added 4 commits July 5, 2023 11:25
update string mapping method

Co-authored-by: Luigi Berducci <luigi.berd@gmail.com>
update string mapping method

Co-authored-by: Luigi Berducci <luigi.berd@gmail.com>
update string mapping method

Co-authored-by: Luigi Berducci <luigi.berd@gmail.com>
@hzheng40
Copy link
Member Author

hzheng40 commented Jul 5, 2023

Updated, @luigiberducci please check again.

move deep_update in utils.py,
update f110_env.py accordingly
add test to check params update is propagated to simulator and racecars
rename gym_api_test.py to f110_env_test.py,
move test configure() in f110_env_test.py,
refactoring utility test
Copy link
Collaborator

@luigiberducci luigiberducci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes:

  • The implementation has been separated into utils.py and action.py.
  • The bug of the configure method has been fixed.
  • Added tests for utils and configure.
  • The old tests have been adapted to the new signature of the env constructor.
  • Renamed test file from gym_api_test.py to f110_env_test.py

LGTM

self.steer_buffer = np.append(raw_steer, self.steer_buffer)
else:
steer = self.steer_buffer[-1]
self.steer_buffer = self.steer_buffer[:-1]
self.steer_buffer = np.append(raw_steer, self.steer_buffer)

if self.control_input == "speed":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the implementation looks good.

Imo base_classes.py contains too many things. I moved it into a separate file action.py

@hzheng40 check if it is ok please

gym/f110_gym/envs/f110_env.py Outdated Show resolved Hide resolved
@hzheng40
Copy link
Member Author

hzheng40 commented Jul 9, 2023

Looks good, thanks! Merging.

@hzheng40 hzheng40 merged commit 00ff1d3 into v1.0.0 Jul 9, 2023
@luigiberducci luigiberducci deleted the update_config_method branch July 9, 2023 11:18
@luigiberducci luigiberducci restored the update_config_method branch July 11, 2023 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants