From e1f8cc0c56dd1a9543e96f48e0de8960877296ff Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Mon, 25 Aug 2014 11:57:15 -0700 Subject: [PATCH] add message with constant values for all primitive types --- simple_msgs/CMakeLists.txt | 1 + simple_msgs/msg/AllPrimitiveConstants.msg | 14 ++++++++++++++ simple_msgs/msg/AllStaticArrayTypes.msg | 8 ++++---- simple_msgs/msg/String.msg | 3 ++- userland/src/publisher.cpp | 3 ++- 5 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 simple_msgs/msg/AllPrimitiveConstants.msg diff --git a/simple_msgs/CMakeLists.txt b/simple_msgs/CMakeLists.txt index ca0c5297..330e5dd2 100644 --- a/simple_msgs/CMakeLists.txt +++ b/simple_msgs/CMakeLists.txt @@ -9,6 +9,7 @@ find_package(rosidl_default_generators REQUIRED) rosidl_generate_interfaces(${PROJECT_NAME} "msg/AllDynamicArrayTypes.msg" + "msg/AllPrimitiveConstants.msg" "msg/AllPrimitiveTypes.msg" "msg/AllStaticArrayTypes.msg" "msg/Int32.msg" diff --git a/simple_msgs/msg/AllPrimitiveConstants.msg b/simple_msgs/msg/AllPrimitiveConstants.msg new file mode 100644 index 00000000..cbc7e240 --- /dev/null +++ b/simple_msgs/msg/AllPrimitiveConstants.msg @@ -0,0 +1,14 @@ +bool MY_BOOL=1 +byte MY_BYTE=42 +char MY_CHAR=43 +float32 MY_FLOAT32=3.14 +float64 MY_FLOAT64=3.1415 +int8 MY_INT8=-128 +uint8 MY_UINT8=255 +int16 MY_INT16=-32768 +uint16 MY_UINT16=65535 +int32 MY_INT32=5 +uint32 MY_UINT32=6 +int64 MY_INT64=7 +uint64 MY_UINT64=8 +string MY_STRING=' f o o ' diff --git a/simple_msgs/msg/AllStaticArrayTypes.msg b/simple_msgs/msg/AllStaticArrayTypes.msg index e1f895df..ac9c4b14 100644 --- a/simple_msgs/msg/AllStaticArrayTypes.msg +++ b/simple_msgs/msg/AllStaticArrayTypes.msg @@ -1,7 +1,7 @@ -bool[6] my_bool -byte[6] my_byte +bool[6] my_bool [0,1,0,1,0,1] +byte[6] my_byte [ 1 , 0 , 1 , 0 , 1 ,0] char[6] my_char -float32[6] my_float32 +float32[6] my_float32 [1.2,3.4,5.6,7.8,9.0,0.1] float64[6] my_float64 int8[6] my_int8 uint8[6] my_uint8 @@ -11,4 +11,4 @@ int32[6] my_int32 uint32[6] my_uint32 int64[6] my_int64 uint64[6] my_uint64 -string[6] my_string +string<=2[6] my_string diff --git a/simple_msgs/msg/String.msg b/simple_msgs/msg/String.msg index ae721739..f673862b 100644 --- a/simple_msgs/msg/String.msg +++ b/simple_msgs/msg/String.msg @@ -1 +1,2 @@ -string data +string<=1000 data +string<=1000 data2 diff --git a/userland/src/publisher.cpp b/userland/src/publisher.cpp index ba2f5ddc..037d610f 100644 --- a/userland/src/publisher.cpp +++ b/userland/src/publisher.cpp @@ -35,7 +35,7 @@ int publish(rclcpp::Node* node, void (*set_data_func)(T&, uint32_t)) std::cout << "published ros msg #" << i << std::endl; // } ++i; - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } auto end = std::chrono::steady_clock::now(); @@ -134,6 +134,7 @@ void set_nested(simple_msgs::Nested& ros_msg, uint32_t i) void set_string(simple_msgs::String& ros_msg, uint32_t i) { + i = pow(2, i) - 1; ros_msg.data = ""; for (uint64_t j = i; j < 2 * i; ++j) { ros_msg.data += std::to_string(j % 10);