Skip to content

Configure

Rahul Katiyar edited this page Jun 17, 2021 · 1 revision

For Cpp Node

Add dependencies

Open package.xml with your text editor.
Add the line:

<depend>node_registry</depend>

This declares the package needs node_registry when its code is executed.

CMakeLists.txt

Now open the CMakeLists.txt file. Below the existing dependency
find_package(ament_cmake REQUIRED), add the lines:\

find_package(node_registry REQUIRED)

Add the node_registry in the ament_target_dependencies

ament_target_dependencies(talker rclcpp std_msgs node_registry)

Cmake Example for a Simple talker node

cmake_minimum_required(VERSION 3.5)
project(talker_cpp_xnode)

# 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(std_msgs REQUIRED)
find_package(node_registry REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()


add_executable(talker src/publisher_member_function.cpp)
ament_target_dependencies(talker rclcpp std_msgs node_registry)

install(TARGETS
  talker
  DESTINATION lib/${PROJECT_NAME})

ament_package()


For Python Node

Add dependencies

Open package.xml with your text editor.
Add the line:

<depend>node_registry</depend>

This declares the package needs node_registry when its code is executed.

Add an entry point

Open the setup.py file.
Add the following line within the console_scripts brackets of the entry_points field:

entry_points={
        'console_scripts': [
            'talker = talker_xnode.talk_node_func.py'
        ],
    },