mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-11-03 10:24:11 +08:00
gen7 model
This commit is contained in:
@@ -33,6 +33,7 @@ enum ModelGeneration {
|
||||
four @4;
|
||||
five @5;
|
||||
six @6;
|
||||
seven @7;
|
||||
}
|
||||
|
||||
struct ControlsStateSP @0x81c2f05a394cf4af {
|
||||
|
||||
@@ -76,14 +76,14 @@ class Plan:
|
||||
class Meta:
|
||||
ENGAGED = slice(0, 1)
|
||||
# next 2, 4, 6, 8, 10 seconds
|
||||
GAS_DISENGAGE = slice(1, 41, 8)
|
||||
BRAKE_DISENGAGE = slice(2, 41, 8)
|
||||
STEER_OVERRIDE = slice(3, 41, 8)
|
||||
HARD_BRAKE_3 = slice(4, 41, 8)
|
||||
HARD_BRAKE_4 = slice(5, 41, 8)
|
||||
HARD_BRAKE_5 = slice(6, 41, 8)
|
||||
GAS_PRESS = slice(7, 41, 8)
|
||||
BRAKE_PRESS = slice(8, 41, 8)
|
||||
GAS_DISENGAGE = slice(1, 31, 6)
|
||||
BRAKE_DISENGAGE = slice(2, 31, 6)
|
||||
STEER_OVERRIDE = slice(3, 31, 6)
|
||||
HARD_BRAKE_3 = slice(4, 31, 6)
|
||||
HARD_BRAKE_4 = slice(5, 31, 6)
|
||||
HARD_BRAKE_5 = slice(6, 31, 6)
|
||||
# next 0, 2, 4, 6, 8, 10 seconds
|
||||
LEFT_BLINKER = slice(41, 53, 2)
|
||||
RIGHT_BLINKER = slice(42, 53, 2)
|
||||
GAS_PRESS = slice(31, 55, 4)
|
||||
BRAKE_PRESS = slice(32, 55, 4)
|
||||
LEFT_BLINKER = slice(33, 55, 4)
|
||||
RIGHT_BLINKER = slice(34, 55, 4)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from enum import IntFlag
|
||||
import os
|
||||
import os, sys
|
||||
|
||||
from cereal import custom
|
||||
from openpilot.common.params import Params
|
||||
@@ -33,7 +33,9 @@ class ModelCapabilities(IntFlag):
|
||||
In V2, 'prev_desired_curv' (no plural) is used as the input for the same 'desired_curvature' output.
|
||||
"""
|
||||
|
||||
TemporalPoseV1 = 2 ** 5
|
||||
PlanTemporalPose = 2 ** 5
|
||||
|
||||
ModelOutputSlicesV1 = 2 ** 6
|
||||
|
||||
|
||||
class CustomModelMetadata:
|
||||
@@ -53,8 +55,11 @@ class CustomModelMetadata:
|
||||
|
||||
def get_model_capabilities(self) -> ModelCapabilities:
|
||||
"""Returns the model capabilities for a given generation."""
|
||||
if self.generation == ModelGeneration.six:
|
||||
return ModelCapabilities.TemporalPose
|
||||
if self.generation == ModelGeneration.seven:
|
||||
return ModelCapabilities.DesiredCurvatureV2 | ModelCapabilities.PlanTemporalPose | \
|
||||
ModelCapabilities.ModelOutputSlicesV1
|
||||
elif self.generation == ModelGeneration.six:
|
||||
return ModelCapabilities.DesiredCurvatureV2 | ModelCapabilities.PlanTemporalPose
|
||||
elif self.generation == ModelGeneration.five:
|
||||
return ModelCapabilities.DesiredCurvatureV2
|
||||
elif self.generation == ModelGeneration.four:
|
||||
@@ -68,3 +73,22 @@ class CustomModelMetadata:
|
||||
else:
|
||||
# Default model is meant to represent the capabilities of the prebuilt model
|
||||
return ModelCapabilities.Default
|
||||
|
||||
def custom_meta(self):
|
||||
if self.capabilities & ModelCapabilities.ModelOutputSlicesV1:
|
||||
class Meta:
|
||||
ENGAGED = slice(0, 1)
|
||||
# next 2, 4, 6, 8, 10 seconds
|
||||
GAS_DISENGAGE = slice(1, 41, 8)
|
||||
BRAKE_DISENGAGE = slice(2, 41, 8)
|
||||
STEER_OVERRIDE = slice(3, 41, 8)
|
||||
HARD_BRAKE_3 = slice(4, 41, 8)
|
||||
HARD_BRAKE_4 = slice(5, 41, 8)
|
||||
HARD_BRAKE_5 = slice(6, 41, 8)
|
||||
GAS_PRESS = slice(7, 41, 8)
|
||||
BRAKE_PRESS = slice(8, 41, 8)
|
||||
# next 0, 2, 4, 6, 8, 10 seconds
|
||||
LEFT_BLINKER = slice(41, 53, 2)
|
||||
RIGHT_BLINKER = slice(42, 53, 2)
|
||||
|
||||
sys.modules['constants'].Meta = Meta
|
||||
|
||||
@@ -186,11 +186,17 @@ def fill_model_msg(base_msg: capnp._DynamicStructBuilder, extended_msg: capnp._D
|
||||
|
||||
# temporal pose
|
||||
temporal_pose = modelV2.temporalPose
|
||||
if custom_model_valid and custom_model_capabilities & ModelCapabilities.TemporalPoseV1:
|
||||
temporal_pose.trans = net_output_data['sim_pose'][0,:3].tolist()
|
||||
temporal_pose.transStd = net_output_data['sim_pose_stds'][0,:3].tolist()
|
||||
temporal_pose.rot = net_output_data['sim_pose'][0,3:].tolist()
|
||||
temporal_pose.rotStd = net_output_data['sim_pose_stds'][0,3:].tolist()
|
||||
if custom_model_valid:
|
||||
if custom_model_capabilities & ModelCapabilities.PlanTemporalPose:
|
||||
temporal_pose.trans = net_output_data['sim_pose'][0,:3].tolist()
|
||||
temporal_pose.transStd = net_output_data['sim_pose_stds'][0,:3].tolist()
|
||||
temporal_pose.rot = net_output_data['sim_pose'][0,3:].tolist()
|
||||
temporal_pose.rotStd = net_output_data['sim_pose_stds'][0,3:].tolist()
|
||||
else:
|
||||
temporal_pose.trans = net_output_data['plan'][0,0,Plan.VELOCITY].tolist()
|
||||
temporal_pose.transStd = net_output_data['plan_stds'][0,0,Plan.VELOCITY].tolist()
|
||||
temporal_pose.rot = net_output_data['plan'][0,0,Plan.ORIENTATION_RATE].tolist()
|
||||
temporal_pose.rotStd = net_output_data['plan_stds'][0,0,Plan.ORIENTATION_RATE].tolist()
|
||||
else:
|
||||
temporal_pose.trans = net_output_data['plan'][0,0,Plan.VELOCITY].tolist()
|
||||
temporal_pose.transStd = net_output_data['plan_stds'][0,0,Plan.VELOCITY].tolist()
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user