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

Revision history [back]

click to hide/show revision 1
initial version

First, change your callback argument const es_1::Draw msg to const es_1::Draw::ConstPtr& msg.

As mentioned in section 2.2. of roscpp tutorial, "The message is passed in a boost shared_ptr"

Now since callback accepts the arguments as boost::shared_ptr, you may encapsulate your action client like this:

boost::shared_ptr<Client> client; client.reset(new Client(..)); // initialize ros::Subscriber sub = n.subscribe<es_1::Draw>("draw", 1000, boost::bind(polygonCallback, _1, client)); ... void polygonCallback(const es_1::Draw::ConstPtr &msg, const boost::shared_ptr<Client> &cl){//Stuff} // use cl by ->

First, change your callback argument const es_1::Draw msg to const es_1::Draw::ConstPtr& msg.

As mentioned in section 2.2. of roscpp tutorial, "The message is passed in a boost shared_ptr"

Now since callback accepts the arguments as boost::shared_ptr, you may encapsulate your action client like this:

``` boost::shared_ptr<client> client;

boost::shared_ptr<Client> client;

client.reset(new Client(..)); // initialize initialize

ros::Subscriber sub = n.subscribe<es_1::Draw>("draw", n.subscribe<es_1::draw>("draw", 1000, boost::bind(polygonCallback, _1, client)); client));

... void polygonCallback(const es_1::Draw::ConstPtr &msg, const boost::shared_ptr<Client> boost::shared_ptr<client> &cl){//Stuff} // use cl by -> '->'

```

First, change your callback argument const es_1::Draw msg to const es_1::Draw::ConstPtr& msg.

As mentioned in section 2.2. of roscpp tutorial, "The message is passed in a boost shared_ptr"

Now since callback accepts the arguments as boost::shared_ptr, you may encapsulate your action client like this:

``` boost::shared_ptr<client> client;

boost::shared_ptr<Client> client; client.reset(new Client(..)); // initialize

initialize ros::Subscriber sub = n.subscribe<es_1::draw>("draw", n.subscribe<es_1::Draw>("draw", 1000, boost::bind(polygonCallback, _1, client));

client)); ... void polygonCallback(const es_1::Draw::ConstPtr &msg, const boost::shared_ptr<client> boost::shared_ptr<Client> &cl){//Stuff} // use cl by '->'->

```

First, change your callback argument const es_1::Draw msg to const es_1::Draw::ConstPtr& msg.

As mentioned in section 2.2. of roscpp tutorial, "The message is passed in a boost shared_ptr"

Now since callback accepts the arguments as boost::shared_ptr, you may encapsulate your action client like this:

boost::shared_ptr<Client> client;

boost::shared_ptr<Client> client;

client.reset(new Client(..)); // initialize initialize

ros::Subscriber sub = n.subscribe<es_1::Draw>("draw", 1000, boost::bind(polygonCallback, _1, client)); ... client));

...

void polygonCallback(const es_1::Draw::ConstPtr &msg, const boost::shared_ptr<Client> &cl){//Stuff} // use cl by -> ->