Skip to content

Commit 6442ee5

Browse files
author
Murilo Marinho
committed
[sas_object_client] Adding test node.
1 parent 2627b9e commit 6442ee5

6 files changed

Lines changed: 96 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.8)
22
project(sas_common)
33

44
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5-
add_compile_options(-Wall -Wextra -Wpedantic)
5+
add_compile_options(-Wall -Wextra -Wpedantic -fPIC)
66
endif()
77

88
set(PYBIND11_FINDPYTHON ON) # Fix CMP0148 Warning. https://github.com/pybind/pybind11/issues/4785
@@ -108,6 +108,37 @@ unset(RCLCPP_LOCAL_BINARY_NAME)
108108
# CPP Binary Block [END] #
109109
##########################
110110

111+
############################
112+
# CPP Binary Block [BEGIN] #
113+
# vvvvvvvvvvvvvvvvvvvvvvvv #
114+
# https://ros2-tutorial.readthedocs.io/en/latest/
115+
# While we cant use blocks https://cmake.org/cmake/help/latest/command/block.html#command:block
116+
# we use set--unset
117+
set(RCLCPP_LOCAL_BINARY_NAME sas_object_test_node)
118+
119+
add_executable(${RCLCPP_LOCAL_BINARY_NAME}
120+
src/examples/sas_object_test_node.cpp
121+
)
122+
123+
ament_target_dependencies(${RCLCPP_LOCAL_BINARY_NAME} PUBLIC
124+
rclcpp)
125+
126+
target_link_libraries(${RCLCPP_LOCAL_BINARY_NAME} PUBLIC
127+
${PROJECT_NAME}
128+
)
129+
130+
target_include_directories(${RCLCPP_LOCAL_BINARY_NAME} PUBLIC
131+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
132+
$<INSTALL_INTERFACE:include>)
133+
134+
install(TARGETS ${RCLCPP_LOCAL_BINARY_NAME}
135+
DESTINATION lib/${PROJECT_NAME})
136+
137+
unset(RCLCPP_LOCAL_BINARY_NAME)
138+
# ^^^^^^^^^^^^^^^^^^^^^^ #
139+
# CPP Binary Block [END] #
140+
##########################
141+
111142
##### LAUNCH FILES #####
112143

113144
install(DIRECTORY

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ SHELL ["/bin/bash", "-c"]
44
ENV BASH_ENV="/etc/bash_env"
55

66
RUN sudo apt-get update && sudo apt-get upgrade -y
7-
RUN sudo sudo dpkg -r --force-depends ros-jazzy-sas-common
7+
RUN sudo sudo apt-get remove -y ros-jazzy-sas-common
88
RUN mkdir -p /root/sas_common_devel/src/

docker/compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ services:
88
&& ls .
99
&& colcon build
1010
&& source install/setup.bash
11-
&& ros2 launch sas_common sas_common_ros2_parameter_test_launch.py"
11+
&& ros2 launch sas_common sas_common_ros2_parameter_test_launch.py
12+
&& ros2 run sas_common sas_object_test_node"

src/examples/sas_common_ros2_parameter_test_node.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
# Copyright (c) 2016-2022 Murilo Marques Marinodeo
2+
# Copyright (c) 2016-2026 Murilo Marques Marinodeo
33
#
44
# This file is part of sas_common.
55
#
6-
# sas_robot_driver is free software: you can redistribute it and/or modify
6+
# sas_common is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU Lesser General Public License as published by
88
# the Free Software Foundation, either version 3 of the License, or
99
# (at your option) any later version.
@@ -60,7 +60,7 @@ int main(int argc, char** argv)
6060
}
6161

6262
rclcpp::init(argc,argv,rclcpp::InitOptions(),rclcpp::SignalHandlerOptions::None);
63-
auto node = std::make_shared<rclcpp::Node>("sas_robot_driver_ros_composer_node");
63+
auto node = std::make_shared<rclcpp::Node>("sas_common_ros2_parameter_test_node");
6464

6565
try
6666
{
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
# Copyright (c) 2026 Murilo Marques Marinodeo
3+
#
4+
# This file is part of sas_common.
5+
#
6+
# sas_common is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# sas_common is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with sas_common. If not, see <https://www.gnu.org/licenses/>.
18+
#
19+
# ################################################################
20+
#
21+
# Author: Murilo M. Marinho, email: murilomarinodeo@ieee.org
22+
#
23+
# ################################################################*/
24+
#include <exception>
25+
#include <rclcpp/rclcpp.hpp>
26+
#include <sas_common/sas_object_client.hpp>
27+
28+
#include<signal.h>
29+
static std::atomic_bool kill_this_process(false);
30+
void sig_int_handler(int)
31+
{
32+
kill_this_process = true;
33+
}
34+
35+
36+
int main(int argc, char** argv)
37+
{
38+
if(signal(SIGINT, sig_int_handler) == SIG_ERR)
39+
{
40+
throw std::runtime_error("::Error setting the signal int handler.");
41+
}
42+
43+
rclcpp::init(argc,argv,rclcpp::InitOptions(),rclcpp::SignalHandlerOptions::None);
44+
auto node = std::make_shared<rclcpp::Node>("sas_object_test_node");
45+
46+
try
47+
{
48+
auto object_client = sas::ObjectClient(node);
49+
}
50+
catch (const std::exception& e)
51+
{
52+
RCLCPP_ERROR_STREAM_ONCE(node->get_logger(),"::Exception::" << e.what());
53+
}
54+
55+
56+
return 0;
57+
}

src/sas_object_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ ObjectClient::ObjectClient(const std::shared_ptr<Node> &node,
4848
topic_prefix_(topic_prefix == "GET_FROM_NODE"? node->get_name() : topic_prefix),
4949
pose_(0)
5050
{
51-
RCLCPP_INFO_STREAM(node_->get_logger(),"::Initializing ObjectClient with prefix " + topic_prefix);
51+
RCLCPP_INFO_STREAM(node_->get_logger(),"::Initializing ObjectClient with prefix " + topic_prefix_);
5252

5353
publisher_pose_ = node->create_publisher<geometry_msgs::msg::PoseStamped>(topic_prefix + "/set/pose",1);
5454

0 commit comments

Comments
 (0)