mavlink / mavros

MAVLink to ROS gateway with proxy for Ground Control Station
Other
879 stars 990 forks source link

[ROS2][Question] Which service to use to set params from C++ code #1737

Closed Vicidel closed 2 years ago

Vicidel commented 2 years ago

Issue details

Hello all

I need to set parameters using MAVROS2. I see that there are two services:

In the param plugin there is a line here saying that the service set_parameters is not exposed to user code. And in the mavros_msgs definition of ParamSetV2 there is a note that it's only if the ROS2 param API is not sufficient here.

From my interpretation I should not use any of those two. Which of these two should I believe?

MAVROS version and platform

Mavros: 2.1.1 ROS: ROS2 Galactic Ubuntu: 20.04

Autopilot type and version

[ ] ArduPilot [x] PX4

vooon commented 2 years ago

You should use standard parameter interface. ~/set have quite specific use cases: to bypass parameter exclude check (bu name) or to send unknown (yet) parameter.

Vicidel commented 2 years ago

Okay that makes sense, thanks for the quick answer!

esharet commented 2 years ago

You should use standard parameter interface. ~/set have quite specific use cases: to bypass parameter exclude check (bu name) or to send unknown (yet) parameter.

Can you please explain? I'm interested in setting and getting parameters from pixhawk. The service /mavros/param/set work fine for setting, is it the right way? and how can I get a specific parameter? Thanks

vooon commented 2 years ago

ROS2 has standard interface to parameters. Use them. https://github.com/mavlink/mavros/blob/686bd833e7d6ea5542977178872762dfbec5ed89/mavros/src/plugins/param.cpp#L43-L55