longitudinal maneuvers fixups (#1209)
* corolla updates * lil more * lil more * fix --------- Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
parent
f99bb69180
commit
732bf8f12d
|
@ -79,29 +79,30 @@ MANEUVERS = [
|
||||||
Action(1, 2), Action(-1, 2),
|
Action(1, 2), Action(-1, 2),
|
||||||
Action(1, 2), Action(-1, 2),
|
Action(1, 2), Action(-1, 2),
|
||||||
],
|
],
|
||||||
|
repeat=2,
|
||||||
initial_speed=0.,
|
initial_speed=0.,
|
||||||
),
|
),
|
||||||
Maneuver(
|
Maneuver(
|
||||||
"brake step response: -1m/ss from 20mph",
|
"brake step response: -1m/ss from 20mph",
|
||||||
[Action(-1, 3),],
|
[Action(0, 2), Action(-1, 3)],
|
||||||
repeat=3,
|
repeat=3,
|
||||||
initial_speed=20. * Conversions.MPH_TO_MS,
|
initial_speed=20. * Conversions.MPH_TO_MS,
|
||||||
),
|
),
|
||||||
Maneuver(
|
Maneuver(
|
||||||
"brake step response: -4m/ss from 20mph",
|
"brake step response: -4m/ss from 20mph",
|
||||||
[Action(-4, 3),],
|
[Action(0, 2), Action(-4, 3)],
|
||||||
repeat=3,
|
repeat=3,
|
||||||
initial_speed=15. * Conversions.MPH_TO_MS,
|
initial_speed=20. * Conversions.MPH_TO_MS,
|
||||||
),
|
),
|
||||||
Maneuver(
|
Maneuver(
|
||||||
"gas step response: +1m/ss from 20mph",
|
"gas step response: +1m/ss from 20mph",
|
||||||
[Action(1, 3),],
|
[Action(0, 2), Action(1, 3)],
|
||||||
repeat=3,
|
repeat=3,
|
||||||
initial_speed=20. * Conversions.MPH_TO_MS,
|
initial_speed=20. * Conversions.MPH_TO_MS,
|
||||||
),
|
),
|
||||||
Maneuver(
|
Maneuver(
|
||||||
"gas step response: +4m/ss from 20mph",
|
"gas step response: +4m/ss from 20mph",
|
||||||
[Action(4, 3),],
|
[Action(0, 2), Action(4, 3)],
|
||||||
repeat=3,
|
repeat=3,
|
||||||
initial_speed=20. * Conversions.MPH_TO_MS,
|
initial_speed=20. * Conversions.MPH_TO_MS,
|
||||||
),
|
),
|
||||||
|
@ -161,31 +162,37 @@ def main(args):
|
||||||
with PandaRunner() as p:
|
with PandaRunner() as p:
|
||||||
print("\n\n")
|
print("\n\n")
|
||||||
|
|
||||||
|
maneuvers = MANEUVERS
|
||||||
|
if len(args.maneuvers):
|
||||||
|
maneuvers = [MANEUVERS[i-1] for i in set(args.maneuvers)]
|
||||||
|
|
||||||
logs = {}
|
logs = {}
|
||||||
rk = Ratekeeper(int(1./DT))
|
rk = Ratekeeper(int(1./DT))
|
||||||
for i, m in enumerate(MANEUVERS):
|
for i, m in enumerate(maneuvers):
|
||||||
logs[m.description] = {}
|
logs[m.description] = {}
|
||||||
print(f"Running {i+1}/{len(MANEUVERS)} '{m.description}'")
|
print(f"Running {i+1}/{len(MANEUVERS)} '{m.description}'")
|
||||||
for run in range(m.repeat):
|
for run in range(m.repeat):
|
||||||
print(f"- run #{run}")
|
print(f"- run #{run}")
|
||||||
print("- setting up, engage cruise")
|
print("- setting up, engage cruise")
|
||||||
ready_cnt = 0
|
ready_cnt = 0
|
||||||
for _ in range(int(60./DT)):
|
for _ in range(int(2*60./DT)):
|
||||||
cs = p.read(strict=False)
|
cs = p.read(strict=False)
|
||||||
|
|
||||||
cc = CarControl(
|
cc = CarControl(
|
||||||
enabled=True,
|
enabled=True,
|
||||||
longActive=True,
|
longActive=True,
|
||||||
actuators=CarControl.Actuators(
|
actuators=CarControl.Actuators(
|
||||||
accel=(m.initial_speed - cs.vEgo)*0.5,
|
accel=(m.initial_speed - cs.vEgo)*0.8,
|
||||||
longControlState=CarControl.Actuators.LongControlState.stopping if m.initial_speed < 0.1 else CarControl.Actuators.LongControlState.pid,
|
longControlState=CarControl.Actuators.LongControlState.pid,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
if m.initial_speed < 0.1:
|
||||||
|
cc.actuators.accel = -2
|
||||||
|
cc.actuators.longControlState = CarControl.Actuators.LongControlState.stopping
|
||||||
p.write(cc)
|
p.write(cc)
|
||||||
|
|
||||||
ready = cs.cruiseState.enabled and not cs.cruiseState.standstill and ((m.initial_speed - 0.3) < cs.vEgo < (m.initial_speed + 0.3))
|
ready = cs.cruiseState.enabled and not cs.cruiseState.standstill and ((m.initial_speed - 0.6) < cs.vEgo < (m.initial_speed + 0.6))
|
||||||
ready_cnt = (ready_cnt+1) if ready else 0
|
ready_cnt = (ready_cnt+1) if ready else 0
|
||||||
if ready_cnt > (3./DT):
|
if ready_cnt > (2./DT):
|
||||||
break
|
break
|
||||||
rk.keep_time()
|
rk.keep_time()
|
||||||
else:
|
else:
|
||||||
|
@ -207,6 +214,7 @@ def main(args):
|
||||||
|
|
||||||
rk.keep_time()
|
rk.keep_time()
|
||||||
|
|
||||||
|
print("writing out report")
|
||||||
with open('/tmp/logs.json', 'w') as f:
|
with open('/tmp/logs.json', 'w') as f:
|
||||||
import json
|
import json
|
||||||
json.dump(logs, f, indent=2)
|
json.dump(logs, f, indent=2)
|
||||||
|
@ -214,11 +222,14 @@ def main(args):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
maneuver_help = "\n".join([f"{i+1}. {m.description}" for i, m in enumerate(MANEUVERS)])
|
||||||
parser = argparse.ArgumentParser(description="A tool for longitudinal control testing.",
|
parser = argparse.ArgumentParser(description="A tool for longitudinal control testing.",
|
||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
formatter_class=argparse.RawTextHelpFormatter)
|
||||||
parser.add_argument('--desc', help="Extra description to include in report.")
|
parser.add_argument('--desc', help="Extra description to include in report.")
|
||||||
parser.add_argument('--output', help="Write out report to this file.", default=None)
|
parser.add_argument('--output', help="Write out report to this file.", default=None)
|
||||||
|
parser.add_argument('maneuvers', nargs='*', type=int, default=None, help=f'Deafult is all.\n{maneuver_help}')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
print(args)
|
||||||
|
|
||||||
if "REPORT_TEST" in os.environ:
|
if "REPORT_TEST" in os.environ:
|
||||||
with open(os.environ["REPORT_TEST"]) as f:
|
with open(os.environ["REPORT_TEST"]) as f:
|
||||||
|
|
Loading…
Reference in New Issue