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

Xiang's profile - activity

2021-03-21 17:02:20 -0500 received badge  Famous Question (source)
2021-03-21 17:02:20 -0500 received badge  Notable Question (source)
2019-11-04 12:03:14 -0500 received badge  Famous Question (source)
2019-11-04 12:03:14 -0500 received badge  Notable Question (source)
2019-11-04 12:03:14 -0500 received badge  Popular Question (source)
2019-04-12 03:33:27 -0500 received badge  Famous Question (source)
2019-04-12 03:33:27 -0500 received badge  Notable Question (source)
2019-04-12 03:33:27 -0500 received badge  Popular Question (source)
2018-12-09 01:59:35 -0500 edited question Problems when installing pcl library in ROS Indigo

Problems when installing pcl library in ROS Indigo Hi all, I am trying to install the point cloud library in ROS Indigo

2018-12-09 01:54:30 -0500 edited question Problems when installing pcl library in ROS Indigo

Problems when installing pcl package in ROS Indigo Hi all, I am trying to install the point cloud library in ROS Indigo

2018-12-09 01:54:30 -0500 received badge  Editor (source)
2018-12-09 01:54:17 -0500 edited question Problems when installing pcl library in ROS Indigo

Problems when installing pcl package in ROS Indigo Hi all, I am trying to install the point cloud library in ROS Indigo

2018-12-09 01:51:52 -0500 asked a question Problems when installing pcl library in ROS Indigo

Problems when installing pcl package in ROS Indigo Hi all, I am trying to install the point cloud library in ROS Indigo

2018-07-09 13:53:41 -0500 marked best answer a error occurs when using boost::bind to the basic listener.cpp

I made a mistake in previous question here. Hence, I closed it. Here is my new question...

I am using boost bind to subscribe to several topics, following this.

I programmed a basic listener.cpp according to the wiki, and added boost::bind to it. Unfornately, the errors occured.

Can anyone help me? Many thanks.

#include "ros/ros.h"
#include "std_msgs/String.h"

#include <boost/bind.hpp>

void chatterCallback(const std_msgs::String::ConstPtr& msg) {
    ROS_INFO("I heard: [%s]", msg->data.c_str());
}

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

    int i = 0;
    ros::NodeHandle n;
    ros::Subscriber sub = n.subscribe("chatter0", 1000, boost::bind(chatterCallback, _1, i));

    ros::spin();

    return 0;
}

Here is the compiling result.

In file included from /usr/include/boost/bind.hpp:22:0,
                 from /opt/ros/indigo/include/ros/publisher.h:35,
                 from /opt/ros/indigo/include/ros/node_handle.h:32,
                 from /opt/ros/indigo/include/ros/ros.h:45,
                 from /home/alex/Documents/Tutorials/ROS/wiki/catkin_ws/src/beginner_tutorials/src/listener_bind.cpp:1:
/usr/include/boost/bind/bind.hpp: In instantiation of ‘struct boost::_bi::result_traits<boost::_bi::unspecified, void (*)(const boost::shared_ptr<const std_msgs::String_<std::allocator<void> > >&)>’:
/usr/include/boost/bind/bind_template.hpp:15:48:   required from ‘class boost::_bi::bind_t<boost::_bi::unspecified, void (*)(const boost::shared_ptr<const std_msgs::String_<std::allocator<void> > >&), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >’
/home/alex/Documents/Tutorials/ROS/wiki/catkin_ws/src/beginner_tutorials/src/listener_bind.cpp:15:91:   required from here
/usr/include/boost/bind/bind.hpp:69:37: error: ‘void (*)(const boost::shared_ptr<const std_msgs::String_<std::allocator<void> > >&)’ is not a class, struct, or union type
     typedef typename F::result_type type;
                                     ^
/home/alex/Documents/Tutorials/ROS/wiki/catkin_ws/src/beginner_tutorials/src/listener_bind.cpp: In function ‘int main(int, char**)’:
/home/alex/Documents/Tutorials/ROS/wiki/catkin_ws/src/beginner_tutorials/src/listener_bind.cpp:15:92: error: no matching function for call to ‘ros::NodeHandle::subscribe(const char [9], int, boost::_bi::bind_t<boost::_bi::unspecified, void (*)(const boost::shared_ptr<const std_msgs::String_<std::allocator<void> > >&), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >)’
     ros::Subscriber sub = n.subscribe("chatter0", 1000, boost::bind(chatterCallback, _1, i));
                                                                                            ^
/home/alex/Documents/Tutorials/ROS/wiki/catkin_ws/src/beginner_tutorials/src/listener_bind.cpp:15:92: note: candidates are:
In file included from /opt/ros/indigo/include/ros/ros.h:45:0,
                 from /home/alex/Documents/Tutorials/ROS/wiki/catkin_ws/src/beginner_tutorials/src/listener_bind.cpp:1:
