colcon fails building ros1 package
Hey y'all, pointcloud here again getting into more trouble.
I'm trying to create a tutorial on converting a ROS1 package to ROS2, as I need it for my project and it would be possibly helpful for other people as well to have an example on an actual package, rather than a "tutorial built custom package".
In order to make it more applicable to a wider range of packages.
including a ROS1 package in my micro-ros project fails to build, likely because the conversion is incomplete. <edit> So here are the steps I have taken..
I have been following a tutorial regarding porting ROS1 to ROS2. It can be found here: https://industrial-training-master.re...
1. <micro-ros_ws>/extra_packages git clone https://github.com/TFmini/TFmini-ROS.git
2. modified the CMakeLists.txt (see below before / after)
3. modified the package.xml (see below before / after)
4. modified TFmini.cpp, replacing #include <ros/ros.h> with #include <rclcpp/rclcpp.hpp>
5. <--- This is where my understanding of converting ROS1 package to ROS2 stops --->
6. build of course fails, as I'm likely missing some steps
I believe the issue is with my understanding of converting the ROS1 package properly. I can see the tutorial I'm following converts it straight into ROS2 using cpp as base language, whereas I'm writing a tutorial converting into a micro-ros environment. And that is a quite different task.
Starting to wonder if it would be best to just start writing my whole entire package from the beginning?! Rather than converting an old ROS1 package..
ORIGINAL CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(tfmini_ros)
find_package(catkin REQUIRED COMPONENTS
sensor_msgs
roscpp
)
find_package(Boost REQUIRED COMPONENTS system)
catkin_package(
INCLUDE_DIRS include
)
include_directories(${catkin_INCLUDE_DIRS} include)
add_executable(tfmini_ros_node
src/TFmini_ros_node.cpp
src/TFmini.cpp
)
target_link_libraries(tfmini_ros_node
${catkin_LIBRARIES}
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -std=gnu++11")
install(TARGETS tfmini_ros_node tfmini_ros_node
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY include
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
)
install(FILES
launch/tfmini.launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
Modified CMakeLists.txt
cmake_minimum_required(VERSION 3.8)
project(tfmini_ros)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(sensor_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
"msg/Range.msg"
DEPENDENCIES sensor_msgs
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()
The original package.xml
<?xml version="1.0"?>
<package>
<name>tfmini_ros</name>
<version>0.0.1</version>
<description>The TFmini_ros package</description>
<maintainer email="wenquan@todo.todo">wenquan</maintainer>
<license>TODO</license>
<author >TAN</author>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>roscpp</build_depend>
<run_depend>boost</run_depend>
<export>
</export>
</package>
My modifed package.xml
<?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>tfmini_ros</name>
<version>0.0.1</version>
<description>The TFmini_ros2 package</description>
<maintainer email="mail@gmail.com">administrator</maintainer>
<license>License declaration</license>
<!-- Unsure if sensor_msgs needs to be "depend" or "build_depend" -->
<depend>sensor_msgs</build_depend>
<!--<build_depend>sensor_msgs</build_depend>-->
<build_depend>roscpp</build_depend>
<exec_depend>rosidl_default_runtime</exec_depend>
<member_of_group>rosidl_interface_packages</member_of_group>
<!-- --> ...
Could I ask you to please update the title of your question to better reflect your actual question?
"severely fails" doesn't really convey they fact you're trying to build a ROS 1 Catkin package in a ROS 2 workspace with Colcon.
Hey dude, updated not only the title, but rather the entire question to make more sense. It was probably too early when I wrote that initial post :-/
However, I almost certainly believe it is better to start from scratch creating a package and using the existing ROS1 version as a template, than trying to convert....
Especially for beginners, I believe that is the better approach, as it teaches not only interpreting older packages, but also gets newcomers into building and creating own packages. On top of that using a template (even if it's an older version) it does give some guidance.
Thanks, I will leave this as official and add an answer.
I'm not sure I understand what you did.
TFmini/TFmini-ROS.git
doesn't seem to build any messages itself.The
Range
message is already provided by thesensor_msgs
package. Why are you building it in the package you converted? You also don't appear to be building any of the source files of the original package any more.