Skip to content

Commit

Permalink
reinstate getparam for a single crazyflie
Browse files Browse the repository at this point in the history
  • Loading branch information
knmcguire committed May 7, 2024
1 parent 6a3bb4b commit f446b6e
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions crazyflie_py/crazyflie_py/crazyflie.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ def __init__(self, node, cfname, paramTypeDict):
self.status = {}

# Query some settings
getParamsService = node.create_client(GetParameters, '/crazyflie_server/get_parameters')
getParamsService.wait_for_service()
self.getParamsService = node.create_client(GetParameters, '/crazyflie_server/get_parameters')
self.getParamsService.wait_for_service()
req = GetParameters.Request()
req.names = ['robots.{}.initial_position'.format(cfname), 'robots.{}.uri'.format(cfname)]
future = getParamsService.call_async(req)
future = self.getParamsService.call_async(req)
while rclpy.ok():
rclpy.spin_once(node)
if future.done():
Expand Down Expand Up @@ -484,26 +484,38 @@ def notifySetpointsStop(self, remainValidMillisecs=100, groupMask=0):
# '/world', '/cf' + str(self.id), rospy.Time(0))
# return np.array(position)

# def getParam(self, name):
# """Returns the current value of the onboard named parameter.
def getParam(self, name):
"""Returns the current value of the onboard named parameter.
# Parameters are named values of various primitive C types that control
# the firmware's behavior. For more information, see
# https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/userguides/logparam/.
Parameters are named values of various primitive C types that control
the firmware's behavior. For more information, see
https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/userguides/logparam/.
# Parameters are read at system startup over the radio and cached.
# The ROS launch file can also be used to set parameter values at startup.
# Subsequent calls to :meth:`setParam()` will update the cached value.
# However, if the parameter changes for any other reason, the cached value
# might become stale. This situation is not common.
Parameters are read at system startup over the radio and cached.
The ROS launch file can also be used to set parameter values at startup.
Subsequent calls to :meth:`setParam()` will update the cached value.
However, if the parameter changes for any other reason, the cached value
might become stale. This situation is not common.
# Args:
# name (str): The parameter's name.
Args:
name (str): The parameter's name.
Returns:
value (Any): The parameter's value.
"""

param_name = self.prefix[1:] + '.params.' + name
req = GetParameters.Request()
req.names = [param_name]
future = self.getParamsService.call_async(req)
rclpy.spin_until_future_complete(self.node, future)
param_type = self.paramTypeDict[name]
if param_type == ParameterType.PARAMETER_INTEGER:
param_value = future.result().values[0].integer_value
elif param_type == ParameterType.PARAMETER_DOUBLE:
param_value = future.result().values[0].double_value
return param_value

# Returns:
# value (Any): The parameter's value.
# """
# return rospy.get_param(self.prefix + '/' + name)

def setParam(self, name, value):
"""
Expand Down

0 comments on commit f446b6e

Please sign in to comment.