0
$\begingroup$

Rosanswers logo

Hello,

I'm trying to run orbslam2 on a tello drone using ros 2 (foxy distro, ubuntu 20.04). For the purpose, I am trying to use this repository:

https://github.com/tentone/tello-ros2

What I managed to do successfully so far is:

  • Install all dependencies, running scripts/install.sh

  • Build the 3 packages of the repository (tello/tello_control/tello_msg) running scripts/build.sh, which is basically running colcon build on the 3 packages:

    colcon build --symlink-install --packages-select tello tello_control tello_msg

  • Build the ORBSLAM-2 package, through the instructions in the scripts/orbslam.sh script

Now I am trying to compile the nodes in the slam/src/orbslam2 folder. However when I run colcon build in that folder, I get the following error:

    /home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp: In constructor ‘MonocularSlamNode::MonocularSlamNode(ORB_SLAM2::System*, const string&, const string&)’:
/home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:20:141: error: no matching function for call to ‘MonocularSlamNode::create_subscription<ImageMsg>(const char [7], std::_Bind_helper<false, void (MonocularSlamNode::*)(std::shared_ptr<sensor_msgs::msg::Image_<std::allocator<void> > >), MonocularSlamNode*, const std::_Placeholder<1>&>::type)’
   20 |     m_image_subscriber = this->create_subscription<ImageMsg>("camera", std::bind(&MonocularSlamNode::GrabImage, this, std::placeholders::_1));
      |                                                                                                                                             ^
In file included from /opt/ros/foxy/include/rclcpp/executors/single_threaded_executor.hpp:28,
                 from /opt/ros/foxy/include/rclcpp/executors.hpp:22,
                 from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
                 from /home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.hpp:10,
                 from /home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:1:
