Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sim enums #209

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion cangen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Ex. If there are 5 messages of size one (booleans), add a 3 bit filler before ad
8. Unsent messages should only contain the size parameter
9. Make the topic of an EncodableCANMsg be `"Calypso/Bidir/State/{key}/{field_name}"`
10. The description field must be only letters and spaces, upper or lowercase
11. Sim enum frrquencies must add up to 1 or they will not be respected.

Message guide:
1. Use previous examples for most things
Expand Down Expand Up @@ -84,6 +85,10 @@ Occassionally you may want Calypso to also send a message on the CAN network. Us
- `is_ext`, boolean representing whether the CAN ID is extended or standard (`false` by default)
It is recommended that the decoding of the message be done to the topic `"Calypso/Bidir/State/{key}/{field_name}"`. Note decoding works exactly the same with these messages, so serves as an accurate representation of what Calypso is current sending out to the car.

Also, you should allow for simulation of the data point whenever possible.
- `sim_freq`, integer frequency of which this message is usually emitted, in ms



#### NetField

Expand All @@ -93,6 +98,7 @@ Within the `fields` member of a Message object, there is a list of NetField obje
- `points`, a list of Point objects to be used for this MQTT message
- `send` (optional), boolean representing whether this message should be send over the network (`true` by default)
- `topic_append` (optional), boolean representing whether to append the topic name with the value of the first CANPoint in `points` (`false` by default)
- `sim` (optional) a sim object to define simulation parameters


#### Point
Expand All @@ -102,7 +108,21 @@ Within the `points` member of a NetField object, there is a list of Point object
- `signed` (optional), boolean representing whether or not the number is signed in two's complement form (`false` by default)
- `endianness` (optional), string representing the byte endianness of the bits being read, either `"big"` or `"little"` (`"big"` by default)
- `format` (optional, not recommended), string representing the final type of the data (`"f32"` by default)
- `default` (optional, only for Encodable Messages), float representing the default value to be sent before a command is received or when an empty command is received. This is ignored when decoding the Point (`0` by default)
- `default_value` (optional, only for Encodable Messages), float representing the default value to be sent before a command is received or when an empty command is received. This is ignored when decoding the Point (`0` by default)

#### Sim
Within the `sim` member of a NetField object, there is a single sim object. This object is one of two types, either `sweep` or `enum`. However these types are implied, not written in the JSON, just use them correctly!

`sweep`: sweep a certain range of values
- `min`, float, the minium value to emit
- `max`, float, the maximum value to emit
- `inc_min`, float, the minimum increment
- `inc_max`, float, the maximum increment
- `round`, bool, whether to round values to a whole number (more precise rounding is not supported)

or
`enum`: choose from a certain list of values
- `options`, list[[`value`, `freq`]...], a list containing lists of length two. Each inner list's first item is the value to be emitted, and the second item is the probability the item should be emitted. **These probabilities must add to 1, or they won't be obeyed.**


### Directory Structure
Expand Down
Loading