From efcae4510c5cd9cba5f90b54336d600bda508300 Mon Sep 17 00:00:00 2001 From: Bastien Scher Date: Mon, 29 Jan 2018 16:30:13 +0100 Subject: [PATCH] Add support for boolean parameters --- rosserial_client/src/ros_lib/ros/node_handle.h | 18 ++++++++++++++++++ .../src/rosserial_python/SerialClient.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/rosserial_client/src/ros_lib/ros/node_handle.h b/rosserial_client/src/ros_lib/ros/node_handle.h index 1db13bce4..8fa27b19b 100644 --- a/rosserial_client/src/ros_lib/ros/node_handle.h +++ b/rosserial_client/src/ros_lib/ros/node_handle.h @@ -661,6 +661,24 @@ class NodeHandle_ : public NodeHandleBase_ } return false; } + bool getParam(const char* name, bool* param, int length = 1, int timeout = 1000) + { + if (requestParam(name, timeout)) + { + if (length == req_param_resp.ints_length) + { + //copy it over + for (int i = 0; i < length; i++) + param[i] = req_param_resp.ints[i]; + return true; + } + else + { + logwarn("Failed to get param: length mismatch"); + } + } + return false; + } }; } diff --git a/rosserial_python/src/rosserial_python/SerialClient.py b/rosserial_python/src/rosserial_python/SerialClient.py index aa98cd188..858745cbf 100644 --- a/rosserial_python/src/rosserial_python/SerialClient.py +++ b/rosserial_python/src/rosserial_python/SerialClient.py @@ -670,7 +670,7 @@ def handleParameterRequest(self, data): if t!= type(p): rospy.logerr('All Paramers in the list %s must be of the same type'%req.name) return - if (t == int): + if (t == int or t == bool): resp.ints= param if (t == float): resp.floats=param