-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Imported upstream version '2.5.0' of 'upstream'
- Loading branch information
Showing
265 changed files
with
36,688 additions
and
26,195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[*.{cpp,hpp}] | ||
indent_style = space | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,76 @@ | ||
Contributing | ||
============ | ||
|
||
|
||
1. Fork the repo: | ||
![fork](http://s24.postimg.org/pfvt9sdv9/Fork_mavros.png) | ||
2. Clone the repo (`git clone https://github.com/mavlink/mavros.git`); | ||
3. Create a remote connection to your repo (`git remote add <remote_repo> [email protected]:<YourGitUser>/mavros.git`); | ||
4. Create a feature/dev branch (`git checkout -b <feature_branch>`); | ||
5. Add the changes; | ||
6. Apply the changes by committing (`git commit -m "<message>"` or `git commit -a` and then write message; if adding new files: `git add <path/to/file.ext>`); | ||
7. Check code style `uncrustify -c ${ROS_WORKSPACE}/src/mavros/mavros/tools/uncrustify-cpp.cfg --replace --no-backup <path/to/file.ext>`; | ||
8. Fix small code style errors and typos; | ||
9. Commit with description like "uncrustify" or "code style fix". Please avoid changes in program logic (separate commit are better than mix of style and bug fix); | ||
# Contributing | ||
|
||
1. Fork the repo. [<img src="https://upload.wikimedia.org/wikipedia/commons/3/38/GitHub_Fork_Button.png" height="30"/>](https://github.com/mavlink/mavros/fork) | ||
2. Clone the repo into your workspace: | ||
|
||
```bash | ||
git clone https://github.com/mavlink/mavros.git | ||
``` | ||
|
||
3. Create a remote connection to your repo: | ||
|
||
```bash | ||
git remote add origin [email protected]:<YourGitUser>/mavros.git | ||
``` | ||
|
||
4. Create a feature/dev branch: | ||
|
||
```bash | ||
git checkout -b <feature_branch> | ||
``` | ||
|
||
5. Make your changes. | ||
6. Commit the changes. The `-a` option automatically adds and removes files for you. | ||
|
||
```bash | ||
git commit -a -m "<message>" | ||
``` | ||
|
||
7. Check your code style: | ||
|
||
```bash | ||
uncrustify -c ${ROS_WORKSPACE}/src/mavros/mavros/tools/uncrustify-cpp.cfg --replace --no-backup <path/to/file.ext> | ||
``` | ||
|
||
8. Fix small code style errors and typos. | ||
9. 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). | ||
10. Run tests: | ||
- with `catkin_make`, issue `catkin_make tests` and then `catkin_make run_tests`; | ||
- with `catkin tools`, issue `catkin run_tests`; | ||
11. If everything goes as planned, push the changes (`git push -u <remote_repo> <feature_branch>`) and issue a pull request. | ||
|
||
- with `catkin_make`, issue `catkin_make tests` and then `catkin_make run_tests`; | ||
- with `catkin tools`, issue `catkin run_tests`; | ||
|
||
11. If everything goes as planned, push the changes and issue a pull request. | ||
|
||
cog.py generators | ||
----------------- | ||
```bash | ||
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. copy message fields). | ||
To avoid manual copy-paste work (and errors!) we use [cog.py][cog] generator/preprocessor. | ||
Generator program written in comment blocks on Python (that allow import pymavlink), output will be inserted between markers. | ||
As an example you may look at `utils::to_string()` implementation for some enums: [lib/enum_to_string.cpp][ets]. | ||
## cog.py generators | ||
|
||
To install it : | ||
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][cog] code generator/preprocessor. | ||
|
||
pip install --user cogapp pymavlink | ||
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][pml] 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][ets]. | ||
Then fill the behaviour you when between the `[[[cog:]]]` `[[[end]]]` balise | ||
and invoke cog like this: | ||
Install cog and pymavlink: | ||
cog.py -cr your_file.h/cpp | ||
```bash | ||
pip install --user cogapp pymavlink | ||
``` | ||
Your file will be updated by cog. | ||
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: | ||
./mavros/tools/cogall.sh | ||
```bash | ||
cog.py -cr your_file.h/cpp | ||
``` | ||
This script will regenerate all files with generators. | ||
In addition, this script will re-generate all files with cog code: | ||
```bash | ||
./mavros/tools/cogall.sh | ||
``` | ||
[cog]: https://nedbatchelder.com/code/cog/ | ||
[ets]: https://github.com/mavlink/mavros/blob/master/mavros/src/lib/enum_to_string.cpp | ||
[pml]: https://mavlink.io/en/mavgen_python/ |
Oops, something went wrong.