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

jlin's profile - activity

2022-09-11 21:28:25 -0500 received badge  Nice Question (source)
2020-04-08 10:31:32 -0500 received badge  Famous Question (source)
2019-08-01 22:05:27 -0500 received badge  Nice Question (source)
2019-07-17 02:28:01 -0500 received badge  Famous Question (source)
2019-07-17 02:28:01 -0500 received badge  Notable Question (source)
2019-05-20 01:32:33 -0500 marked best answer roscpp message_filters Synchronizer.registerCallback problem

Hi,

For the example of message filter in this example , I tried to register callback from a class member function as in the following code:

#include <message_filters/subscriber.h>
#include <message_filters/synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>
#include <sensor_msgs/Image.h>

using namespace sensor_msgs;
using namespace message_filters;

typedef sync_policies::ApproximateTime<Image, Image> MySyncPolicy;

void callback(const ImageConstPtr& image1, const ImageConstPtr& image2)
{
  // Solve all of perception here...
}
class A {
  public:
    void my_callback(const ImageConstPtr& image1, const ImageConstPtr& image2) 
    {
    }

    void init(const Synchronizer<MySyncPolicy>& sync) {
       //Fail to compile 
       sync.registerCallback(boost::bind(&A::my_callback, this, _1, _2));
    }
};

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

   ros::NodeHandle nh;
   message_filters::Subscriber<Image> image1_sub(nh, "image1", 1);
   message_filters::Subscriber<Image> image2_sub(nh, "image2", 1);

   // ApproximateTime takes a queue size as its constructor argument, hence MySyncPolicy(10)
   Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), image1_sub, image2_sub);
   sync.registerCallback(boost::bind(&callback, _1, _2));
   A a;
  // this is OK
  sync.registerCallback(boost::bind(&A::my_callback, &a, _1, _2));

  // but this fails
  a.init(sync);
  ros::spin();

  return 0;
}

I could call registerCallback of the A class method in the main sync.registerCallback(boost::bind(&A::my_callback, &a, _1, _2));. But when I made the call in the init of the class definition it failed to compiled with the following errors:

In member function ‘void A::init(const message_filters::Synchronizer<message_filters::sync_policies::approximatetime<sensor_msgs::image_<std::allocator<void> >, sensor_msgs::Image_<std::allocator<void> > > >&)’: /home/mango/workspace/cyngn_ros/src/lev-ros/lev_localization/src/message_test.cpp:26:69: error: no matching function for call to ‘message_filters::Synchronizer<message_filters::sync_policies::approximatetime<sensor_msgs::image_<std::allocator<void> >, sensor_msgs::Image_<std::allocator<void> > > >::registerCallback(boost::_bi::bind_t<void, boost::_mfi::mf2<void,="" a,="" const="" boost::shared_ptr<const="" sensor_msgs::image_<std::allocator<void=""> > >&, const boost::shared_ptr<const sensor_msgs::image_<std::allocator<void=""> > >&>, boost::_bi::list3<boost::_bi::value<a*>, boost::arg<1>, boost::arg<2> > >) const’ sync.registerCallback(boost::bind(&A::my_callback, this, _1, _2)); /opt/ros/kinetic/include/message_filters/synchronizer.h:302:14: note: candidate: message_filters::Connection message_filters::Synchronizer<policy>::registerCallback(C&) [with C = boost::_bi::bind_t<void, boost::_mfi::mf2<void,="" a,="" const="" boost::shared_ptr<const="" sensor_msgs::image_<std::allocator<void=""> > >&, const boost::shared_ptr<const sensor_msgs::image_<std::allocator<void=""> > >&>, boost::_bi::list3<boost::_bi::value<a*>, boost::arg<1>, boost::arg<2> > >; Policy = message_filters::sync_policies::ApproximateTime<sensor_msgs::image_<std::allocator<void> >, sensor_msgs::Image_<std::allocator<void> > >] <near match=""> Connection registerCallback(C& callback) /opt/ros/kinetic/include/message_filters/synchronizer.h:302:14: note: conversion of argument 1 would be ill-formed: /home/mango/workspace/cyngn_ros/src/lev-ros/lev_localization/src/message_test.cpp:26:38: error: invalid initialization of non-const reference of type ‘boost::_bi::bind_t<void, boost::_mfi::mf2<void,="" a,="" const="" boost::shared_ptr<const="" sensor_msgs::image_<std::allocator<void=""> > >&, const boost::shared_ptr<const sensor_msgs::image_<std::allocator<void=""> > >&>, boost::_bi::list3<boost::_bi::value<a*>, boost::arg<1>, boost::arg<2> > >&’ from an rvalue of type ‘boost::_bi::bind_t<void, boost::_mfi::mf2<void,="" a,="" const="" boost::shared_ptr<const="" sensor_msgs::image_ ... (more)

2019-02-13 03:40:15 -0500 received badge  Notable Question (source)
2018-08-23 09:48:19 -0500 received badge  Famous Question (source)
2018-08-23 09:48:19 -0500 received badge  Notable Question (source)
2018-07-20 07:49:32 -0500 received badge  Famous Question (source)
2018-06-05 15:19:25 -0500 commented question Why am I seeing multiple PIDs while running nodelet

