commaai / commaai/opendbc

Safety: group safety state into structs and move safety limiting into class methods

Open
#3,433 0 comments 0 reactions 0 assignees View on GitHub
car safety enhancement
Dominant language
Python
Stars
3.4k
Forks
2.3k
Avg merge
2d 8h
Merged PRs (30d)
39

Description

### Describe the bug or enhancement

Apply state grouping in structs like in newly introduced curvature safety to angle and torque
Curvature PR: https://github.com/commaai/opendbc/pull/3405

```c
typedef struct {
int desired_last;
uint32_t rt_msgs;
uint32_t rt_msgs_prev;
uint32_t ts_check_last;
struct sample_t meas;
} CurvatureSteeringState;
```

```python
@dataclass
class CurvatureSteeringLimits:
# Max accepted by the EPS
CURVATURE_MAX: float
MAX_LATERAL_ACCEL: float = MAX_LATERAL_ACCEL
MAX_LATERAL_JERK: float = MAX_LATERAL_JERK

def apply_limits(self, apply_curvature: float, apply_curvature_last: float, v_ego: float, curvature: float, lat_active: bool, steer_step: int) -> float:
```

### Provide a route where the issue occurs if applicable

_No response_

### openpilot version if applicable

_No response_

### Additional info

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing the curvature safety implementation in PR #3405 with the existing angle and torque safety code. Identify the state and safety-limiting entry points in those areas, then confirm that the refactor groups their state and moves limiting into methods without changing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
embedded-iot
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.