From 899b0a61b0be11f2310a36bddca481a93947c31f Mon Sep 17 00:00:00 2001 From: Martin Pecka Date: Thu, 25 Jun 2020 00:00:18 +0200 Subject: [PATCH 1/4] Added const versions of XmlRpcValue converting operators. (#1978) --- .../xmlrpcpp/include/xmlrpcpp/XmlRpcValue.h | 8 ++++++++ utilities/xmlrpcpp/src/XmlRpcValue.cpp | 6 ++++++ utilities/xmlrpcpp/test/TestValues.cpp | 16 ++++++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcValue.h b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcValue.h index 703cceea6e..4aa560849a 100644 --- a/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcValue.h +++ b/utilities/xmlrpcpp/include/xmlrpcpp/XmlRpcValue.h @@ -95,6 +95,13 @@ namespace XmlRpc { operator BinaryData&() { assertTypeOrInvalid(TypeBase64); return *_value.asBinary; } operator struct tm&() { assertTypeOrInvalid(TypeDateTime); return *_value.asTime; } + operator const bool&() const { assertTypeOrInvalid(TypeBoolean); return _value.asBool; } + operator const int&() const { assertTypeOrInvalid(TypeInt); return _value.asInt; } + operator const double&() const { assertTypeOrInvalid(TypeDouble); return _value.asDouble; } + operator const std::string&() const { assertTypeOrInvalid(TypeString); return *_value.asString; } + operator const BinaryData&() const { assertTypeOrInvalid(TypeBase64); return *_value.asBinary; } + operator const struct tm&() const { assertTypeOrInvalid(TypeDateTime); return *_value.asTime; } + XmlRpcValue const& operator[](int i) const { assertArray(i+1); return _value.asArray->at(i); } XmlRpcValue& operator[](int i) { assertArray(i+1); return _value.asArray->at(i); } @@ -147,6 +154,7 @@ namespace XmlRpc { void invalidate(); // Type checking + void assertTypeOrInvalid(Type t) const; void assertTypeOrInvalid(Type t); void assertArray(int size) const; void assertArray(int size); diff --git a/utilities/xmlrpcpp/src/XmlRpcValue.cpp b/utilities/xmlrpcpp/src/XmlRpcValue.cpp index 361a8e8073..1928784311 100644 --- a/utilities/xmlrpcpp/src/XmlRpcValue.cpp +++ b/utilities/xmlrpcpp/src/XmlRpcValue.cpp @@ -70,6 +70,12 @@ namespace XmlRpc { // Type checking + void XmlRpcValue::assertTypeOrInvalid(Type t) const + { + if (_type != t) + throw XmlRpcException("type error"); + } + void XmlRpcValue::assertTypeOrInvalid(Type t) { if (_type == TypeInvalid) diff --git a/utilities/xmlrpcpp/test/TestValues.cpp b/utilities/xmlrpcpp/test/TestValues.cpp index 842e78e9fe..60dae29a5e 100644 --- a/utilities/xmlrpcpp/test/TestValues.cpp +++ b/utilities/xmlrpcpp/test/TestValues.cpp @@ -49,7 +49,7 @@ TEST(XmlRpc, Bool) { } TEST(XmlRpc, testBoolean) { - XmlRpcValue booleanFalse(false); + const XmlRpcValue booleanFalse(false); XmlRpcValue booleanTrue(true); int offset = 0; XmlRpcValue booleanFalseXml("0", &offset); @@ -75,7 +75,7 @@ TEST(XmlRpc, testBoolean) { // Int TEST(XmlRpc, testInt) { - XmlRpcValue int0(0); + const XmlRpcValue int0(0); ASSERT_EQ(XmlRpcValue::TypeInt, int0.getType()); XmlRpcValue int1(1); @@ -110,7 +110,7 @@ TEST(XmlRpc, testInt) { TEST(XmlRpc, testDouble) { // Double - XmlRpcValue d(43.7); + const XmlRpcValue d(43.7); ASSERT_EQ(XmlRpcValue::TypeDouble, d.getType()); EXPECT_EQ("43.700000000000003", d.toXml()); EXPECT_DOUBLE_EQ(43.7, double(d)); @@ -130,7 +130,7 @@ TEST(XmlRpc, testDouble) { TEST(XmlRpc, testString) { // String - XmlRpcValue s("Now is the time <&"); + const XmlRpcValue s("Now is the time <&"); ASSERT_EQ(XmlRpcValue::TypeString, s.getType()); EXPECT_EQ(18, s.size()); EXPECT_EQ("Now is the time <&", s.toXml()); @@ -178,7 +178,7 @@ TEST(XmlRpc, testDateTime) { // DateTime int offset = 0; // Construct from XML - XmlRpcValue dateTime( + const XmlRpcValue dateTime( "19040503T03:12:35", &offset); ASSERT_EQ(XmlRpcValue::TypeDateTime, dateTime.getType()); @@ -286,7 +286,7 @@ TEST(XmlRpc, testArray) { EXPECT_EQ(a, aXml); // Array copy works - XmlRpcValue copy(a); + const XmlRpcValue copy(a); ASSERT_EQ(a.getType(), copy.getType()); ASSERT_EQ(a.size(), copy.size()); for (int i = 0; i < 3; i++) { @@ -345,7 +345,7 @@ TEST(XmlRpc, testStruct) { ""; int offset = 0; - XmlRpcValue structXml(csStructXml, &offset); + const XmlRpcValue structXml(csStructXml, &offset); EXPECT_EQ(struct1, structXml); for (XmlRpcValue::iterator itr = struct1.begin(); itr != struct1.end(); @@ -399,7 +399,7 @@ TEST(XmlRpc, testStruct) { TEST(XmlRpc, base64) { char data[] = {1, 2}; - XmlRpcValue bin(data, 2); + const XmlRpcValue bin(data, 2); EXPECT_EQ(XmlRpcValue::TypeBase64, bin.getType()); EXPECT_EQ(2, bin.size()); From eed549af698b8a0ad769ff32e7adceb69c472172 Mon Sep 17 00:00:00 2001 From: Enrique Fernandez Perdomo Date: Tue, 21 Jul 2020 00:35:13 +0200 Subject: [PATCH 2/4] Add latch param to throttle (#1944) This allows to force the advertised throttled publisher to be latched or not, instead of using the same latching property value as the input topic. It defaults to the previous behaviour, i.e. it uses the same latching property value as the input topic. --- tools/topic_tools/src/throttle.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/tools/topic_tools/src/throttle.cpp b/tools/topic_tools/src/throttle.cpp index be3c445b7a..f605e16d01 100644 --- a/tools/topic_tools/src/throttle.cpp +++ b/tools/topic_tools/src/throttle.cpp @@ -57,6 +57,8 @@ bool g_use_messages; ros::Time g_last_time; bool g_use_wallclock; bool g_lazy; +bool g_force_latch = false; +bool g_force_latch_value = true; ros::TransportHints g_th; class Sent @@ -87,6 +89,21 @@ void conn_cb(const ros::SingleSubscriberPublisher&) } } +bool is_latching(const boost::shared_ptr& connection_header) +{ + if (connection_header) + { + ros::M_string::const_iterator it = connection_header->find("latching"); + if ((it != connection_header->end()) && (it->second == "1")) + { + ROS_DEBUG("input topic is latched; latching output topic to match"); + return true; + } + } + + return false; +} + void in_cb(const ros::MessageEvent& msg_event) { boost::shared_ptr const &msg = msg_event.getConstMessage(); @@ -94,17 +111,7 @@ void in_cb(const ros::MessageEvent& msg_event) if (!g_advertised) { - // If the input topic is latched, make the output topic latched - bool latch = false; - if (connection_header) - { - ros::M_string::const_iterator it = connection_header->find("latching"); - if((it != connection_header->end()) && (it->second == "1")) - { - ROS_DEBUG("input topic is latched; latching output topic to match"); - latch = true; - } - } + const bool latch = g_force_latch ? g_force_latch_value : is_latching(connection_header); g_pub = msg->advertise(*g_node, g_output_topic, 10, latch, conn_cb); g_advertised = true; printf("advertised as %s\n", g_output_topic.c_str()); @@ -192,6 +199,7 @@ int main(int argc, char **argv) pnh.getParam("wall_clock", g_use_wallclock); pnh.getParam("unreliable", unreliable); pnh.getParam("lazy", g_lazy); + g_force_latch = pnh.getParam("force_latch", g_force_latch_value); if (unreliable) g_th.unreliable().reliable(); // Prefers unreliable, but will accept reliable. From 8806bc479f86f68863f66bbc59a3c92bd1d9473a Mon Sep 17 00:00:00 2001 From: Carl Saldanha Date: Thu, 23 Jul 2020 11:06:52 -0700 Subject: [PATCH 3/4] Add which node has been registered with the same name (#1992) * Add which node has been registered with the same name Was looking through logs of several nodes that had been launched at the same time and it was getting hard to tell which node was being duplicated. This would allow you do to see the name of the node that caused the issue * switch to shutdown_node_task --- tools/rosmaster/src/rosmaster/registrations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/rosmaster/src/rosmaster/registrations.py b/tools/rosmaster/src/rosmaster/registrations.py index 6cbfddf2a7..f7e8d124d3 100644 --- a/tools/rosmaster/src/rosmaster/registrations.py +++ b/tools/rosmaster/src/rosmaster/registrations.py @@ -125,7 +125,7 @@ def shutdown_node_task(api, caller_id, reason): @type reason: str """ try: - xmlrpcapi(api).shutdown('/master', reason) + xmlrpcapi(api).shutdown('/master', "[{}] Reason: {}".format(caller_id, reason)) except: pass #expected in many common cases remove_server_proxy(api) From 6a23fd719ee13a1d8f03273bc6ac576be39c652d Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Thu, 23 Jul 2020 15:37:55 -0700 Subject: [PATCH 4/4] remove not existing NodeProxy from rospy __all__ (#2007) --- clients/rospy/src/rospy/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/clients/rospy/src/rospy/__init__.py b/clients/rospy/src/rospy/__init__.py index 1c4a5693a9..6d9ebc8311 100644 --- a/clients/rospy/src/rospy/__init__.py +++ b/clients/rospy/src/rospy/__init__.py @@ -113,7 +113,6 @@ 'logerr_once', 'logfatal_once', 'parse_rosrpc_uri', 'MasterProxy', - 'NodeProxy', 'ROSException', 'ROSSerializationException', 'ROSInitException',