Skip to content

Commit 3783520

Browse files
jdsikaCopilot
andcommitted
Add .github/copilot-instructions.md for Copilot context
Document build/test commands, proto dependency hierarchy, top-level container messages, commenting conventions, validation rules, code style, versioning scheme, CI pipeline, and key codebase conventions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5b72733 commit 3783520

1 file changed

Lines changed: 142 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Copilot Instructions for Open Simulation Interface (OSI)
2+
3+
## Overview
4+
5+
OSI is a Protocol Buffers (proto2) interface specification for environmental perception of automated driving functions. All `.proto` files use `syntax = "proto2"`, `option optimize_for = SPEED`, and belong to `package osi3`.
6+
7+
## Build & Test
8+
9+
**Run all tests:**
10+
11+
```sh
12+
pip install pyyaml
13+
python -m unittest discover tests
14+
```
15+
16+
**Run a single test file or test case:**
17+
18+
```sh
19+
python -m unittest tests.test_rules
20+
python -m unittest tests.test_rules.TestRules.test_rules_compliance
21+
```
22+
23+
**Validate proto compilation** (requires `grpcio-tools`):
24+
25+
```sh
26+
python -m grpc_tools.protoc --proto_path=. --python_out=. osi_common.proto osi_occupant.proto
27+
```
28+
29+
**Build Doxygen docs** (requires CMake, Doxygen, proto2cpp):
30+
31+
```sh
32+
mkdir build && cd build
33+
cmake -D FILTER_PROTO2CPP_PY_PATH=<path-to-proto2cpp> ../
34+
cmake --build . --config Release
35+
```
36+
37+
## Architecture
38+
39+
### Proto Dependency Hierarchy
40+
41+
```
42+
osi_version.proto.in (template → osi_version.proto via CMake)
43+
44+
osi_common.proto (primitives: Vector3d, Timestamp, Identifier, BoundingBox, etc.)
45+
46+
building blocks (osi_object, osi_lane, osi_environment, osi_trafficsign, osi_trafficlight,
47+
osi_roadmarking, osi_occupant, osi_logicallane, osi_referenceline, osi_route, …)
48+
49+
top-level containers (see below)
50+
```
51+
52+
### Top-Level Container Messages
53+
54+
| Message | File | Role |
55+
|---------|------|------|
56+
| `GroundTruth` | `osi_groundtruth.proto` | Complete simulated environment state |
57+
| `SensorView` | `osi_sensorview.proto` | Input to a sensor model (GroundTruth + config) |
58+
| `SensorData` | `osi_sensordata.proto` | Output of a sensor model (detected entities) |
59+
| `HostVehicleData` | `osi_hostvehicledata.proto` | Vehicle's own internal state perception |
60+
| `StreamingUpdate` | `osi_streamingupdate.proto` | Partial/incremental updates |
61+
| `SensorDataSeries` | `osi_datarecording.proto` | Time-series recording wrapper |
62+
63+
### Detected vs Ground Truth Pattern
64+
65+
Ground truth entities (e.g. `MovingObject`, `Occupant`, `Lane`) live in `GroundTruth`. Each has a corresponding `Detected*` message (e.g. `DetectedMovingObject`, `DetectedOccupant`, `DetectedLane`) in `SensorData` that wraps a list of candidates with probabilities.
66+
67+
## Proto Commenting Conventions
68+
69+
Every message, enum, and field **must** have a comment. CI tests enforce this.
70+
71+
### Messages and Enums
72+
73+
Must start with `\brief` on a separate comment line:
74+
75+
```proto
76+
//
77+
// \brief A cartesian 3D vector for positions, velocities or accelerations.
78+
//
79+
// The coordinate system is defined as right-handed.
80+
//
81+
message Vector3d
82+
{
83+
```
84+
85+
### Fields
86+
87+
Minimum 2 comment lines (content + blank `//`). Units on a separate line:
88+
89+
```proto
90+
// The number of seconds since start.
91+
//
92+
// Unit: s
93+
//
94+
optional int64 seconds = 1;
95+
```
96+
97+
### Validation Rules
98+
99+
Wrap in `\rules` / `\endrules` blocks. Available rules are defined in `rules.yml`:
100+
101+
```proto
102+
// \rules
103+
// is_greater_than_or_equal_to: 0
104+
// is_less_than_or_equal_to: 999999999
105+
// \endrules
106+
```
107+
108+
Available rule keywords: `is_greater_than`, `is_greater_than_or_equal_to`, `is_less_than`, `is_less_than_or_equal_to`, `is_equal_to`, `is_different_to`, `is_globally_unique`, `refers_to`, `is_iso_country_code`, `first_element`, `last_element`, `check_if ... else do_check`, `is_set`, `minimum_length`, `maximum_length`.
109+
110+
### Other Doxygen Markers
111+
112+
- `\note` — important notes
113+
- `\attention` — deprecation warnings
114+
- `\c TypeName` — inline code/type reference
115+
- `\image html filename.svg "caption" width=550px` — image reference
116+
- `\b text` — bold
117+
118+
## Code Style
119+
120+
Defined in `.clang-format`: Google base style, 4-space indent, 80-column limit, Allman braces (`{` on new line), no tabs.
121+
122+
## Versioning
123+
124+
`VERSION` file holds `VERSION_MAJOR`, `VERSION_MINOR`, `VERSION_PATCH`. CMake substitutes these into `osi_version.proto.in``osi_version.proto`. Current version: **3.8.0**.
125+
126+
## CI Pipeline
127+
128+
GitHub Actions (`protobuf.yml`) runs on push/PR to master:
129+
1. **Spellcheck** — aspell via pyspelling (custom wordlist at `.github/spelling_custom_words_en_US.txt`)
130+
2. **Tests**`python -m unittest discover tests`
131+
3. **Doxygen build** — generates API docs from proto comments
132+
133+
## Key Conventions
134+
135+
- All proto field numbers are stable — never reuse or renumber existing fields.
136+
- `repeated` fields use singular names (e.g. `repeated WheelData wheel_data`, not `wheel_datas`).
137+
- Enum values are prefixed with the enum type in UPPER_SNAKE_CASE (e.g. enum `Seat``SEAT_FRONT_LEFT`).
138+
- IDs use the `Identifier` message type and are typically `is_globally_unique`.
139+
- Cross-references between entities use `refers_to` rules (e.g. `refers_to: MovingObject`).
140+
- Coordinate system is right-handed, following ISO 8855 for vehicles.
141+
- Bounding box offsets follow the `bbcenter_to_*` naming pattern (e.g. `bbcenter_to_rear`, `bbcenter_to_root`).
142+
- PRs require DCO sign-off and "ReadyForCCBReview" label for Change Control Board review.

0 commit comments

Comments
 (0)