Skip to content

Latest commit

 

History

History
76 lines (52 loc) · 2.46 KB

CONTRIBUTING.md

File metadata and controls

76 lines (52 loc) · 2.46 KB

Contributing

  1. Fork the repo.
  2. Clone the repo into your workspace:
git clone https://github.com/mavlink/mavros.git
  1. Create a remote connection to your repo:
git remote add origin [email protected]:<YourGitUser>/mavros.git
  1. Create a feature/dev branch:
git checkout -b <feature_branch>
  1. Make your changes.
  2. Commit the changes. The -a option automatically adds and removes files for you.
git commit -a -m "<message>"
  1. Check your code style:
uncrustify -c ${ROS_WORKSPACE}/src/mavros/mavros/tools/uncrustify-cpp.cfg --replace --no-backup <path/to/file.ext>
  1. Fix small code style errors and typos.
  2. Commit with a description like "uncrustify" or "code style fix". Please avoid changes in program logic (separate commits are better than a mix of style and bug fixes).
  3. Run tests:
  • with catkin_make, issue catkin_make tests and then catkin_make run_tests;
  • with catkin tools, issue catkin run_tests;
  1. If everything goes as planned, push the changes and issue a pull request.
git push -u origin <feature_branch>

cog.py generators

In many places we need to copy some data from MAVLink, and in many places we have regular patterns of code (e.g. copied message fields). To avoid manual copy-paste work (and errors!) we use the the cog.py code generator/preprocessor.

Cog generates C++ code from code blocks written in Python that you add into your C++ code file as specially formatted comments. Since you are now using Python, you can import and make use of the pymavlink module, which already comes with MAVlink message definitions that you can reuse. An example you may look at is the utils::to_string() implementation for some enums in lib/enum_to_string.cpp.

Install cog and pymavlink:

pip install --user cogapp pymavlink

Add your generator code to your file as comments enclosed in the [[[cog:]]] and [[[end]]] tags. Then invoke cog so that it updates your file:

cog.py -cr your_file.h/cpp

In addition, this script will re-generate all files with cog code:

./mavros/tools/cogall.sh