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

Define config protobuf message type #153

Open
oliverlee opened this issue Mar 10, 2017 · 10 comments
Open

Define config protobuf message type #153

oliverlee opened this issue Mar 10, 2017 · 10 comments

Comments

@oliverlee
Copy link
Owner

oliverlee commented Mar 10, 2017

This is a build configuration option and can vary for different binaries. We should add the tick frequency to the protobuf message so that we can obtain timing information correctly and other fields related to the ChibiOS configuration.

tentative config schema

enum EnumSetupType {
    SIMULATOR = 0;
    STEERBYWIRE = 1;
}

enum EnumProjectType {
    UNSPECIFIED = 0;
    FLIMNAP_AREND = 1;
    FLIMNAP_KINEMATIC = 2;
    FLIMNAP_WHIPPLE = 3;
    FLIMNAP_ZERO_INPUT = 4;
}

message pbConfig {
    optional EnumSetupType setup = 0;
    optional EnumProjectType project = 1;
    optional FirmwareVersion gitsha1 = 2;
    optional bool build_ndebug = 3;
    optional bool ch_st_resolution_32 = 4; // 16-bit if false
    optional uint32 ch_st_frequency = 5;
    optional uint32 ch_rtc_frequency = 6;
    optional uint32 heartbeat_period = 7; // to be used for two-way communication?
}
@oliverlee oliverlee added this to the v0.2 milestone Mar 10, 2017
@mickvangelderen
Copy link
Collaborator

Or you could scale timing information.

@oliverlee
Copy link
Owner Author

Right now we record:
timestamp - units of system ticks (10 kHz in current master f2c686b, but I want to increase it to 100 kHz in PR #152)
computation time - units of realtime counter ticks (168 MHz)
transmission time - units of realtime counter ticks (168 MHz)

We could scale to microseconds and transmit. The issue that I can think of is if we reduce the size of the unsigned int use to store/transmit timing information from uint32_t to uint16_t or uint8_t, we'd have to be careful about overflow.

With uint32_t the timestamp will overflow in 4.97 days at 10 kHz and 11.9 hours at 100 kHz.

@mickvangelderen
Copy link
Collaborator

The way I see it now there are three options:

  1. leave as is, read clock frequencies from .h files
    • 👍 simple
    • 👎 fields do not have a consistent unit
  2. scale to a unit that works for all possible clock frequencies
    • 👍 fields have a consistent unit
    • 👎 chosen scaling might not work well if the clock frequency changes to a non-anticipated value
  3. transmit the counter frequencies
    • 👍 values can be expressed in consistent unit
    • 👎 lots of duplication in the output
    • 👎 mimicking what the exponent in a float does for you

@oliverlee
Copy link
Owner Author

  1. leave as is, read clock frequencies from .h files

One issue that could arise is if we use different clock frequencies in different headers/projects, we would need to know which is the right frequency when decoding.

  1. transmit the counter frequencies

I think we could just send the clock frequency once in the first message

@mickvangelderen
Copy link
Collaborator

  1. scale to a unit that works for all possible clock frequencies

Floats are precise up to 6 significant digits (23 bits give steps of 2^{-23} \approx 1.19\cdot10^{-7} ).

Usually relative timestamps can be represented by a float but an absolute timestamp cannot. The value must be < 2^23 to prevent loss of precision.

I think we could just send the clock frequency once in the first message

If we can send a few extra bytes per message to make each message individually interpret-able we should.

@oliverlee
Copy link
Owner Author

oliverlee commented Mar 23, 2017 via email

@oliverlee
Copy link
Owner Author

I think we need to fully define the protobuf message types, specifically the "configuration type", and the corresponding fields.

This is related to #181

@oliverlee oliverlee modified the milestones: Improved Demo, Post Demo Jun 15, 2017
@oliverlee oliverlee changed the title Add ChibiOS tick frequency as a protobuf message field Define config protobuf message type Jun 15, 2017
@oliverlee
Copy link
Owner Author

I'm also in favor of dropping the Message suffix and replacing it with a pb prefix until namespaces are supported.

@mickvangelderen
Copy link
Collaborator

mickvangelderen commented Jun 28, 2017

Just thought of something. We should include a session number because that might come in handy. There was a RNG unit on the microconroller right?

@oliverlee
Copy link
Owner Author

Let's try to switch to proto3 when implementing this and two-way communication, but fall back to proto2 if it doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants