Skip to content

Commit

Permalink
long maneuvers: add start from stop (commaai#33556)
Browse files Browse the repository at this point in the history
* long maneuvers: add start from stop

* fix

* git ignore
  • Loading branch information
adeebshihadeh authored Sep 13, 2024
1 parent 3da5dda commit 6ec6038
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions tools/longitudinal_maneuvers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/longitudinal_reports/
16 changes: 12 additions & 4 deletions tools/longitudinal_maneuvers/maneuversd.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ class Maneuver:
_ready_cnt: int = 0
_repeated: int = 0

def get_accel(self, v_ego: float, long_active: bool, standstill: bool) -> float:
ready = abs(v_ego - self.initial_speed) < 0.3 and long_active and not standstill
def get_accel(self, v_ego: float, long_active: bool, standstill: bool, cruise_standstill: bool) -> float:
ready = abs(v_ego - self.initial_speed) < 0.3 and long_active and not cruise_standstill
if self.initial_speed < 0.01:
ready = v_ego < 0.1 and standstill
self._ready_cnt = (self._ready_cnt + 1) if ready else 0

if self._ready_cnt > (3. / DT_MDL):
Expand Down Expand Up @@ -70,6 +72,12 @@ def active(self):


MANEUVERS = [
Maneuver(
"start from stop",
[Action(1.5, 3)],
repeat=3,
initial_speed=0.,
),
Maneuver(
"creep: alternate between +1m/s^2 and -1m/s^2",
[
Expand Down Expand Up @@ -135,12 +143,12 @@ def main():
v_ego = max(sm['carState'].vEgo, 0)

if maneuver is not None:
accel = maneuver.get_accel(v_ego, sm['carControl'].longActive, sm['carState'].cruiseState.standstill)
accel = maneuver.get_accel(v_ego, sm['carControl'].longActive, sm['carState'].standstill, sm['carState'].cruiseState.standstill)

if maneuver.active:
alert_msg.alertDebug.alertText1 = f'Maneuver Active: {accel:0.2f} m/s^2'
else:
alert_msg.alertDebug.alertText1 = f'Reaching Speed: {maneuver.initial_speed * CV.MS_TO_MPH:0.2f} mph'
alert_msg.alertDebug.alertText1 = f'Setting up to {maneuver.initial_speed * CV.MS_TO_MPH:0.2f} mph'
alert_msg.alertDebug.alertText2 = f'{maneuver.description}'
else:
alert_msg.alertDebug.alertText1 = 'Maneuvers Finished'
Expand Down

0 comments on commit 6ec6038

Please sign in to comment.