Thanks. The document for Nodelet is actually pretty thin on ROS wiki and can be augmented with more concrete coding exam

2018-06-05 11:52:38 -0500 received badge  Popular Question (source)
2018-06-05 01:09:05 -0500 asked a question Why am I seeing multiple PIDs while running nodelet

Why am I seeing multiple PIDs while running nodelet I'm new to nodelet and experimenting an example shown in the GitHub

2018-03-19 07:27:00 -0500 received badge  Notable Question (source)
2018-03-14 07:20:01 -0500 received badge  Popular Question (source)
2018-03-10 00:54:55 -0500 commented answer roscpp message_filters Synchronizer.registerCallback problem

Thank you!

2018-03-10 00:53:28 -0500 received badge  Enthusiast
2018-03-09 16:36:10 -0500 asked a question roscpp message_filters Synchronizer.registerCallback problem

roscpp message_filters Synchronizer.registerCallback problem Hi, For the example of message filter in this example , I

2018-03-09 15:30:15 -0500 marked best answer roscpp message_filters ApproximateTime API questions

Hi,

I have two questions regarding using message_filters ApproximateTimePolicy. From the example, it is not quite clear how I can specify the delay (in seconds) between messages that they can be synchronized. There are setAgePenalty, setInterMessageLowerBound, and setMaxIntervalDuration calls. I winder which one I should be using.

The second question is that I need to instantiate the Synchronizer with SimpleFilter<sensors_msgs::Image> instead of message_filter::Subscriber. Can anyone provide me with a code snippet how to do this? Sorry I'm not very good with c++ template, hence, the question.

Thanks for any help.

2018-03-09 15:12:48 -0500 commented answer roscpp message_filters ApproximateTime API questions

Thanks so much! Somehow the program failed to link with undefined reference to `image_transport::ImageTransport::ImageTr

2018-03-08 13:06:01 -0500 received badge  Popular Question (source)
2018-03-07 22:31:26 -0500 asked a question roscpp message_filters ApproximateTime API questions

roscpp message_filters ApproximateTime API questions Hi, I have two questions regarding using message_filters Approxima

2017-12-01 23:54:15 -0500 received badge  Famous Question (source)
2017-12-01 22:46:25 -0500 commented answer TF quaternion rotation problem

Thanks! That really helps.

2017-12-01 22:44:36 -0500 received badge  Supporter (source)
2017-12-01 22:44:32 -0500 marked best answer TF quaternion rotation problem

My goal is to rotate a quaternion by a yaw angle. q1 is the quaternion that I want to rotate

q1 = quaternion_from_euler(math.pi/2, math.pi/4, math.pi/4)

I want to rotate q1 by 1/4 pi yaw so I create another quaternion q2 for the purpose

q2 = quaternion_from_euler(0, 0, math.pi/4)

I then rotate q1 and I expect the result to be (pi/2, pi/4, pi/2) roll-pitch-yaw

q3 = quaternion_multiply(q1, q2)

But when I convert the result to Euler below is the value.

e3 = euler_from_quaternion(q3)
print e3
(1.5707963267948966, -0.0, 0.7853981633974484)

Looks like it rotates pitch by -pi/4 instead of the yaw by pi/4. Am I doing something wrong? Thanks for any help.

2017-12-01 22:44:32 -0500 received badge  Scholar (source)
2017-12-01 16:45:36 -0500 commented answer TF quaternion rotation problem

Thanks. That works.

2017-12-01 08:01:25 -0500 received badge  Notable Question (source)
2017-12-01 01:37:03 -0500 received badge  Popular Question (source)
2017-11-30 18:05:13 -0500 asked a question TF quaternion rotation problem

TF quaternion rotation problem My goal is to rotate a quaternion by a yaw angle. q1 is the quaternion that I want to rot

2017-11-02 09:42:00 -0500 received badge  Famous Question (source)
2017-07-21 15:27:15 -0500 received badge  Student (source)
2017-07-21 15:26:06 -0500 received badge  Popular Question (source)
2017-06-23 09:48:07 -0500 received badge  Notable Question (source)
2017-06-06 06:02:38 -0500 received badge  Popular Question (source)
2017-05-01 19:09:01 -0500 asked a question how does multiple publishers and multiple subscribers work?

how does multiple publishers and multiple subscribers work? Hi, How does the sockets among M publishers and N subscribe

2017-05-01 19:09:00 -0500 asked a question ROS XMLRPC, TCPROS, UDPROS specification

ROS XMLRPC, TCPROS, UDPROS specification Hi, I'm interested in implementing a pure Erlang client for ROS. Just wondering

2017-05-01 19:09:00 -0500 asked a question ROS XMLRPC, TCPPROS, and UDPROS spec

ROS XMLRPC, TCPPROS, and UDPROS spec Hi, I'm interested in implementing a pure Erlang client for ROS. Just wondering is