ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

A nodelet is blocking another nodelet

asked 2021-10-20 01:28:17 -0600

zuy gravatar image

updated 2022-05-01 13:05:42 -0600

lucasw gravatar image

Hi, I have a package which contains 2 nodelets and I want to run these 2 nodelets in the same manager. The problem is, I can only run 1 nodelets at a time, when I run both of them only the one which get to run first is executed, the other one give me the following output:

[ INFO] [1634708917.097720708]: Loading nodelet /driver_nodelet of type driver_nodelet/Driver to manager nodelet_manager with the following remappings:

Seems like it is executed but it literally does nothing. Does this mean that the first one is blocking the second one from being loaded? And when I run both of them and terminate the manager, it also terminate the second-executed nodelet. Here is my packages files: plugins.xml:

<library path="lib/libdriver_nodelet">
<class name="driver_nodelet/Driver"
     type="driver_nodelet::Driver"
     base_class_type="nodelet::Nodelet">
<description>
    Driver node
</description>
</class>
<class name="odometry/Odom"
     type="odometry::Odom"
     base_class_type="nodelet::Nodelet">
<description>
    Odom node
</description>
</class>
</library>

my package.xml:

<?xml version="1.0"?>
<package format="2">
<name>driver_nodelet</name>
<version>0.0.0</version>
<description>The driver_nodelet package</description>
<maintainer email="sonpham@todo.todo">sonpham</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>nodelet</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>serial</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>message_generation</build_depend>
<build_export_depend>nodelet</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>serial</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>nodelet</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>serial</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>message_runtime</exec_depend>

<export>
<nodelet plugin="${prefix}/plugins.xml"/>
</export>
</package>

My CMakeLists.txt:

cmake_minimum_required(VERSION 3.0.2)
project(driver_nodelet)


find_package(catkin REQUIRED COMPONENTS
nodelet
roscpp
serial
std_msgs
message_generation
)


add_message_files(
FILES
channel_values.msg
)


generate_messages(
DEPENDENCIES
std_msgs
)


catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES Driver_nodelet
CATKIN_DEPENDS nodelet roscpp serial std_msgs message_runtime
#  DEPENDS system_lib
)



include_directories(
# include
${catkin_INCLUDE_DIRS}
)

## Declare a C++ library
add_library(driver_nodelet
src/driver.cpp

 )
add_library(odom
src/odom.cpp

 )


target_link_libraries(driver_nodelet
${catkin_LIBRARIES}
)
target_link_libraries(odom
${catkin_LIBRARIES}
)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-10-20 01:52:43 -0600

zuy gravatar image

For anyone get insterested, the reason is I put while(ros::ok()) loop inside both of 2 nodelets code, so it keep blocking other process, you shouldn't do this inside a nodelet. If you want a period action, use ros::Timer instead.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-10-20 01:28:17 -0600

Seen: 103 times

Last updated: Oct 20 '21