I have just written the code for the first part of the rosject (topics), but it does not compile.
It tells me there is a problem with the subscriber, but I think there is no error.
This is how I implemented the subscriber (hidding the core part):
Thank you @bayodesegun for your response.
Even following your instructions I have the same error.
This is my CMakeLists:
# Default to C99
# Default to C++14
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
# find dependencies
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
# Custom interfaces
# Main 1: Publishers&Subsribers
ament_target_dependencies(pt1_wall_follow_node rclcpp std_msgs geometry_msgs)
# Install launch files.
If I comment on the line “subscription_ = this->create_subscription<sensor_msgs::msg::LaserScan>("/scan", 10, std::bind(&WallFollow::scan_callback, this, _1));” it works.
What am I missing?
I just read through your code. I know of two reasons why you are having this subscription error (rosidl_typesupport).
You might have forgotten to include sensor_msgs in to your package dependency (in your CMakeLists.txt and package.xml files). EDIT: I was correct - you don’t have sensor_msgs in your CMakeLists.txt. Also add that in package.xml file.
You have forgotten to define the QoS for the laser scanner subscriber (so your program defaults to system settings - which probably does not match with sensor QoS).
You can get the laser scanner QoS info by doing ros2 topic info /scan -v.
You can get info on scan QoS such as history depth, reliability, durability and liveliness.
Once you have fixed the issues try to run your program. If you still have the issues let us know!