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

Json schema for COMP_METADATA_TYPE_VERSION, COMP_METADATA_TYPE_PARAMETER #1431

Merged
merged 5 commits into from
Aug 23, 2020

Conversation

DonLakeFlyer
Copy link
Contributor

@hamishwillee
Copy link
Collaborator

@DonLakeFlyer The output I'm generating for parameters in now matches this - so you could test against https://gist.github.com/hamishwillee/3779fcfb6bd368b1cd9fd3f84cbcb5b6

  1. For consistency it would be consistent to change these value names:
    • defaultValue > default
    • units > unit
  2. For smaller payload it might also make be worth changing:
  • shortDescription > shortDesc OR short_desc
  • longDescription > longDesc OR long_desc
  1. The schema appears correct, but unfortunately the validation doesn't work properly with respect to required": [ "name", "type" ], and "additionalProperties": false. I.e . you can remove the name field, or have any name you like for another field in the array. This is a problem not just in the online validator, but has been reported in some others.

@DonLakeFlyer
Copy link
Contributor Author

  1. For consistency it would be consistent to change these value names:

What is this trying to consistent with?

2. For smaller payload it might also make be worth changing:

That would save something like 10 bytes from a compressed file.

I'd rather keep the naming as is since it matches naming QGC has been using for years now. Changing it means changing all the internal json files in QGC. Certainly doable, but needs to be a decent enough reason. Since it will trash localizations on json files which have already been done.

@hamishwillee
Copy link
Collaborator

@DonLakeFlyer

Consistency with your other field names - ie min, max, increment are not minValue, maxValue, incrementValue because it is redundant.

Those are very good reasons to keep it the same (in particular the localisations). You're right that the amounts of memory we're talking are small, but Firmware people worry about bytes.

@DonLakeFlyer
Copy link
Contributor Author

Consistency with your other field names

Ah, got it. Let me look at changing those.

@hamishwillee
Copy link
Collaborator

Cool. I think it is just default and units that make sense to change. The others would be nice to have shorter, but completely defensible that you wouldn't want to.

@DonLakeFlyer
Copy link
Contributor Author

I did "shortDesc", "longDesc" and "default". I left "units" since "unit" just doesn't make sense to me as english.

"description": "Units for parameter value.",
"type": "string",
"default": "",
"comment": "A 'Known Unit' allows a GCS to convert between units like meters to feet as needed. Known Units are: 'm/meter/meter', 'vertical m' - vertical distance, 'cm/px', 'm/s', 'C' - celcius, 'm^2', 'g' - grams, 'centi-degrees', 'radians', 'norm'."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DonLakeFlyer Should we have a list of valid values here so we can validate against it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I look at the schema spec and it is not possible to define in schema a set of possible values, which can also include those play anything else you want. Only the "known" units can translate back/forth in a gcs ui. But units can be anything. You can have "foo" units if you want. It's just a textual label.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'll try for consistency in PX4 at least. The problem I see with the concept of known unit is that this is just saying what QGC does. It isn't clear whether the spec is mandating that a GCS does support translation between units here. I suspect not. If we are guiding/mandating I'd also almost prefer that we reduce the set of known units that we allow in order to get that consistency.

it might be worth changing the comment to something like:

Any unit may be used. A GCS may convert "known units" for locale-sensitive display (e.g. using metres and feet as needed). Commonly supported "known units" are: m/meter/meter, 'vertical m' (vertical distance), cm, px, m/s, C (celcius), m^2, g (grams), centi-degrees, radians, norm."

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DonLakeFlyer Should we recommend the set from PX4?: '%', 'Hz', 'mAh',
'rad', '%/rad', 'rad/s',
'bit/s', 'B/s',
'deg', 'deg*1e7', 'deg/s',
'celcius', 'gauss', 'gauss/s', 'mgauss', 'mgauss^2',
'hPa', 'kg', 'kg/m^2',
'mm', 'm', 'm/s', 'm/s^2', 'm/s^3', 'm/s^2/sqrt(Hz)', 'm/s/rad',
'Ohm', 'V',
'us', 'ms', 's'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me (QGC specifically) the only ones that really matter are the ones that QGC can do units translation on https://github.com/mavlink/qgroundcontrol/blob/master/src/FactSystem/FactMetaData.cc#L48. I don't know how that differs from say MP. But I assume it would be similar. Since they are a superset of PX4/ArduPilot parameter metadata translatable units. The rest are mostly for consitency I guess, but I"m not sure how critical that is with respect to getting units consistency across any mavlink system.

