ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

mirella melo's profile - activity

2023-06-08 15:59:39 -0500 marked best answer error: ‘_1’ was not declared in this scope

Hi.

I'm trying to use boost bind in my ROS 2 package. But I'm getting the following error when building with Colcon build:

error:‘_1’ was not declared in this scope

error:‘ _2’ was not declared in this scope

Here is my C++ code:

 #include <functional>
 #include <memory>
 #include "rclcpp/rclcpp.hpp"
 #include "std_msgs/msg/string.hpp"
 #include <message_filters/subscriber.h>
 #include <message_filters/synchronizer.h>
 #include <message_filters/sync_policies/approximate_time.h>
 #include <message_filters/time_synchronizer.h>
 #include "boost/bind/bind.hpp"
 #include <functional>

 void callback(const std_msgs::msg::String::SharedPtr& st_1, 
      const std_msgs::msg::String::SharedPtr& st_2) {
         // Callback function...
 }

 int main(int argc, char** argv){
     rclcpp::init(argc, argv);
     auto node = rclcpp::Node::make_shared("my_node");

     message_filters::Subscriber<std_msgs::msg::String> st_1(node, "st_1");
     message_filters::Subscriber<std_msgs::msg::String> st_2(node, "st_2");
     message_filters::TimeSynchronizer<std_msgs::msg::String, std_msgs::msg::String> sync(st_1, st_2, 10);
     sync.registerCallback(boost::bind(&callback, _1, _2));

    rclcpp::spin(node);

    return 0;
 }

CMakeFile:

 cmake_minimum_required(VERSION 3.5)
 project(project)

 # 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(message_filters REQUIRED)
 find_package(Boost REQUIRED COMPONENTS 
      system
      filesystem 
      date_time 
      thread
 )

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

 add_executable(sub src/subscriber.cpp)
 ament_target_dependencies(sub rclcpp std_msgs message_filters)
 target_include_directories(sub PRIVATE ${Boost_INCLUDE_DIRS})
 target_link_libraries(sub ${Boost_LIBRARIES})

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

 ament_package()

Any help is welcome! Thanks!

2023-06-08 15:59:39 -0500 received badge  Self-Learner (source)
2023-03-13 06:17:04 -0500 received badge  Nice Answer (source)
2022-09-27 12:27:16 -0500 received badge  Great Question (source)
2022-06-01 19:39:09 -0500 marked best answer Linking OpenCV library (ROS2, C++)

Hi!

I'd like to use the OpenCV library in a C++ project - ROS2 (building with colcon build).

I added in the CmakeList the following command:

find_package(OpenCV 3.4.0 REQUIRED)

And when I #include any OpenCV header in my main code, I have no errors, but when I call any function of it, I have linking errors. It may be missing something in the CmakeList, but I don't know exactly what...

I appreciate any help. Thanks!

2021-11-16 11:12:11 -0500 received badge  Notable Question (source)
2021-11-16 11:12:11 -0500 received badge  Famous Question (source)
2021-10-12 07:01:55 -0500 received badge  Necromancer (source)
2021-08-19 04:30:40 -0500 marked best answer How to subscribe to two images (ROS 2 and C++)

Hi.

I'm trying to use message_filters package (I also tried with image_transport...) to subscribe to two images. I couldn't understand the usage for ROS 2, but I found this short example for ROS 1. So, what changes do I need to do in this code to have it running in ROS 2?

Thanks in advance.

  using namespace sensor_msgs;
  using namespace message_filters;

  void callback(const ImageConstPtr& image, const ImageConstPtr& cam_info)
  {
       // Callback function...
  }

  int main(int argc, char** argv)
  {
         ros::init(argc, argv, "vision_node");
         ros::NodeHandle nh;

         message_filters::Subscriber<Image> image_1(nh, "image_1", 1);
         message_filters::Subscriber<Image> image_2(nh, "image_2", 1);
         TimeSynchronizer<Image, Image> sync(image_sub, info_sub, 10);
         sync.registerCallback(boost::bind(&callback, _1, _2));

        ros::spin();

        return 0;
  }
2021-08-19 04:30:40 -0500 received badge  Self-Learner (source)
2021-07-13 13:57:40 -0500 received badge  Necromancer (source)
2021-06-22 08:15:41 -0500 received badge  Good Question (source)
2021-05-29 09:47:43 -0500 received badge  Famous Question (source)
2021-05-25 06:03:46 -0500 marked best answer Timestamp message ros2 - python

