git clone https://github.com/mavlink/mavros.git
- Create a remote connection to your repo:
git remote add origin git@github.com:<YourGitUser>/mavros.git
- Create a feature/dev branch:
git checkout -b <feature_branch>
- Make your changes.
- Commit the changes. The
-a
option automatically adds and removes files for you.
git commit -a -m "<message>"
- Check your code style:
uncrustify -c ${ROS_WORKSPACE}/src/mavros/mavros/tools/uncrustify-cpp.cfg --replace --no-backup <path/to/file.ext>
- Fix small code style errors and typos.
- 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).
- Run tests:
- with
catkin_make
, issuecatkin_make tests
and thencatkin_make run_tests
; - with
catkin tools
, issuecatkin run_tests
;
- If everything goes as planned, push the changes and issue a pull request.
git push -u origin <feature_branch>
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