/opt/ros/foxy/include/rclcpp/node.hpp:213:3: note: candidate: ‘template<class MessageT, class CallbackT, class AllocatorT, class CallbackMessageT, class SubscriptionT, class MessageMemoryStrategyT> std::shared_ptr<SubscriptionT> rclcpp::Node::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>&, typename MessageMemoryStrategyT::SharedPtr)’
  213 |   create_subscription(
      |   ^~~~~~~~~~~~~~~~~~~
/opt/ros/foxy/include/rclcpp/node.hpp:213:3: note:   template argument deduction/substitution failed:
/home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:20:141: note:   candidate expects 5 arguments, 2 provided
   20 |     m_image_subscriber = this->create_subscription<ImageMsg>("camera", std::bind(&MonocularSlamNode::GrabImage, this, std::placeholders::_1));
      |                                                                                                                                             ^
/home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:22:85: error: no matching function for call to ‘MonocularSlamNode::create_publisher<ImageMsg>(const char [16])’
   22 |     m_annotated_image_publisher = this->create_publisher<ImageMsg>("annotated_frame");
      |                                                                                     ^
In file included from /opt/ros/foxy/include/rclcpp/executors/single_threaded_executor.hpp:28,
                 from /opt/ros/foxy/include/rclcpp/executors.hpp:22,
                 from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
                 from /home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.hpp:10,
                 from /home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:1:
/opt/ros/foxy/include/rclcpp/node.hpp:184:3: note: candidate: ‘template<class MessageT, class AllocatorT, class PublisherT> std::shared_ptr<PublisherT> rclcpp::Node::create_publisher(const string&, const rclcpp::QoS&, const rclcpp::PublisherOptionsWithAllocator<AllocatorT>&)’
  184 |   create_publisher(
      |   ^~~~~~~~~~~~~~~~
/opt/ros/foxy/include/rclcpp/node.hpp:184:3: note:   template argument deduction/substitution failed:
/home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:22:85: note:   candidate expects 3 arguments, 1 provided
   22 |     m_annotated_image_publisher = this->create_publisher<ImageMsg>("annotated_frame");
      |                                                                                     ^
/home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:24:71: error: no matching function for call to ‘MonocularSlamNode::create_publisher<MarkerMsg>(const char [13])’
   24 |     m_map_publisher = this->create_publisher<MarkerMsg>("ORB_SLAM_map");
      |                                                                       ^
In file included from /opt/ros/foxy/include/rclcpp/executors/single_threaded_executor.hpp:28,
                 from /opt/ros/foxy/include/rclcpp/executors.hpp:22,
                 from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
                 from /home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.hpp:10,
                 from /home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:1:
/opt/ros/foxy/include/rclcpp/node.hpp:184:3: note: candidate: ‘template<class MessageT, class AllocatorT, class PublisherT> std::shared_ptr<PublisherT> rclcpp::Node::create_publisher(const string&, const rclcpp::QoS&, const rclcpp::PublisherOptionsWithAllocator<AllocatorT>&)’
  184 |   create_publisher(
      |   ^~~~~~~~~~~~~~~~
/opt/ros/foxy/include/rclcpp/node.hpp:184:3: note:   template argument deduction/substitution failed:
/home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:24:71: note:   candidate expects 3 arguments, 1 provided
   24 |     m_map_publisher = this->create_publisher<MarkerMsg>("ORB_SLAM_map");
      |                                                                       ^
/home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:15:78: warning: unused parameter ‘strVocFile’ [-Wunused-parameter]
   15 | MonocularSlamNode::MonocularSlamNode(ORB_SLAM2::System* pSLAM, const string &strVocFile, const string &strSettingsFile)
      |                                                                ~~~~~~~~~~~~~~^~~~~~~~~~
/home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp: In member function ‘void MonocularSlamNode::PublishFrame()’:
/home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:252:63: error: no matching function for call to ‘rclcpp::Publisher<sensor_msgs::msg::Image_<std::allocator<void> > >::publish(sensor_msgs::msg::Image_<std::allocator<void> >::SharedPtr)’
  252 |     m_annotated_image_publisher->publish(rosImage.toImageMsg());
      |                                                               ^
In file included from /opt/ros/foxy/include/rclcpp/topic_statistics/subscription_topic_statistics.hpp:31,
                 from /opt/ros/foxy/include/rclcpp/subscription.hpp:50,
                 from /opt/ros/foxy/include/rclcpp/any_executable.hpp:25,
                 from /opt/ros/foxy/include/rclcpp/memory_strategy.hpp:24,
                 from /opt/ros/foxy/include/rclcpp/memory_strategies.hpp:18,
                 from /opt/ros/foxy/include/rclcpp/executor_options.hpp:20,
                 from /opt/ros/foxy/include/rclcpp/executor.hpp:33,
                 from /opt/ros/foxy/include/rclcpp/executors/multi_threaded_executor.hpp:26,
                 from /opt/ros/foxy/include/rclcpp/executors.hpp:21,
                 from /opt/ros/foxy/include/rclcpp/rclcpp.hpp:146,
                 from /home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.hpp:10,
                 from /home/huangpan1/tello_1410/tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp:1:
/opt/ros/foxy/include/rclcpp/publisher.hpp:185:3: note: candidate: ‘void rclcpp::Publisher<MessageT, AllocatorT>::publish(std::unique_ptr<MessageT, typename std::conditional<std::is_same<typename std::allocator_traits<typename std::allocator_traits<_Alloc>::rebind_traits<MessageT>::allocator_type>::rebind_alloc<MessageT>, typename std::allocator<void>::rebind<_Tp1>::other>::value, std::default_delete<_Tp>, rclcpp::allocator::AllocatorDeleter<typename std::allocator_traits<_Alloc>::rebind_traits<MessageT>::allocator_type> >::type>) [with MessageT = sensor_msgs::msg::Image_<std::allocator<void> >; AllocatorT = std::allocator<void>; typename std::conditional<std::is_same<typename std::allocator_traits<typename std::allocator_traits<_Alloc>::rebind_traits<MessageT>::allocator_type>::rebind_alloc<MessageT>, typename std::allocator<void>::rebind<_Tp1>::other>::value, std::default_delete<_Tp>, rclcpp::allocator::AllocatorDeleter<typename std::allocator_traits<_Alloc>::rebind_traits<MessageT>::allocator_type> >::type = std::default_delete<sensor_msgs::msg::Image_<std::allocator<void> > >]’
  185 |   publish(std::unique_ptr<MessageT, MessageDeleter> msg)
      |   ^~~~~~~
/opt/ros/foxy/include/rclcpp/publisher.hpp:185:53: note:   no known conversion for argument 1 from ‘sensor_msgs::msg::Image_<std::allocator<void> >::SharedPtr’ {aka ‘std::shared_ptr<sensor_msgs::msg::Image_<std::allocator<void> > >’} to ‘std::unique_ptr<sensor_msgs::msg::Image_<std::allocator<void> >, std::default_delete<sensor_msgs::msg::Image_<std::allocator<void> > > >’
  185 |   publish(std::unique_ptr<MessageT, MessageDeleter> msg)
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/opt/ros/foxy/include/rclcpp/publisher.hpp:209:3: note: candidate: ‘void rclcpp::Publisher<MessageT, AllocatorT>::publish(const MessageT&) [with MessageT = sensor_msgs::msg::Image_<std::allocator<void> >; AllocatorT = std::allocator<void>]’
  209 |   publish(const MessageT & msg)
      |   ^~~~~~~
/opt/ros/foxy/include/rclcpp/publisher.hpp:209:28: note:   no known conversion for argument 1 from ‘sensor_msgs::msg::Image_<std::allocator<void> >::SharedPtr’ {aka ‘std::shared_ptr<sensor_msgs::msg::Image_<std::allocator<void> > >’} to ‘const sensor_msgs::msg::Image_<std::allocator<void> >&’
  209 |   publish(const MessageT & msg)
      |           ~~~~~~~~~~~~~~~~~^~~
/opt/ros/foxy/include/rclcpp/publisher.hpp:226:3: note: candidate: ‘void rclcpp::Publisher<MessageT, AllocatorT>::publish(const rcl_serialized_message_t&) [with MessageT = sensor_msgs::msg::Image_<std::allocator<void> >; AllocatorT = std::allocator<void>; rcl_serialized_message_t = rcutils_uint8_array_t]’
  226 |   publish(const rcl_serialized_message_t & serialized_msg)
      |   ^~~~~~~
/opt/ros/foxy/include/rclcpp/publisher.hpp:226:44: note:   no known conversion for argument 1 from ‘sensor_msgs::msg::Image_<std::allocator<void> >::SharedPtr’ {aka ‘std::shared_ptr<sensor_msgs::msg::Image_<std::allocator<void> > >’} to ‘const rcl_serialized_message_t&’ {aka ‘const rcutils_uint8_array_t&’}
  226 |   publish(const rcl_serialized_message_t & serialized_msg)
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/opt/ros/foxy/include/rclcpp/publisher.hpp:232:3: note: candidate: ‘void rclcpp::Publisher<MessageT, AllocatorT>::publish(const rclcpp::SerializedMessage&) [with MessageT = sensor_msgs::msg::Image_<std::allocator<void> >; AllocatorT = std::allocator<void>]’
  232 |   publish(const SerializedMessage & serialized_msg)
      |   ^~~~~~~
/opt/ros/foxy/include/rclcpp/publisher.hpp:232:37: note:   no known conversion for argument 1 from ‘sensor_msgs::msg::Image_<std::allocator<void> >::SharedPtr’ {aka ‘std::shared_ptr<sensor_msgs::msg::Image_<std::allocator<void> > >’} to ‘const rclcpp::SerializedMessage&’
  232 |   publish(const SerializedMessage & serialized_msg)
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/opt/ros/foxy/include/rclcpp/publisher.hpp:246:3: note: candidate: ‘void rclcpp::Publisher<MessageT, AllocatorT>::publish(rclcpp::LoanedMessage<MessageT, AllocatorT>&&) [with MessageT = sensor_msgs::msg::Image_<std::allocator<void> >; AllocatorT = std::allocator<void>]’
  246 |   publish(rclcpp::LoanedMessage<MessageT, AllocatorT> && loaned_msg)
      |   ^~~~~~~
/opt/ros/foxy/include/rclcpp/publisher.hpp:246:58: note:   no known conversion for argument 1 from ‘sensor_msgs::msg::Image_<std::allocator<void> >::SharedPtr’ {aka ‘std::shared_ptr<sensor_msgs::msg::Image_<std::allocator<void> > >’} to ‘rclcpp::LoanedMessage<sensor_msgs::msg::Image_<std::allocator<void> >, std::allocator<void> >&&’
  246 |   publish(rclcpp::LoanedMessage<MessageT, AllocatorT> && loaned_msg)

And similar errors on lines 22 and 24 of the same file, stating that there is no matching function for create_publisher: link text

As far as I understand, the monocular-slam-node is declared inside the src/monocular/monocular-slam-node.hpp header as a rclcpp::Node, at this line: https://github.com/tentone/tello-ros2/blob/main/slam/src/orbslam2/src/monocular/monocular-slam-node.hpp#L22 So it should inherit the methods of rclcpp::Node, among which the create_subscription and create_publisher methods, but somehow it seems there is a mismatch between the number of arguments passed to the call to those methods...

I already sourced the environment, source /opt/ros/foxy/local_setup.bash.

Can someone please help me understand what is wrong here? Thank you very much!

EDITED: Added more info


Originally posted by damiano on ROS Answers with karma: 18 on 2022-10-17

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I looked at the source code and found something strange. A subscription must be defined with a QoS, which is surprisingly not mentioned in the code. Therefore, please edit the source code (tello-ros2/slam/src/orbslam2/src/monocular/monocular-slam-node.cpp) by adding appropriate QoS. An example is shown below:

m_image_subscriber = this->create_subscription<ImageMsg>("camera", 10, std::bind(&MonocularSlamNode::GrabImage, this, std::placeholders::_1));

Please inform us if the problem persists.


Originally posted by ravijoshi with karma: 1744 on 2022-10-17

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by damiano on 2022-10-17:
Thanks, indeed I arrived to the same solution after googling and I found some similar question posted on another github repository. Similarly, I fixed the error on the create_publisher function as well. Thank you!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.