gecko_messages


Namegecko_messages JSON
Version 2024.2.25 PyPI version JSON
download
home_pagehttps://pypi.org/project/gecko-messages/
Summarygecko_messages
upload_time2024-02-25 23:35:01
maintainer
docs_urlNone
authorwalchko
requires_python>=3.11
licenseMIT
keywords gecko messages robotics serial
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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 file
- `global.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` or `int8`
- `uint16` or `int16`
- `uint32` or `int32`
- `uint64` or `int64`
- `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.

```toml
[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

```toml
[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:

```toml
[message]
float-x = 1
id = 33  # this can be in global.toml under [global.ids]
name = "simple"
```

## To Do

- [x] Add defaults to message
- [ ] Fix `python` 3.8 - 3.10 with `tomlkit`
- [x] Added ranges to types, but don't use them, remove?
- [ ] Add global wrap size default to 70 char wide
- [ ] Add `py` and `c` for builtin messages, want `vec` in message and `vec_t` in `c`
- [ ] 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.
            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/gecko-messages/",
    "name": "gecko_messages",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "gecko,messages,robotics,serial",
    "author": "walchko",
    "author_email": "walchko@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/e2/2a/cc022e653fe9fd3eb99c51dd810c36f53516a85298fce041f5228d4cc81f/gecko_messages-2024.2.25.tar.gz",
    "platform": null,
    "description": "# Messages\n\nMessage formats should be short and simple, but if you want, it can also be complex.\n\nFiles:\n\n- `imu.toml` where the name of the message is the name of the file\n- `global.toml` which holds common or global setting for all\n\n```\ntoml(file) - > dict -> create_c/py -> string -> file\ntoml(string) -> dict -> create_c/py -> string -> file\n\nread_folder(dir_path, output_path=./) -> calls below functions\nread_toml(file) -> dict\nread_tomls(string) -> dict\n\nMsg_file(file_path, global_file=file_path/global.toml, output_path=./) -> string\nMsg_string(str, global_str) -> string\n```\n\nBinary:\nhttps://linuxcommandlibrary.com/man/protoc\n\n```\nmsgcomp [--out_dir=DIR][--in_dir=DIR][--version][--verbose][--help][--cpp-only][--python-only]\n```\n\nverbose:\nnum msg found: x\nglobal found: t/f\nId, Msg_name, size, fmt\n\u2026\n\nCpp and python need id2msg(int) -> string\n\n## Message File\n\nMessage use standard types:\n\n- `uint8` or `int8`\n- `uint16` or `int16`\n- `uint32` or `int32`\n- `uint64` or `int64`\n- `float`\n\nOr complex types:\n\n| ID | Message    | Info                             |\n|----|------------|----------------------------------|\n| 1  | `vec_t`    | {float x,y,z}\n| 2  | `quat_t`   | {float w,x,y,z}\n| 3  | `twist_t`  | {vec_t linear, vec_t angular}\n| 4  | `wrench_t` | {vec_t force, vec_t torque}\n| 5  | `pose_t`   | {vec_t position, quat_t orientation}\n\n\n## Global\n\nNow you can shorten your message file because a lot of the keys are repetitive across\nmessage files. Basically, anything in the \u201cglobal\u201d space of a message file can be moved\nto a `global.toml` file instead of putting it into a message file.\n\n```toml\n[global]\ncomments = \"string\"\nnamespace = \"string\"\nlicense = \"string\" # full text of what you want at the top of each file\nversion = \"string\" # anything you want like 1.0.2 or 2022.2.23\nfrozen = \"bool\"    # is python dataclass frozen true or false\nwrap_width = \"int\" # line width for text wrapping, default = 70\n\n[global.serialize]\nyivo = \"bool\"         # true | false\nmavlink = \"bool\"\n\n# put native types in var_types VarTypes(name, size, fmt, id) ... native ids = 0,\n# complex ids > 0, remove complex altogether ids between 20 - 255. This is nice\n# to put message ids here, because you can see them all in one place and know you don\u2019t\n# have any conflicts.\n[global.ids]\nimu_t = int\ncalibration_t = int\nmy_cool_msg = int\nawesome_msg = int\n```\n\n## Message\n\n```toml\n[enum.name] # optional, can have many of these, each must have\n            # an original name and each value in an enum must\n            # be unique (python uses `@unique` from `enum`\n            # library)\nVal1 = 1\nVal2 = 2\nVal3 = 3\n\n# since python is not a strongly typed language, it will not always respect\n# default types, so what should be an array (float[3]), you can set to a\n# scalar int. C is the only one that will complain if you do this.\n[message]\n# type-var_name = array_dimension\nfloat-x = 1  # float x = 0 or default\nfloat-y = 2  # float y[2]{0,0} or default\nfloat-z = 1  # var names can only be ascii letters, numbers and -\nvec_t-a = 2  # vec_t a[2]{{0,0,0},{0,0,0}}\n             # add `#include \u201cvec_t.hpp\u201d` and `from vec_t import *` when generated\n\ncomments = \"string\"     # optional, will be attached to the `struct`\nid = \"bool\"             # can be in global.toml [ids] or here, value must be between 20 - 255\nfrozen = \"bool\"         # only for python dataclass\n\n[message.defaults] # optional, don't need to do this\nx = 12      # set defaults for variables\ny = [1,2]   # don't need to define defaults for all variables\n\n# this is really a message library for serialization, so only put functions if\n# you really need to, otherwise, let some other part of your code base\n# handle this\n[functions]\nc = \"string\"\npython = \"string\"\n```\n\nThe minimum message file is:\n\n```toml\n[message]\nfloat-x = 1\nid = 33  # this can be in global.toml under [global.ids]\nname = \"simple\"\n```\n\n## To Do\n\n- [x] Add defaults to message\n- [ ] Fix `python` 3.8 - 3.10 with `tomlkit`\n- [x] Added ranges to types, but don't use them, remove?\n- [ ] Add global wrap size default to 70 char wide\n- [ ] Add `py` and `c` for builtin messages, want `vec` in message and `vec_t` in `c`\n- [ ] Fix comments ... do I need them?\n- [ ] Fix or remove automatic defaults, messages with new types are not\n      getting setup correctly with defaults. Only allow custom defaults\n      for new messages. Maybe embed default in each type class or `None`\n      if no default?\n\n# MIT License\n\n**Copyright (c) 2023 gecko-robotics**\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "gecko_messages",
    "version": "2024.2.25",
    "project_urls": {
        "Homepage": "https://pypi.org/project/gecko-messages/",
        "Repository": "https://github.com/gecko-robotics/messages"
    },
    "split_keywords": [
        "gecko",
        "messages",
        "robotics",
        "serial"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3621a8670165b5fa16ce45d71b64c8faf5ec659657080eb5fc5917085911843a",
                "md5": "8d222f92b6ff46f0a2aa33c4f773b9c3",
                "sha256": "416576da07144af693c55118d1cd2441020a875ce0bcee577ff5a35a30ed5db7"
            },
            "downloads": -1,
            "filename": "gecko_messages-2024.2.25-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8d222f92b6ff46f0a2aa33c4f773b9c3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 17987,
            "upload_time": "2024-02-25T23:34:59",
            "upload_time_iso_8601": "2024-02-25T23:34:59.932267Z",
            "url": "https://files.pythonhosted.org/packages/36/21/a8670165b5fa16ce45d71b64c8faf5ec659657080eb5fc5917085911843a/gecko_messages-2024.2.25-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e22acc022e653fe9fd3eb99c51dd810c36f53516a85298fce041f5228d4cc81f",
                "md5": "5146a3dbaf1729aa5408a74bc588304b",
                "sha256": "b66a46a0106dd1d67129ac53cf256a41ae948f7af82e030c9efa320fc02e9a6f"
            },
            "downloads": -1,
            "filename": "gecko_messages-2024.2.25.tar.gz",
            "has_sig": false,
            "md5_digest": "5146a3dbaf1729aa5408a74bc588304b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 12808,
            "upload_time": "2024-02-25T23:35:01",
            "upload_time_iso_8601": "2024-02-25T23:35:01.716552Z",
            "url": "https://files.pythonhosted.org/packages/e2/2a/cc022e653fe9fd3eb99c51dd810c36f53516a85298fce041f5228d4cc81f/gecko_messages-2024.2.25.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-25 23:35:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gecko-robotics",
    "github_project": "messages",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "gecko_messages"
}
        
Elapsed time: 0.18637s