New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add page for PX4 ROS library #2740
Conversation
bcddb40
to
4a5c797
Compare
@bkueng Housekeeping
|
Top level comments on this feature.
I'll add some other comments/suggestions in line. |
en/ros2/px4_sdk.md
Outdated
@@ -0,0 +1,336 @@ | |||
# PX4 SDK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name :-(
en/ros2/px4_sdk.md
Outdated
|
||
#### Mode | ||
|
||
- A mode is a component that can send setpoints to the vehicle, which control its motion (such as velocity or direct actuator commands). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to list the setpoints somewhere below and link to them.
en/ros2/px4_sdk.md
Outdated
## Mode Tutorial | ||
|
||
This section steps through an example for a custom mode class. | ||
For a complete application, check out the [examples in the repository](https://github.com/PX4/px4_sdk/tree/main/examples/cpp). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth providing "such as" links https://github.com/PX4/px4_sdk/blob/main/examples/cpp/modes/rtl_replacement/include/mode.hpp
en/ros2/px4_sdk.md
Outdated
To ensure compatibility, use the latest _main_ branches for PX4, _px4_msgs_ and the SDK. | ||
See also [here](https://github.com/PX4/px4_sdk#compatibility-with-px4). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me uncomfortable - it basically says we ensure compatibility of the SDK by forcing you to use an unstable version of PX4. The linked doc is better in that it says we might change this in future. We should come up with a plan now and let people know.
The linked doc mentions this, which should also appear in this doc (I haven't checked) but it is cool:
The SDK checks for message compatibility on startup when registering a mode. ALL_PX4_SDK_MESSAGES defines the set of checked messages. If you use other messages, you can check them using:
if (!px4_sdk::messageCompatibilityCheck(node, {{"/fmu/in/vehicle_rates_setpoint"}})) {
throw std::runtime_error("Messages incompatible");
}
en/ros2/px4_sdk.md
Outdated
|
||
1. [Configure the output](../payloads/#generic-actuator-control-with-mavlink) | ||
2. Create an instance of [px4_sdk::OffboardActuatorControls](https://github.com/PX4/px4_sdk/blob/main/px4_sdk_cpp/include/px4_sdk/control/offboard_actuators.hpp) in the constructor of your mode | ||
3. Call the `set` method to control the actuator(s). This can be done independently of any active setpoints. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code fragment or link to code showing last two points would be awesome.
}; | ||
``` | ||
|
||
- `[1]`: First we create a class that inherits from `px4_ros2::ModeBase` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we could create a "reference" of the public API - just names and a description for the main classes at the end. Starting from a reference tells you what documentation is available/missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we could use doxygen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to assume you have this on your list :-)
The following sections provide a list of commonly used setpoint types. | ||
You can also add your own type by adding a class that inherits from `px4_ros2::SetpointBase`, sets the configuration flags according to what the setpoint requires, and then publishes any topic containing a setpoint. | ||
|
||
<!-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo
@bkueng I added some comments. I'm not sure how far this has to go before we decide it is "right". Some things I'd like considered before we merge:
You might not want to do any of this right now. That's OK if you think this is useful as is and have a cunning plan going forward? |
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
Will do.
Yes later. It's not up yet and I wanted to add the link to the docs to the video first.
Yes agnostic, but we'll have to see how much we can abstract a mode to be generic. I don't think they will be completely generic.
Cunning certainly goes too far, but yes, there's a lot of things to be done. |
- [Experimental] [PX4 ROS 2 Interface Library](../ros2/px4_ros2_interface_lib.md): A new C++ library that simplifies controlling PX4 from ROS 2. | ||
Supports adding flight modes in ROS 2 that are peers of the PX4 modes running on the flight controller. | ||
Added to PX4 in [PX4-Autopilot#20707](https://github.com/PX4/PX4-Autopilot/pull/20707) (initial support). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI the important thing here is to set expectation. So I have put a prefix experimental and added a link to the initial PR.
As you enhance this you can add new PR links.
If you consider significant parts of this stable, we can remove "Experimental".
en/ros2/px4_ros2_interface_lib.md
Outdated
:::warning Experimental | ||
At time of writing parts of the PX4 ROS 2 Interface Library is experimental, and hence subject to change: | ||
|
||
- The architecture and core interfaces for defining modes in ROS 2 modes are largely stable. | ||
The library offers significant benefits over using offboard mode in its current state. | ||
- Only a few setpoint types have settled (the others are still under development). | ||
You may need to use internal PX4 topics which may not remain backwards-compatible over time. | ||
- The API is not fully documented. | ||
- Testing in CI is still limited. | ||
|
||
::: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI I added section "Experimental" up the top. What I'm trying to do here is explain that the mode stuff works now and already gives you a benefit over using offboard mode, but that many of the abstractions we provide for working with ROS 2 do not exist yet. So you can use it but likely things will change.
I've done it in bullets so you can extend easily if you want. I'm open to any text which sets the level of expectation appropriately (i.e. this is "for discussion").
Telemetry topics include: | ||
|
||
- [OdometryGlobalPosition](https://github.com/Auterion/px4-ros2-interface-lib/blob/main/px4_ros2_cpp/include/px4_ros2/odometry/global_position.hpp): Global position | ||
- [OdometryLocalPosition](https://github.com/Auterion/px4-ros2-interface-lib/blob/main/px4_ros2_cpp/include/px4_ros2/odometry/local_position.hpp): Local position, velocity and acceleration. | ||
|
||
:::note | ||
These topics provide a wrapper around the internal PX4 topics, allowing the library to maintain compatibility if the internal topics change. | ||
Check [px4_ros2/odometry](https://github.com/Auterion/px4-ros2-interface-lib/tree/main/px4_ros2_cpp/include/px4_ros2/odometry) for new topics, and of course you can use any ROS 2 topic published from PX4. | ||
::: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs checking. I wanted to add a little information on what we support now at this level, and a reason why we bother.
@bkueng I've addressed most of my own concerns with this - setting expectation - by adding an experimental header. Can you please check that is OK. Perhaps there is a better way of explaining the state of the SDK. The only one thing missing that I think might block people from using this is this question on the mode executor: https://github.com/PX4/PX4-user_guide/pull/2740/files#r1402837201 I'll merge tomorrow if you think this is reasonable. |
en/ros2/px4_ros2_interface_lib.md
Outdated
- Only a few setpoint types have settled (the others are still under development). | ||
You may need to use internal PX4 topics which may not remain backwards-compatible over time. | ||
- The API is not fully documented. | ||
- Testing in CI is still limited. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ok, but just fyi most of the things that are there are tested. Mostly the setpoint types (with their expected behavior) that are not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then let's say that :-)
Thanks Hamish. Looks good to me. |
TODO: Error duplicate reference to print |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK @bkueng made a few minor changes to address your responses to my feedback. I'm going to merge. I wish we could do a lot more, but good to get this out there and visible.
Documentation for PX4/PX4-Autopilot#20707.
Some bits are still missing & it needs integration with the other pages.
@hamishwillee if you want you can already take a first pass. @tstastny will go through the steps to see if anything is missing.