/opt/ros/indigo/include/ros/node_handle.h:401:14: note: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(M), T*, const ros::TransportHints&)
   Subscriber subscribe(const std::string& topic, uint32_t queue_size, void(T::*fp)(M), T* obj, 
              ^
/opt/ros/indigo/include/ros/node_handle.h:401:14: note:   template argument deduction/substitution failed:
/home/alex/Documents/Tutorials/ROS/wiki/catkin_ws/src/beginner_tutorials/src/listener_bind.cpp:15:92: note:   mismatched types ‘void (T::*)(M)’ and ‘boost::_bi::bind_t<boost::_bi::unspecified, void (*)(const boost ...
(more)
2018-04-07 20:44:18 -0500 received badge  Famous Question (source)
2018-04-07 20:44:18 -0500 received badge  Notable Question (source)
2018-04-07 20:44:18 -0500 received badge  Popular Question (source)
2017-10-25 05:17:33 -0500 received badge  Popular Question (source)
2017-09-20 23:31:06 -0500 received badge  Famous Question (source)
2017-06-30 03:51:59 -0500 received badge  Notable Question (source)
2017-06-05 10:20:04 -0500 received badge  Popular Question (source)
2017-05-27 06:51:25 -0500 received badge  Self-Learner (source)
2017-05-27 06:51:25 -0500 received badge  Teacher (source)
2017-05-26 03:01:29 -0500 answered a question a error occurs when using boost::bind to the basic listener.cpp

The issued is solved by add the type to subscribe(). Also, do not forget to add 'int i' to the assignment of callback().

2017-05-26 01:10:59 -0500 asked a question a error occurs when using boost::bind to the basic listener.cpp

a error occurs when using boost::bind to the basic listener.cpp I made a mistake in previous question here. Hence, I clo

2017-05-25 06:09:40 -0500 commented question a error occurs when using boost::bind to the basic listener.cpp

Never mind, my mistake about understanding of boost::bind(). I closed the question. Sorry.

2017-05-25 04:30:41 -0500 asked a question a error occurs when using boost::bind to the basic listener.cpp

a error occurs when using boost::bind to the basic listener.cpp Hi, I am using boost bind to subscribe to several topic

2017-05-16 04:32:49 -0500 asked a question Can I apply a namespace to a global named topic?

Can I apply a namespace to a global named topic? Hi, I want to use the namespace to several same nodes. However, the to

2017-03-24 05:33:52 -0500 received badge  Enthusiast
2017-03-19 08:19:51 -0500 received badge  Student (source)
2017-03-17 00:56:54 -0500 commented question Can I record the data of the latest several seconds to a .bag?

Why display 'This post is awaiting moderation'?

2017-03-17 00:56:54 -0500 asked a question Can I record the data of the latest several seconds to a .bag?

Hi,

I would like to record the data of the latest several seconds, but do not find any way to do that.

I think that what I need is a queue. Say, a topic of 1 hz, and I want to record the latest three seconds. The first three seconds are pushed to the queue. When the time stamp is larger than three, the data in the head is pulled, and the new data is pushed.

t0-t1-t2 -> t1-t2-t3 -> t2-t3-t4

I do not know if I am right. Or, is there any easy way to do that? Many thanks.

2017-03-17 00:56:54 -0500 asked a question Can I record the data of the latest several seconds to a .bag?

Hi,

I would like to record the data of the latest several seconds, but do not find any way to do that.

I think that what I need is a queue. Say, a topic of 1 hz, and I want to record the latest three seconds. The data of first three seconds are pushed to the queue. When the time stamp is larger than three, the data in the head is pulled, and the new data is pushed.

t0-t1-t2 -> t1-t2-t3 -> t2-t3-t4

I do not know if I am right. Or, is there any easy way to do that? Many thanks.

2014-07-18 19:10:02 -0500 received badge  Famous Question (source)
2014-04-04 09:37:11 -0500 received badge  Notable Question (source)
2014-04-04 08:16:55 -0500 received badge  Popular Question (source)
2014-03-04 07:47:00 -0500 answered a question Unable to compile PCL 3D Object Recognition tutorial in ROS

I am new to ROS and PCL, but would like to do the similar work with you. Could you please tell me how to use PCL in ROS? Many thanks.

2014-03-03 02:45:19 -0500 commented question No Data from MAVLink_ROS

Should I rosmake the MAVLink_ROS_PKG in a "built" workspace?

2014-03-03 02:34:53 -0500 asked a question No Data from MAVLink_ROS

Hi, I plan to use MAVLink-ROS to read the IMU data from APM2.5. Although it compiles sucessfully by rosmake, the data cannot be received. I use rqt_graph to check the topic and node, but there is no topic or node connected to the node "MAVLink_ros". As a beginner to ROS and Linus, I do not know how to solve the issue. My Ubuntu version is 12.10 and ROS is Hydro. Many thnaks.