MessagePoolMemoryStrategy initialization fails with sensor_msgs/msg/imu
My setup:
ROS2 crystal, colcon build system, Ubuntu 18.04.1, gcc compiler:7.3.0
Hi , I tried initializing the message pool memory strategy for two different message types, the "Twist" message from geometry_msgs and "Imu" msg from sensor_msgs. Here is the code:
#include "rclcpp/rclcpp.hpp"
#include "sensor_msgs/msg/imu.hpp"
#include <rclcpp/strategies/message_pool_memory_strategy.hpp>
#include "geometry_msgs/msg/twist.hpp"
int main(int argc, char** argv) {
rclcpp::init(argc, argv);
auto memory_strategy_twist =std::make_shared<rclcpp::strategies::message_pool_memory_strategy::MessagePoolMemoryStrategy <geometry_msgs::msg::Twist, 1>>();
auto memory_strategy_imu = std::make_shared<rclcpp::strategies::message_pool_memory_strategy::MessagePoolMemoryStrategy <sensor_msgs::msg::Imu,1 >>();
rclcpp::shutdown();
return EXIT_SUCCESS;
}
I get a compiler error:
/home/xxxx/demo1/src/test1-1.cpp: In function ‘int main(int, char**)’:
/home/xxxx/demo1/src/test1-1.cpp:15:143: error: wrong number of template arguments (1, should be at
least 2)
:strategies::message_pool_memory_strategy::MessagePoolMemoryStrategy<sensor_msgs::msg::Imu >>()
;
^~~
when I comment out the initialization for memory_strategy_imu , the build is successful. Any Ideas on how I can get it to compile for Imu message types?
CMakeLists.txt:
cmake_minimum_required(VERSION 3.5)
project(demo1)
# 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(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
add_executable(Demo_test
src/test1-1.cpp )
ament_target_dependencies(Demo_test
"rclcpp" "sensor_msgs"
"geometry_msgs")
install(TARGETS
Demo_test
DESTINATION bin)
ament_package()
package.xml:
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>demo1</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="xxx">xxx</maintainer>
<license>TODO: License declaration</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rclcpp</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>geometry_msgs</build_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>rclcpp</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>