Hi. I`m trying to form the timestamp message in ROS2 (dashing) in python.

When I use

msg.header.stamp = node.get_clock().now()

I have the error:

The 'stamp' field must be a sub message of type 'Time'

Thanks in advance! :)

'

2021-05-18 12:59:54 -0500 received badge  Famous Question (source)
2021-04-24 23:27:42 -0500 received badge  Notable Question (source)
2021-04-08 15:59:16 -0500 received badge  Popular Question (source)
2021-04-06 15:41:02 -0500 edited question Create wall timer using callback with parameters - ROS2, C++

Create wall timer using callback with parameters - ROS2, C++ Hi. I have two image msg synchronized as follows: message

2021-04-06 15:39:26 -0500 asked a question Create wall timer using callback with parameters - ROS2, C++

Create wall timer using callback with parameters - ROS2, C++ Hi. I have two image msg synchronized as follows: message

2021-03-26 16:06:48 -0500 answered a question camera_calibration set_camera_info Service not found

For melodic, I simply removed anything related to the camera info file in the command line. rosrun camera_calibration c

2021-02-17 03:22:12 -0500 received badge  Notable Question (source)
2021-02-17 03:22:12 -0500 received badge  Popular Question (source)
2020-12-13 14:32:35 -0500 received badge  Popular Question (source)
2020-12-12 12:10:53 -0500 received badge  Famous Question (source)
2020-12-03 20:24:15 -0500 marked best answer Getting error after calling a service in eloquent

Hi!

I`m trying to use a Rtabmap service, which is defined as follows:

 #request
 bool global
 bool optimized
 bool graph_only
 ---
 #response

Then, I call:

 ros2 service call /publish_map rtabmap_ros/srv/PublishMap "{global: 1, optimized: 1, graph_only: 0}"

But it returns:

Traceback (most recent call last):
File "/opt/ros/eloquent/bin/ros2", line 11, in <module>
    load_entry_point('ros2cli==0.8.7', 'console_scripts', 'ros2')()
File "/opt/ros/eloquent/lib/python3.6/site-packages/ros2cli/cli.py", line 69, in main
    rc = extension.main(parser=parser, args=args)
File "/opt/ros/eloquent/lib/python3.6/site-packages/ros2service/command/service.py", line 43, in main
    return extension.main(args=args)
File "/opt/ros/eloquent/lib/python3.6/site-packages/ros2service/verb/call.py", line 59, in main
    args.service_type, args.service_name, args.values, period)
File "/opt/ros/eloquent/lib/python3.6/site-packages/ros2service/verb/call.py", line 69, in requester
    module = importlib.import_module('.'.join(parts[:-1]))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/user/rtabmap_ros/install/rtabmap_ros/lib/python3.6/site-packages/rtabmap_ros/srv/__init__.py", line 1, in <module>
    from rtabmap_ros.srv._get_map import GetMap  # noqa: F401
File "/home/user/rtabmap_ros/install/rtabmap_ros/lib/python3.6/site-packages/rtabmap_ros/srv/_get_map.py", line 77
    self.global = kwargs.get('global', bool())
            ^
SyntaxError: invalid syntax

Please, any idea why this is happening?

Thanks in advance!

2020-12-03 20:24:13 -0500 commented answer Getting error after calling a service in eloquent

This makes sense! Hopefully, the Rtabmap team will fix it if this is the case. Thank you for your reply!!

2020-12-02 16:10:44 -0500 asked a question Getting error after calling a service in eloquent

Getting error after calling a service in eloquent Hi! I`m trying to use a Rtabmap service, which is defined as follows:

2020-11-06 21:05:26 -0500 edited question Rtab-map : unexpected occupancy grid map

Rtab-map : unexpected occupancy grid map Hi, I just started using Rtabmap and I'm having an unexpected 2D occupancy grid

2020-11-06 20:39:51 -0500 commented question The proper way to define a TF tree

Thanks for replying! I'm using OpenvSlam. And here is my odometry node. I detected/did few improvements and I'm not gett

2020-11-05 12:14:06 -0500 received badge  Famous Question (source)