diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f2afc7a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+log/
+.vscode/
+build/
+install/
\ No newline at end of file
diff --git a/custom_msgs/float_location_msgs/msg/FloatLocation b/custom_msgs/float_location_msgs/msg/FloatLocation
deleted file mode 100644
index 0fb5429..0000000
--- a/custom_msgs/float_location_msgs/msg/FloatLocation
+++ /dev/null
@@ -1,3 +0,0 @@
-float32 x
-float32 y
-float32 z
\ No newline at end of file
diff --git a/custom_msgs/float_location_msgs/CMakeLists.txt b/custom_msgs/geometry_msgs/CMakeLists.txt
similarity index 94%
rename from custom_msgs/float_location_msgs/CMakeLists.txt
rename to custom_msgs/geometry_msgs/CMakeLists.txt
index 40c46f9..351ceb2 100644
--- a/custom_msgs/float_location_msgs/CMakeLists.txt
+++ b/custom_msgs/geometry_msgs/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
-project(float_location_msgs)
+project(geometry_msgs)
# Default to C99
if(NOT CMAKE_C_STANDARD)
@@ -20,7 +20,7 @@ find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
- "msg/FloatLocation.msg"
+ "msg/Vector3.msg"
)
if(BUILD_TESTING)
diff --git a/custom_msgs/geometry_msgs/msg/Vector3.msg b/custom_msgs/geometry_msgs/msg/Vector3.msg
new file mode 100644
index 0000000..681257d
--- /dev/null
+++ b/custom_msgs/geometry_msgs/msg/Vector3.msg
@@ -0,0 +1,3 @@
+float64 x
+float64 y
+float64 z
\ No newline at end of file
diff --git a/custom_msgs/float_location_msgs/package.xml b/custom_msgs/geometry_msgs/package.xml
similarity index 95%
rename from custom_msgs/float_location_msgs/package.xml
rename to custom_msgs/geometry_msgs/package.xml
index 57aceb4..4ba5e75 100644
--- a/custom_msgs/float_location_msgs/package.xml
+++ b/custom_msgs/geometry_msgs/package.xml
@@ -1,7 +1,7 @@
- float_location_msgs
+ geometry_msgs
0.0.0
TODO: Package description
uden
diff --git a/custom_msgs/mix_msgs/CMakeLists.txt b/custom_msgs/mix_msgs/CMakeLists.txt
new file mode 100644
index 0000000..d3d4416
--- /dev/null
+++ b/custom_msgs/mix_msgs/CMakeLists.txt
@@ -0,0 +1,37 @@
+cmake_minimum_required(VERSION 3.5)
+project(mix_msgs)
+
+# Default to C99
+if(NOT CMAKE_C_STANDARD)
+ set(CMAKE_C_STANDARD 99)
+endif()
+
+# Default to C++14
+if(NOT CMAKE_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD 14)
+endif()
+
+if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ add_compile_options(-Wall -Wextra -Wpedantic)
+endif()
+
+# find dependencies
+find_package(ament_cmake REQUIRED)
+find_package(rosidl_default_generators REQUIRED)
+
+rosidl_generate_interfaces(${PROJECT_NAME}
+ "msg/Mix.msg"
+)
+
+if(BUILD_TESTING)
+ find_package(ament_lint_auto REQUIRED)
+ # the following line skips the linter which checks for copyrights
+ # uncomment the line when a copyright and license is not present in all source files
+ #set(ament_cmake_copyright_FOUND TRUE)
+ # the following line skips cpplint (only works in a git repo)
+ # uncomment the line when this package is not in a git repo
+ #set(ament_cmake_cpplint_FOUND TRUE)
+ ament_lint_auto_find_test_dependencies()
+endif()
+
+ament_package()
\ No newline at end of file
diff --git a/custom_msgs/mix_msgs/msg/Mix.msg b/custom_msgs/mix_msgs/msg/Mix.msg
new file mode 100644
index 0000000..4e55741
--- /dev/null
+++ b/custom_msgs/mix_msgs/msg/Mix.msg
@@ -0,0 +1,4 @@
+string name
+uint16 height
+float32 weight
+uint16[] array
\ No newline at end of file
diff --git a/custom_msgs/mix_msgs/package.xml b/custom_msgs/mix_msgs/package.xml
new file mode 100644
index 0000000..8ebe014
--- /dev/null
+++ b/custom_msgs/mix_msgs/package.xml
@@ -0,0 +1,23 @@
+
+
+
+ mix_msgs
+ 0.0.0
+ TODO: Package description
+ uden
+ TODO: License declaration
+
+ ament_cmake
+
+ rosidl_default_generators
+ rosidl_default_runtime
+
+ rosidl_interface_packages
+
+ ament_lint_auto
+ ament_lint_common
+
+
+ ament_cmake
+
+
\ No newline at end of file
diff --git a/mros2_echoback_health/src/pub_node.cpp b/mros2_echoback_health/src/pub_node.cpp
index 8b7df0c..50c8039 100644
--- a/mros2_echoback_health/src/pub_node.cpp
+++ b/mros2_echoback_health/src/pub_node.cpp
@@ -25,7 +25,7 @@ class Publisher : public rclcpp::Node
void timer_callback()
{
auto message = health_msgs::msg::Health();
- message.name = "Hi";
+ message.name = std::to_string(count_++);
message.height = 170;
message.weight = 63.5;
RCLCPP_INFO(this->get_logger(), "Publishing msg: { name: '%s', height: %u cm, weight: %f kg }", message.name.c_str(), message.height, message.weight);
diff --git a/mros2_echoback_float_location/CMakeLists.txt b/mros2_echoback_mix/CMakeLists.txt
similarity index 87%
rename from mros2_echoback_float_location/CMakeLists.txt
rename to mros2_echoback_mix/CMakeLists.txt
index 4b7171a..f61e790 100644
--- a/mros2_echoback_float_location/CMakeLists.txt
+++ b/mros2_echoback_mix/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
-project(mros2_echoback_float_location)
+project(mros2_echoback_mix)
# Default to C99
@@ -19,16 +19,16 @@ endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
-find_package(float_location_msgs REQUIRED)
+find_package(mix_msgs REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package( REQUIRED)
add_executable(pub_node src/pub_node.cpp)
-ament_target_dependencies(pub_node rclcpp float_location_msgs)
+ament_target_dependencies(pub_node rclcpp mix_msgs)
add_executable(sub_node src/sub_node.cpp)
-ament_target_dependencies(sub_node rclcpp float_location_msgs)
+ament_target_dependencies(sub_node rclcpp mix_msgs)
target_include_directories(pub_node PUBLIC
$
@@ -59,4 +59,4 @@ if(BUILD_TESTING)
ament_lint_auto_find_test_dependencies()
endif()
-ament_package()
+ament_package()
\ No newline at end of file
diff --git a/mros2_echoback_float_location/launch/launch_pubsub.py b/mros2_echoback_mix/launch/launch_pubsub.py
similarity index 82%
rename from mros2_echoback_float_location/launch/launch_pubsub.py
rename to mros2_echoback_mix/launch/launch_pubsub.py
index 974491e..dc56c29 100644
--- a/mros2_echoback_float_location/launch/launch_pubsub.py
+++ b/mros2_echoback_mix/launch/launch_pubsub.py
@@ -5,17 +5,17 @@
def generate_launch_description():
return LaunchDescription([
Node(
- package='mros2_echoback_float_location',
+ package='mros2_echoback_mix',
node_executable='pub_node',
node_name='pub_mros2',
prefix=['stdbuf -o L'],
output="screen"
),
Node(
- package='mros2_echoback_float_location',
+ package='mros2_echoback_mix',
node_executable='sub_node',
node_name='mros2_sub',
prefix=['stdbuf -o L'],
output="screen"
)
- ])
+ ])
\ No newline at end of file
diff --git a/mros2_echoback_float_location/package.xml b/mros2_echoback_mix/package.xml
similarity index 80%
rename from mros2_echoback_float_location/package.xml
rename to mros2_echoback_mix/package.xml
index 7349b49..2a71f50 100644
--- a/mros2_echoback_float_location/package.xml
+++ b/mros2_echoback_mix/package.xml
@@ -1,7 +1,7 @@
- mros2_echoback_float_location
+ mros2_echoback_mix
0.0.0
TODO: Package description
uden
@@ -9,13 +9,13 @@
ament_cmake
rclcpp
-float_location_msgs
+mix_msgs
rclcpp
-float_location_msgs
+mix_msgs
ament_lint_auto
ament_lint_common
ament_cmake
-
+
\ No newline at end of file
diff --git a/mros2_echoback_mix/src/pub_node.cpp b/mros2_echoback_mix/src/pub_node.cpp
new file mode 100644
index 0000000..dbc0ccb
--- /dev/null
+++ b/mros2_echoback_mix/src/pub_node.cpp
@@ -0,0 +1,48 @@
+#include
+#include
+#include
+#include
+
+#include "rclcpp/rclcpp.hpp"
+#include "mix_msgs/msg/mix.hpp"
+
+using namespace std::chrono_literals;
+
+/* This example creates a subclass of Node and uses std::bind() to register a
+* member function as a callback from the timer. */
+
+class Publisher : public rclcpp::Node
+{
+public:
+ Publisher()
+ : Node("pub_mros2"), count_(0)
+ {
+ publisher_ = this->create_publisher("to_stm", 10);
+ timer_ = this->create_wall_timer(1000ms, std::bind(&Publisher::timer_callback, this));
+ }
+
+private:
+ void timer_callback()
+ {
+ auto message = mix_msgs::msg::Mix();
+ message.name = std::to_string(count_++);
+ message.height = 170;
+ message.weight = 63.5;
+ message.array.push_back(count_);
+ message.array.push_back(count_+1);
+ message.array.push_back(count_+2);
+ RCLCPP_INFO(this->get_logger(), "Publishing msg: { name: '%s', height: %u cm, weight: %f kg, array: {%u,%u,%u} }", message.name.c_str(), message.height, message.weight, message.array[0], message.array[1], message.array[2]);
+ publisher_->publish(message);
+ }
+ rclcpp::TimerBase::SharedPtr timer_;
+ rclcpp::Publisher::SharedPtr publisher_;
+ size_t count_;
+};
+
+int main(int argc, char * argv[])
+{
+ rclcpp::init(argc, argv);
+ rclcpp::spin(std::make_shared());
+ rclcpp::shutdown();
+ return 0;
+}
diff --git a/mros2_echoback_mix/src/sub_node.cpp b/mros2_echoback_mix/src/sub_node.cpp
new file mode 100644
index 0000000..7f9ee5c
--- /dev/null
+++ b/mros2_echoback_mix/src/sub_node.cpp
@@ -0,0 +1,34 @@
+#include
+#include
+#include
+#include
+
+#include "rclcpp/rclcpp.hpp"
+#include "mix_msgs/msg/mix.hpp"
+
+using std::placeholders::_1;
+
+class Subscriber : public rclcpp::Node
+{
+public:
+ Subscriber() : Node("mros2_sub")
+ {
+ subscriber_ = this->create_subscription("to_linux", rclcpp::QoS(10).best_effort(), std::bind(&Subscriber::topic_callback, this, _1));
+ }
+
+private:
+ void topic_callback(const mix_msgs::msg::Mix::SharedPtr message) const
+ {
+ RCLCPP_INFO(this->get_logger(), "Subscribed msg: { name: '%s', height: %d cm, weight: %f kg, array: {%u,%u,%u} }", message->name.c_str(), message->height, message->weight, message->array[0], message->array[1], message->array[2]);
+ }
+ rclcpp::Subscription::SharedPtr subscriber_;
+};
+
+
+int main(int argc, char *argv[])
+{
+ rclcpp::init(argc, argv);
+ rclcpp::spin(std::make_shared());
+ rclcpp::shutdown();
+ return 0;
+}
\ No newline at end of file
diff --git a/mros2_echoback_vector3/CMakeLists.txt b/mros2_echoback_vector3/CMakeLists.txt
new file mode 100644
index 0000000..fa1c53b
--- /dev/null
+++ b/mros2_echoback_vector3/CMakeLists.txt
@@ -0,0 +1,62 @@
+cmake_minimum_required(VERSION 3.5)
+project(mros2_echoback_vector3)
+
+
+# Default to C99
+if(NOT CMAKE_C_STANDARD)
+ set(CMAKE_C_STANDARD 99)
+endif()
+
+# Default to C++14
+if(NOT CMAKE_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD 14)
+endif()
+
+if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ add_compile_options(-Wall -Wextra -Wpedantic)
+endif()
+
+# find dependencies
+find_package(ament_cmake REQUIRED)
+find_package(rclcpp REQUIRED)
+find_package(geometry_msgs REQUIRED)
+# uncomment the following section in order to fill in
+# further dependencies manually.
+# find_package( REQUIRED)
+
+add_executable(pub_node src/pub_node.cpp)
+ament_target_dependencies(pub_node rclcpp geometry_msgs)
+
+add_executable(sub_node src/sub_node.cpp)
+ament_target_dependencies(sub_node rclcpp geometry_msgs)
+
+target_include_directories(pub_node PUBLIC
+ $
+ $)
+
+target_include_directories(sub_node PUBLIC
+ $
+ $)
+
+install(TARGETS pub_node
+ DESTINATION lib/${PROJECT_NAME})
+install(TARGETS sub_node
+ DESTINATION lib/${PROJECT_NAME})
+
+install(DIRECTORY
+ launch
+ DESTINATION share/${PROJECT_NAME}
+)
+
+if(BUILD_TESTING)
+ find_package(ament_lint_auto REQUIRED)
+ # the following line skips the linter which checks for copyrights
+ # uncomment the line when a copyright and license is not present in all source files
+ #set(ament_cmake_copyright_FOUND TRUE)
+ # the following line skips cpplint (only works in a git repo)
+ # uncomment the line when this package is not in a git repo
+ #set(ament_cmake_cpplint_FOUND TRUE)
+ ament_lint_auto_find_test_dependencies()
+endif()
+
+ament_package()
\ No newline at end of file
diff --git a/mros2_echoback_vector3/launch/launch_pubsub.py b/mros2_echoback_vector3/launch/launch_pubsub.py
new file mode 100644
index 0000000..8bbf203
--- /dev/null
+++ b/mros2_echoback_vector3/launch/launch_pubsub.py
@@ -0,0 +1,21 @@
+from launch import LaunchDescription
+from launch_ros.actions import Node
+
+# Note: `node_`, `prefix` and `output` will be removed on Foxy
+def generate_launch_description():
+ return LaunchDescription([
+ Node(
+ package='mros2_echoback_vector3',
+ node_executable='pub_node',
+ node_name='pub_mros2',
+ prefix=['stdbuf -o L'],
+ output="screen"
+ ),
+ Node(
+ package='mros2_echoback_vector3',
+ node_executable='sub_node',
+ node_name='mros2_sub',
+ prefix=['stdbuf -o L'],
+ output="screen"
+ )
+ ])
\ No newline at end of file
diff --git a/mros2_echoback_vector3/package.xml b/mros2_echoback_vector3/package.xml
new file mode 100644
index 0000000..cb043c9
--- /dev/null
+++ b/mros2_echoback_vector3/package.xml
@@ -0,0 +1,21 @@
+
+
+
+ mros2_echoback_vector3
+ 0.0.0
+ TODO: Package description
+ uden
+ TODO: License declaration
+
+ ament_cmake
+rclcpp
+geometry_msgs
+rclcpp
+geometry_msgs
+ ament_lint_auto
+ ament_lint_common
+
+
+ ament_cmake
+
+
\ No newline at end of file
diff --git a/mros2_echoback_float_location/src/pub_node.cpp b/mros2_echoback_vector3/src/pub_node.cpp
similarity index 76%
rename from mros2_echoback_float_location/src/pub_node.cpp
rename to mros2_echoback_vector3/src/pub_node.cpp
index 4192938..a662f62 100644
--- a/mros2_echoback_float_location/src/pub_node.cpp
+++ b/mros2_echoback_vector3/src/pub_node.cpp
@@ -4,7 +4,7 @@
#include
#include "rclcpp/rclcpp.hpp"
-#include "float_location_msgs/msg/float_location.hpp"
+#include "geometry_msgs/msg/vector3.hpp"
using namespace std::chrono_literals;
@@ -17,14 +17,14 @@ class Publisher : public rclcpp::Node
Publisher()
: Node("pub_mros2"), count_(0)
{
- publisher_ = this->create_publisher("to_stm", 10);
+ publisher_ = this->create_publisher("to_stm", 10);
timer_ = this->create_wall_timer(1000ms, std::bind(&Publisher::timer_callback, this));
}
private:
void timer_callback()
{
- auto message = float_location_msgs::msg::FloatLocation();
+ auto message = geometry_msgs::msg::Vector3();
message.x = count_++/10.0;
message.y = 2*count_++/10.0;
message.z = 3*count_++/10.0;
@@ -32,7 +32,7 @@ class Publisher : public rclcpp::Node
publisher_->publish(message);
}
rclcpp::TimerBase::SharedPtr timer_;
- rclcpp::Publisher::SharedPtr publisher_;
+ rclcpp::Publisher::SharedPtr publisher_;
size_t count_;
};
@@ -42,4 +42,4 @@ int main(int argc, char *argv[])
rclcpp::spin(std::make_shared());
rclcpp::shutdown();
return 0;
-}
+}
\ No newline at end of file
diff --git a/mros2_echoback_float_location/src/sub_node.cpp b/mros2_echoback_vector3/src/sub_node.cpp
similarity index 55%
rename from mros2_echoback_float_location/src/sub_node.cpp
rename to mros2_echoback_vector3/src/sub_node.cpp
index 0c21ebf..d40cf44 100644
--- a/mros2_echoback_float_location/src/sub_node.cpp
+++ b/mros2_echoback_vector3/src/sub_node.cpp
@@ -4,7 +4,7 @@
#include
#include "rclcpp/rclcpp.hpp"
-#include "float_location_msgs/msg/float_location.hpp"
+#include "geometry_msgs/msg/vector3.hpp"
using std::placeholders::_1;
@@ -13,15 +13,15 @@ class Subscriber : public rclcpp::Node
public:
Subscriber() : Node("mros2_sub")
{
- subscriber_ = this->create_subscription("to_linux", rclcpp::QoS(10).best_effort(), std::bind(&Subscriber::topic_callback, this, _1));
+ subscriber_ = this->create_subscription("to_linux", rclcpp::QoS(10).best_effort(), std::bind(&Subscriber::topic_callback, this, _1));
}
private:
- void topic_callback(const float_location_msgs::msg::FloatLocation::SharedPtr message) const
+ void topic_callback(const geometry_msgs::msg::Vector3::SharedPtr message) const
{
RCLCPP_INFO(this->get_logger(), "Subscribed msg: { x: %f, y: %f, z: %f }", message->x,message->y, message->z);
}
- rclcpp::Subscription::SharedPtr subscriber_;
+ rclcpp::Subscription::SharedPtr subscriber_;
};