@hamishwillee
Copy link
Collaborator

Thanks @DonLakeFlyer . I've regenerated the param.json so you can look at it here: https://gist.github.com/hamishwillee/3779fcfb6bd368b1cd9fd3f84cbcb5b6

Some of the PX4 units look inconsistent - e.g. Hz, Hertz. I'll talk to Beat about that.

I'm pretty sure this is good but I propose we leave it unmerged until I manage to get PX4 exporting this properly and you able to test it.

@DonLakeFlyer
Copy link
Contributor Author

Hz, Hertz

Examples of non-translated units. That said there should still be "consistency".

@DonLakeFlyer
Copy link
Contributor Author

I propose we leave it unmerged until I manage to get PX4 exporting this properly and you able to test it.

You can merge it whenever you feel ready.

@auturgy
Copy link
Collaborator

auturgy commented Aug 6, 2020 via email

@hamishwillee
Copy link
Collaborator

@auturgy Good point, though FWIW these are recommendations only because these very much depend on what the (flight stack) specific parameters are. I just looked at what PX4 use, and there are some "interesting" options.

@DonLakeFlyer
Copy link
Contributor Author

I'm going to merge this instead of letting it sit here. It has no affect on the build. And I have new updates to make to it I want to discuss in a separate pull.

@DonLakeFlyer DonLakeFlyer merged commit ab160de into master Aug 23, 2020
@hamishwillee
Copy link
Collaborator

@DonLakeFlyer Cool - thanks. FYI, current status on PX4 is that we generate the parameter metadata. I was going to do most of the rest last week but I saw that Lorenz is looking at this, and it doesn't make sense for me to do anything in parallel.

@hamishwillee hamishwillee deleted the ParameterSchema branch August 23, 2020 23:08
@DonLakeFlyer
Copy link
Contributor Author

I saw that Lorenz is looking at this

Yup. Lorenz, Beat and I will be talking about it soon.

amilcarlucas pushed a commit to ArduPilot/mavlink that referenced this pull request Sep 22, 2020
…TER (mavlink#1431)

* Json schema for COMP_METADATA_TYPE_VERSION, COMP_METADATA_TYPE_PARAMETER

* Remove unnecessary commas from end of list

* Shorten names for smaller file size

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
amilcarlucas pushed a commit to amilcarlucas/mavlink that referenced this pull request Sep 25, 2020
…TER (mavlink#1431)

* Json schema for COMP_METADATA_TYPE_VERSION, COMP_METADATA_TYPE_PARAMETER

* Remove unnecessary commas from end of list

* Shorten names for smaller file size

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
amilcarlucas pushed a commit to amilcarlucas/mavlink that referenced this pull request Sep 29, 2020
…TER (mavlink#1431)

* Json schema for COMP_METADATA_TYPE_VERSION, COMP_METADATA_TYPE_PARAMETER

* Remove unnecessary commas from end of list

* Shorten names for smaller file size

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
amilcarlucas pushed a commit to amilcarlucas/mavlink that referenced this pull request Oct 5, 2020
…TER (mavlink#1431)

* Json schema for COMP_METADATA_TYPE_VERSION, COMP_METADATA_TYPE_PARAMETER

* Remove unnecessary commas from end of list

* Shorten names for smaller file size

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
peterbarker pushed a commit to peterbarker/mavlink that referenced this pull request Oct 13, 2020
…TER (mavlink#1431)

* Json schema for COMP_METADATA_TYPE_VERSION, COMP_METADATA_TYPE_PARAMETER

* Remove unnecessary commas from end of list

* Shorten names for smaller file size

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
tridge pushed a commit to ArduPilot/mavlink that referenced this pull request Oct 27, 2020
…TER (mavlink#1431)

* Json schema for COMP_METADATA_TYPE_VERSION, COMP_METADATA_TYPE_PARAMETER

* Remove unnecessary commas from end of list

* Shorten names for smaller file size

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants