Hello there,

Moveit Version: Noetic

I have created a Python client service node to call the service server node in c++ for setting motion planner parameters online for Robotic manipulator by passing the custom arguments via the following method mentioned in this issue:

gramaziokohler/roslibpy#26

At: gramaziokohler/roslibpy#26 (comment)

But, I'm getting errors, here is the client side code:

`#!/usr/bin/env python3 import sys import rospy import genpy #import roslibpy import struct import moveit_msgs.msg #import codecs

from moveit_msgs.srv import SetPlannerParams

def setparams_client(**kwargs): rospy.init_node("set_planner_params_client_node") rospy.loginfo("set_planner_params_client_node created") rospy.wait_for_service("set_planner_params") rate = rospy.Rate(1) while not rospy.is_shutdown(): try: request = rospy.ServiceProxy("set_planner_params", SetPlannerParams) request(**kwargs) rate.sleep() except rospy.ServiceException as e: print("Service call failed: %s"%e)

if name == "main": setparams_client(params = {'max_nearest_neighbors': '15', 'type': 'geometric::PRM'}, planner_config ="PRM", group ="arm", replace = 1)

` Here is the structure of empty parameters included in the service type:

`$ rossrv show moveit_msgs/SetPlannerParams string pipeline_id string planner_config string group moveit_msgs/PlannerParams params string[] keys string[] values string[] descriptions bool replace

` Here are the parameters with default values

$ rosservice call /get_planner_params "pipeline_id: '' planner_config: 'PRM' group: 'arm'" params: keys: - max_nearest_neighbors - type values: - '10' - geometric::PRM descriptions: []

When I tried to run the code, I got these errors:

`$ rosrun seyed_ga_tunning_270922 set_planner_params_seyed_hafiz.py [INFO] [1665065193.916210, 0.000000]: set_planner_params_client_node created Traceback (most recent call last): File "/opt/ros/noetic/lib/python3/dist-packages/moveit_msgs/srv/_SetPlannerParams.py", line 109, in serialize length = len(self.params.keys) TypeError: object of type 'builtin_function_or_method' has no len()

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/vaghefi/catkin_ws/src/seyed_ga_tunning_270922/scripts/set_planner_params_seyed_hafiz.py", line 27, in setparams_client(params = {'max_nearest_neighbors': '15', 'type': 'geometric::PRM'}, planner_config ="PRM", group ="arm", replace = 1) File "/home/vaghefi/catkin_ws/src/seyed_ga_tunning_270922/scripts/set_planner_params_seyed_hafiz.py", line 21, in setparams_client request(**kwargs) File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_service.py", line 442, in call return self.call(*args, **kwds) File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_service.py", line 520, in call transport.send_message(request, self.seq) File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_base.py", line 679, in send_message serialize_message(self.write_buff, seq, msg) File "/opt/ros/noetic/lib/python3/dist-packages/rospy/msg.py", line 152, in serialize_message msg.serialize(b) File "/opt/ros/noetic/lib/python3/dist-packages/moveit_msgs/srv/_SetPlannerParams.py", line 136, in serialize except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self))))) File "/opt/ros/noetic/lib/python3/dist-packages/genpy/message.py", line 393, in _check_types check_type(n, t, getattr(self, n)) File "/opt/ros/noetic/lib/python3/dist-packages/genpy/message.py", line 326, in check_type raise SerializationError('field %s must be of type [%s]' % (field_name, field_type)) genpy.message.SerializationError: field params must be of type [moveit_msgs/PlannerParams] `

Please advise, how can I pass the custom parameters?

Thanks

More Seyed Abdollah Vaghefi's questions See All
Similar questions and discussions