Skip to content
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

AP_DDS: Parameters service #28298

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

PQuill33
Copy link

@PQuill33 PQuill33 commented Oct 3, 2024

ISSUE

#28292

Changes

-Add set parameters service call to AP_DDS library

  • service is /ap/set_parameters
  • Add get parameters service call to AP_DDS library
  • service is /ap/get_parameters

Test

Using ros2 CLI, launch ardupilot sitl

ros2 launch ardupilot_sitl sitl_dds_udp.launch.py transport:=udp4 synthetic_clock:=True wipe:=False model:=quad speedup:=1 slave:=0 instance:=0 defaults:=$(ros2 pkg prefix ardupilot_sitl)/share/ardupilot_sitl/config/default_params/copter.parm,$(ros2 pkg prefix ardupilot_sitl)/share/ardupilot_sitl/config/default_params/dds_udp.parm sim_address:=127.0.0.1 master:=tcp:127.0.0.1:5760 sitl:=127.0.0.1:5501
  • Check that parameter service is up
ros2 service list

Expected output
service_list

  • Service call to set parameter
ros2 service call /ap/set_parameters rcl_interfaces/srv/SetParameters "{parameters: [{name: LOIT_SPEED, value: {type: 2, integer_value: 1250}}]}"

Expected output
mavproxy window:
param_success

service call window:
single_param_success

  • Service call to get parameter
ros2 service call /ap/get_parameters rcl_interfaces/srv/GetParameters "{names: ['LOIT_SPEED']}"

Expected output
mavproxy window:
get_param_success

service call window:
get_param_response

@Ryanf55 Ryanf55 self-requested a review October 7, 2024 22:18
@Ryanf55 Ryanf55 added the ROS label Oct 7, 2024
@PQuill33 PQuill33 marked this pull request as ready for review October 10, 2024 16:00
@tizianofiorenzani
Copy link
Contributor

tizianofiorenzani commented Oct 11, 2024

I have tested with the Plane SITL, trying to ask for a wrong parameter. I mispelled AIRSPEED_CRUISE, which should be 22.0, and I expected to get some error. The only thing that tells me the response is wrong is the type = 0.

ros2 service call /ap/get_parameters rcl_interfaces/srv/GetParameters "names: [AIRSPEED_CRUIS2E]"
waiting for service to become available...
requester: making request: rcl_interfaces.srv.GetParameters_Request(names=['AIRSPEED_CRUIS2E'])

response:
rcl_interfaces.srv.GetParameters_Response(values=[rcl_interfaces.msg.ParameterValue(type=0, bool_value=True, integer_value=19513347822207839, double_value=22.0, string_value='', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[])])

Instead, if you ask for the correct parameter I have:

ros2 service call /ap/get_parameters rcl_interfaces/srv/GetParameters "names: [AIRSPEED_CRUISE]"
waiting for service to become available...
requester: making request: rcl_interfaces.srv.GetParameters_Request(names=['AIRSPEED_CRUISE'])

response:
rcl_interfaces.srv.GetParameters_Response(values=[rcl_interfaces.msg.ParameterValue(type=3, bool_value=True, integer_value=19513347822207839, double_value=24.0, string_value='', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[])])

Overall seems correct. I have tried to set and get multiple parameters, changed the airspeed in flight, made sure it was effective.

@PQuill33
Copy link
Author

I have tested with the Plane SITL, trying to ask for a wrong parameter. I mispelled AIRSPEED_CRUISE, which should be 22.0, and I expected to get some error. The only thing that tells me the response is wrong is the type = 0.

ros2 service call /ap/get_parameters rcl_interfaces/srv/GetParameters "names: [AIRSPEED_CRUIS2E]"
waiting for service to become available...
requester: making request: rcl_interfaces.srv.GetParameters_Request(names=['AIRSPEED_CRUIS2E'])

response:
rcl_interfaces.srv.GetParameters_Response(values=[rcl_interfaces.msg.ParameterValue(type=0, bool_value=True, integer_value=19513347822207839, double_value=22.0, string_value='', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[])])

Instead, if you ask for the correct parameter I have:

ros2 service call /ap/get_parameters rcl_interfaces/srv/GetParameters "names: [AIRSPEED_CRUISE]"
waiting for service to become available...
requester: making request: rcl_interfaces.srv.GetParameters_Request(names=['AIRSPEED_CRUISE'])

response:
rcl_interfaces.srv.GetParameters_Response(values=[rcl_interfaces.msg.ParameterValue(type=3, bool_value=True, integer_value=19513347822207839, double_value=24.0, string_value='', byte_array_value=[], bool_array_value=[], integer_array_value=[], double_array_value=[], string_array_value=[])])

Overall seems correct. I have tried to set and get multiple parameters, changed the airspeed in flight, made sure it was effective.

The error gets reported as a GCS message. It should read AP: DDS: Get Parameters Request : ONE OR MORE PARAM NOT FOUND.

I was thinking of populating the fields in the response message with bogus entries if that sounds like an acceptable error response?

@tizianofiorenzani
Copy link
Contributor

I think it's fair to just use the type field to check whether a parameter is valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants