Skip to main content

Coordinate-transforms code generator

Project description

This is the Coordinate-Transform code-generation tool (ctgen).

ctgen is a command line program that generates source code implementing a user-defined set of coordinate transformation matrices.

The language of the generated source code depends on the selected "backend". At the moment Octave and C++ are supported.

The purpose of this tool is to spare the user from boring and error prone development. The main input of ctgen is a simple specification of the relative poses between some frames, which describe the user's problem. This file is a documented sample input.

The output is source code which implements some transforms between the same frames, i.e., code that defines the right matrices with the right coefficients. More specific features of the generated code depend on the selected backend.

Installation

git clone <this repo> ctgen
cd ctgen/
pip install .

Requirements

Python >= 3.4 and Lua >= 5.2.

Lua and Lua packages must be installed manually (i.e. they are not handled by pip). I suggest to follow the docs of Luarocks (the Lua package manager), to make sure to install matching versions of Lua and Luarocks itself.

Then install my template engine, which I use for code generation:

luarocks install template-text

Sample installation sequence

Using a Python3 virtual environment:

# Virtual environment
mkdir myvenv && python3 -m venv myvenv/
source myvenv/bin/activate
#pip install wheel    # may also be needed to prepare the environment

# The actual program
git clone <this repo> ctgen
cd ctgen/
pip install .   # will also fetch other dependencies

# Lua dependencies
# install Lua and Luarocks ... then
luarocks install template-text

Usage

ctgen <input file>

Refer to the command line help ctgen --help for the options.

See sample/model.motdsl for the input file format (a "MotionsDSL" model).

See sample/config.yaml for the configuration file format. The configuration file is optional. Most of the options can be specified on the command line as well. Command line options override matching entries in the configuration file.

If you install the Lua template engine in a local path, via Luarocks, you need to issue

eval `luarocks path`

before attempting to launch ctgen.

Examples

Use the given sample model and all the defaults:

ctgen sample/model.motdsl

Use the C++ backend shipped with the tool:

ctgen -l cpp_iitrbd sample/model.motdsl

Use the sample configuration file:

ctgen -c sample/config.yaml sample/model.motdsl

Use explicit command line switches to set the language backend, the output folder, and to request the homogeneous coordinates representation only:

ctgen --lang octave --output /tmp/ctgen/octave -xH sample/model.motdsl

Generated code

See the readme file of the chosen backend, in the backends/ folder.

Testing

There are no specific unit tests for ctgen itself.

On the other hand, testing the generated code can essentially be done only by comparison with ground truth numerical data.

To facilitate this task, ctgen can generate numerical datasets with the coefficients of the same matrices it can generate code for (see the command line help). These datasets can then be used by backend-specific testing code, if available.

The C++ and Octave backends shipped with ctgen do provide such testing code, check their readme for further details.

Numerical datasets

ctgen generates one binary dataset per matrix, with a variable number of entries, depending on the command line argument. E.g.:

ctgen --output /tmp/ctgen -s 100 sample/model.motdsl

The format of the dataset is documented in the dataset.py module.

License

Copyright 2020-2022, Marco Frigerio

Distributed under the BSD 3-clause license. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctgen-0.2.0.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ctgen-0.2.0-py3-none-any.whl (43.2 kB view details)

Uploaded Python 3

File details

Details for the file ctgen-0.2.0.tar.gz.

File metadata

  • Download URL: ctgen-0.2.0.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for ctgen-0.2.0.tar.gz
Algorithm Hash digest
SHA256 470cff6bb2bbbecc815092683e607aa53fd5e903c805a0e77732552ddcbb6f6a
MD5 58104198b725e6503d7396c3b66b5938
BLAKE2b-256 2311d70592210a253f5bb17704271dc07e856f916981e303a38088d1005d7957

See more details on using hashes here.

File details

Details for the file ctgen-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ctgen-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 43.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for ctgen-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1bacc6a83aa8fc2ecc03d9a3cf00496cff94c98cb1551f1417a207f07d3cdbb8
MD5 4d06d4bfd82ef79f00ddd51bcbb7526a
BLAKE2b-256 b40b46f492f3608844c3165bd7da4d0b663224d1e38a6c88cff3929184e6e081

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page