gecko_messages
Project description
Messages
Message formats should be short and simple, but if you want, it can also be complex.
Files:
imu.toml
where the name of the message is the name of the fileglobal.toml
which holds common or global setting for all
toml(file) - > dict -> create_c/py -> string -> file
toml(string) -> dict -> create_c/py -> string -> file
read_folder(dir_path, output_path=./) -> calls below functions
read_toml(file) -> dict
read_tomls(string) -> dict
Msg_file(file_path, global_file=file_path/global.toml, output_path=./) -> string
Msg_string(str, global_str) -> string
Binary: https://linuxcommandlibrary.com/man/protoc
msgcomp [--out_dir=DIR][--in_dir=DIR][--version][--verbose][--help][--cpp-only][--python-only]
verbose: num msg found: x global found: t/f Id, Msg_name, size, fmt …
Cpp and python need id2msg(int) -> string
Message File
Message use standard types:
uint8
orint8
uint16
orint16
uint32
orint32
uint64
orint64
float
Or complex types:
ID | Message | Info |
---|---|---|
1 | vec_t |
{float x,y,z} |
2 | quat_t |
{float w,x,y,z} |
3 | twist_t |
{vec_t linear, vec_t angular} |
4 | wrench_t |
{vec_t force, vec_t torque} |
5 | pose_t |
{vec_t position, quat_t orientation} |
Global
Now you can shorten your message file because a lot of the keys are repetitive across
message files. Basically, anything in the “global” space of a message file can be moved
to a global.toml
file instead of putting it into a message file.
[global]
comments = "string"
namespace = "string"
license = "string" # full text of what you want at the top of each file
version = "string" # anything you want like 1.0.2 or 2022.2.23
frozen = "bool" # is python dataclass frozen true or false
wrap_width = "int" # line width for text wrapping, default = 70
[global.serialize]
yivo = "bool" # true | false
mavlink = "bool"
# put native types in var_types VarTypes(name, size, fmt, id) ... native ids = 0,
# complex ids > 0, remove complex altogether ids between 20 - 255. This is nice
# to put message ids here, because you can see them all in one place and know you don’t
# have any conflicts.
[global.ids]
imu_t = int
calibration_t = int
my_cool_msg = int
awesome_msg = int
Message
[enum.name] # optional, can have many of these, each must have
# an original name and each value in an enum must
# be unique (python uses `@unique` from `enum`
# library)
Val1 = 1
Val2 = 2
Val3 = 3
# since python is not a strongly typed language, it will not always respect
# default types, so what should be an array (float[3]), you can set to a
# scalar int. C is the only one that will complain if you do this.
[message]
# type-var_name = array_dimension
float-x = 1 # float x = 0 or default
float-y = 2 # float y[2]{0,0} or default
float-z = 1 # var names can only be ascii letters, numbers and -
vec_t-a = 2 # vec_t a[2]{{0,0,0},{0,0,0}}
# add `#include “vec_t.hpp”` and `from vec_t import *` when generated
comments = "string" # optional, will be attached to the `struct`
id = "bool" # can be in global.toml [ids] or here, value must be between 20 - 255
frozen = "bool" # only for python dataclass
[message.defaults] # optional, don't need to do this
x = 12 # set defaults for variables
y = [1,2] # don't need to define defaults for all variables
# this is really a message library for serialization, so only put functions if
# you really need to, otherwise, let some other part of your code base
# handle this
[functions]
c = "string"
python = "string"
The minimum message file is:
[message]
float-x = 1
id = 33 # this can be in global.toml under [global.ids]
name = "simple"
To Do
- Add defaults to message
- Fix
python
3.8 - 3.10 withtomlkit
- Added ranges to types, but don't use them, remove?
- Add global wrap size default to 70 char wide
- Add
py
andc
for builtin messages, wantvec
in message andvec_t
inc
- Fix comments ... do I need them?
- Fix or remove automatic defaults, messages with new types are not
getting setup correctly with defaults. Only allow custom defaults
for new messages. Maybe embed default in each type class or
None
if no default?
MIT License
Copyright (c) 2023 gecko-robotics
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gecko_messages-2024.2.25.tar.gz
.
File metadata
- Download URL: gecko_messages-2024.2.25.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.8 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b66a46a0106dd1d67129ac53cf256a41ae948f7af82e030c9efa320fc02e9a6f |
|
MD5 | 5146a3dbaf1729aa5408a74bc588304b |
|
BLAKE2b-256 | e22acc022e653fe9fd3eb99c51dd810c36f53516a85298fce041f5228d4cc81f |
File details
Details for the file gecko_messages-2024.2.25-py3-none-any.whl
.
File metadata
- Download URL: gecko_messages-2024.2.25-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.8 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 416576da07144af693c55118d1cd2441020a875ce0bcee577ff5a35a30ed5db7 |
|
MD5 | 8d222f92b6ff46f0a2aa33c4f773b9c3 |
|
BLAKE2b-256 | 3621a8670165b5fa16ce45d71b64c8faf5ec659657080eb5fc5917085911843a |