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

Remove vehicle type from agent interface #1294

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions smarts/core/agent_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,6 @@ class AgentInterface:
The choice of action space, this action space also decides the controller that will be enabled.
"""

vehicle_type: str = "sedan"
"""
The choice of vehicle type.
"""

accelerometer: Union[Accelerometer, bool] = True
"""
Enable acceleration and jerk observations.
Expand All @@ -293,7 +288,6 @@ def __post_init__(self):
self.accelerometer = AgentInterface._resolve_config(
self.accelerometer, Accelerometer
)
assert self.vehicle_type in {"sedan", "bus"}

@staticmethod
def from_type(requested_type: AgentType, **kwargs):
Expand Down
5 changes: 0 additions & 5 deletions smarts/core/controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def perform_action(
controller_state,
sensor_state,
action_space,
vehicle_type,
):
"""Calls control for the given vehicle based on a given action space and action.
Args:
Expand All @@ -84,13 +83,9 @@ def perform_action(
The state of a vehicle sensor as relates to vehicle sensors.
action_space:
The action space of the provided action.
vehicle_type:
Vehicle type information about the given vehicle.
"""
if action is None:
return
if vehicle_type == "bus":
liu-allan marked this conversation as resolved.
Show resolved Hide resolved
assert action_space == ActionSpaceType.Trajectory
if action_space == ActionSpaceType.Continuous:
vehicle.control(
throttle=np.clip(action[0], 0.0, 1.0),
Expand Down
1 change: 0 additions & 1 deletion smarts/core/smarts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,6 @@ def _perform_agent_actions(self, agent_actions):
controller_state,
sensor_state,
agent_interface.action_space,
agent_interface.vehicle_type,
)

def _sync_vehicles_to_renderer(self):
Expand Down
11 changes: 8 additions & 3 deletions smarts/core/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,14 @@ def build_agent_vehicle(
SceneColors.Agent.value if trainable else SceneColors.SocialAgent.value
)

if agent_interface.vehicle_type == "sedan":
if mission.vehicle_spec == None:
vehicle_type = "sedan"
else:
vehicle_type = mission.vehicle_spec.veh_config_type
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this the right place to get the vehicle type?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, although I am slightly confused as to why the vehicle_spec is inside the mission rather than in the plan.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

where should vehicle_spec be specified then?


if vehicle_type == "sedan":
urdf_name = "vehicle"
elif agent_interface.vehicle_type == "bus":
elif vehicle_type == "bus":
urdf_name = "bus"
else:
raise Exception("Vehicle type does not exist!!!")
Expand All @@ -406,7 +411,7 @@ def build_agent_vehicle(
vehicle_filepath = str(path.absolute())

controller_parameters = sim.vehicle_index.controller_params_for_vehicle_type(
agent_interface.vehicle_type
vehicle_type
)

chassis = None
Expand Down