Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
log/
.vscode/
build/
install/
3 changes: 0 additions & 3 deletions custom_msgs/float_location_msgs/msg/FloatLocation

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions custom_msgs/geometry_msgs/msg/Vector3.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
float64 x
float64 y
float64 z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>float_location_msgs</name>
<name>geometry_msgs</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">uden</maintainer>
Expand Down
37 changes: 37 additions & 0 deletions custom_msgs/mix_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 4 additions & 0 deletions custom_msgs/mix_msgs/msg/Mix.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
string name
uint16 height
float32 weight
uint16[] array
23 changes: 23 additions & 0 deletions custom_msgs/mix_msgs/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>mix_msgs</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">uden</maintainer>
<license>TODO: License declaration</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<build_depend>rosidl_default_generators</build_depend>
<exec_depend>rosidl_default_runtime</exec_depend>

<member_of_group>rosidl_interface_packages</member_of_group>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
2 changes: 1 addition & 1 deletion mros2_echoback_health/src/pub_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(mros2_echoback_float_location)
project(mros2_echoback_mix)


# Default to C99
Expand All @@ -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(<dependency> 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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand Down Expand Up @@ -59,4 +59,4 @@ if(BUILD_TESTING)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
ament_package()
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
])
])
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>mros2_echoback_float_location</name>
<name>mros2_echoback_mix</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">uden</maintainer>
<license>TODO: License declaration</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rclcpp</build_depend>
<build_depend>float_location_msgs</build_depend>
<build_depend>mix_msgs</build_depend>
<exec_depend>rclcpp</exec_depend>
<exec_depend>float_location_msgs</exec_depend>
<exec_depend>mix_msgs</exec_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
</package>
48 changes: 48 additions & 0 deletions mros2_echoback_mix/src/pub_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <chrono>
#include <functional>
#include <memory>
#include <string>

#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<mix_msgs::msg::Mix>("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<mix_msgs::msg::Mix>::SharedPtr publisher_;
size_t count_;
};

int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<Publisher>());
rclcpp::shutdown();
return 0;
}
34 changes: 34 additions & 0 deletions mros2_echoback_mix/src/sub_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <chrono>
#include <functional>
#include <memory>
#include <string>

#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<mix_msgs::msg::Mix>("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<mix_msgs::msg::Mix>::SharedPtr subscriber_;
};


int main(int argc, char *argv[])
{
rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<Subscriber>());
rclcpp::shutdown();
return 0;
}
62 changes: 62 additions & 0 deletions mros2_echoback_vector3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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(<dependency> 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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

target_include_directories(sub_node PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

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()
21 changes: 21 additions & 0 deletions mros2_echoback_vector3/launch/launch_pubsub.py
Original file line number Diff line number Diff line change
@@ -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"
)
])
21 changes: 21 additions & 0 deletions mros2_echoback_vector3/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>mros2_echoback_vector3</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">uden</maintainer>
<license>TODO: License declaration</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rclcpp</build_depend>
<build_depend>geometry_msgs</build_depend>
<exec_depend>rclcpp</exec_depend>
<exec_depend>geometry_msgs</exec_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading