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

Simulator: cleanup in preparation for metadrive #29903

Merged
merged 9 commits into from
Sep 15, 2023
Merged

Conversation

jnewb1
Copy link
Contributor

@jnewb1 jnewb1 commented Sep 13, 2023

With the goal of adding metadrive as another simulator. Mostly taken from #27373

  • bridge -> run_bridge, with --simulator argument that can switch between multiple possible simulators
  • bridge/common.py for everything thats generic, and a SimulatorBridge base class
  • bridge/carla.py for everything specific to carla, and CarlaBridge class
  • VehicleState -> SimulatorState, which contains everything we need to give OP feedback and prevents passing a bunch of arguments to a bunch of functions
  • use openpilot's engaged variable and send manual gas/brake values back to OP to disengage
  • create simulated_car and simulated_sensors for sending all the feedback to OP

@github-actions github-actions bot added simulation running openpilot in environments like CARLA tools labels Sep 13, 2023
@jnewb1 jnewb1 changed the title Simulator: bridge cleanup Simulator: cleanup in preparation for metadrive Sep 13, 2023
@@ -339,7 +339,7 @@ def update_events(self, CS):
self.events.add(EventName.cameraMalfunction)
elif not self.sm.all_freq_ok(self.camera_packets):
self.events.add(EventName.cameraFrameRate)
if not REPLAY and self.rk.lagging:
if not REPLAY and not SIMULATION and self.rk.lagging:
Copy link
Contributor

Choose a reason for hiding this comment

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

this shouldn't be ignored. openpilot doesn't need much to run realtime

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@jnewb1
Copy link
Contributor Author

jnewb1 commented Sep 14, 2023

@adeebshihadeh this is all the cleanup stuff for carla, which will allow metadrive to be a drop in replacement

@jnewb1 jnewb1 marked this pull request as ready for review September 14, 2023 22:00
self.num_selected_spawn_point = arguments.num_selected_spawn_point

def spawn_world(self):
import carla # pylint: disable=import-error
Copy link
Contributor

Choose a reason for hiding this comment

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

the pylint suppression needed?

world = client.load_world(self.town)

settings = world.get_settings()
#settings.synchronous_mode = True # Enables synchronous mode
Copy link
Contributor

Choose a reason for hiding this comment

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

is this dead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

runs much better without it, removed the commented line

Comment on lines 170 to 171
def close(self):
super().close()
Copy link
Contributor

Choose a reason for hiding this comment

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

just don't override it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

meant to call world.close, done


def spawn_world(self):
import carla # pylint: disable=import-error
def connect_carla_client(host: str, port: int):
Copy link
Contributor

Choose a reason for hiding this comment

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

why the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@@ -0,0 +1,171 @@
import numpy as np
from openpilot.common.params import Params
Copy link
Contributor

Choose a reason for hiding this comment

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

breakup the openpilot imports with a new line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@jnewb1 jnewb1 merged commit 7f6718a into master Sep 15, 2023
@jnewb1 jnewb1 deleted the sim-bridge-cleanup branch September 15, 2023 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
simulation running openpilot in environments like CARLA tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants