Hi all,
It's a newbie question but I'm stuck to this one and I need a gently push to move forward.
So I need to pass 2 input arguments in a local callback of subscriber node.
My header file looks like:
#ifndef _GAZEBO_NETNORMALFORCECALC_PLUGIN_HH_
#define _GAZEBO_NETNORMALFORCECALC_PLUGIN_HH_
#include
#include
#include "gazebo/transport/transport.hh"
#include "ignition/math/Vector3.hh"
#include
namespace gazebo
{
class NetForceCalcPlugin : public WorldPlugin
{
// Constactor
public: NetForceCalcPlugin();
// Destructor
public: virtual ~NetForceCalcPlugin();
// Load the sensor plugin.
// \param[in] _sensor Pointer to the sensor that loaded this plugin.
// \param[in] _sdf SDF element that describes the plugin.
public: virtual void Load(physics::WorldPtr _parent, sdf::ElementPtr /*_sdf*/);
private: transport::NodePtr node;
private: transport::SubscriberPtr normalSub1;
private: ignition::math::Vector3d normal_wheel1;
};
}
#endif
and my cc
#include "net_normalForce_calc.hh"
using namespace gazebo;
NetForceCalcPlugin::NetForceCalcPlugin() : WorldPlugin()
{
}
NetForceCalcPlugin::~NetForceCalcPlugin()
{
}
void cb1(ConstVector3dPtr &_msg, ignition::math::Vector3d normal)
{
normal = ignition::math::Vector3d(_msg->x(), _msg->y(), _msg->z());
ROS_INFO("Normal front_left: [%f, %f, %f]", _msg->x(), _msg->y(), _msg->z());
}
void NetForceCalcPlugin::Load(physics::WorldPtr _parent, sdf::ElementPtr /*_sdf*/)
{
node = transport::NodePtr(new transport::Node());
// Initiaize the node
node->Init();
// Listen to Gazebo world_stats topic
normalSub1 = node->Subscribe("/gazebo/default/contact-surface/front_left_normal", boost::bind(&cb1, _1, normal_wheel1));
ROS_INFO("Net normal stage1 completed succesfully");
}
// Register this plugin with the simulator
GZ_REGISTER_WORLD_PLUGIN(NetForceCalcPlugin)
I know that I probably miss many things but I cannot make it work. From my understanding the compiler waits for a different argument in the boost::bind placeholder and I give something else.
So I get back something looking like:
/home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.cc: In member function ‘virtual void gazebo::NetForceCalcPlugin::Load(gazebo::physics::WorldPtr, sdf::ElementPtr)’:
/home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.cc:27:121: error: no matching function for call to ‘gazebo::transport::Node::Subscribe(const char [50], boost::_bi::bind_t&, ignition::math::Vector3), boost::_bi::list2, boost::_bi::value>>>)’
ault/contact-surface/front_left_normal", boost::bind(&cb1, _1, normal_wheel1));
^
In file included from /usr/include/gazebo-7/gazebo/transport/transport.hh:6:0,
from /usr/include/gazebo-7/gazebo/gazebo_core.hh:22,
from /usr/include/gazebo-7/gazebo/gazebo.hh:20,
from /home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.hh:5,
from /home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.cc:1:
/usr/include/gazebo-7/gazebo/transport/Node.hh:177:21: note: candidate: template gazebo::transport::SubscriberPtr gazebo::transport::Node::Subscribe(const string&, void (T::*)(const boost::shared_ptr&), T*, bool)
SubscriberPtr Subscribe(const std::string &_topic,
^
/usr/include/gazebo-7/gazebo/transport/Node.hh:177:21: note: template argument deduction/substitution failed:
/home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.cc:27:121: note: mismatched types ‘void (T::*)(const boost::shared_ptr&)’ and ‘boost::_bi::bind_t&, ignition::math::Vector3), boost::_bi::list2, boost::_bi::value>>>’
ault/contact-surface/front_left_normal", boost::bind(&cb1, _1, normal_wheel1));
^
In file included from /usr/include/gazebo-7/gazebo/transport/transport.hh:6:0,
from /usr/include/gazebo-7/gazebo/gazebo_core.hh:22,
from /usr/include/gazebo-7/gazebo/gazebo.hh:20,
from /home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.hh:5,
from /home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.cc:1:
/usr/include/gazebo-7/gazebo/transport/Node.hh:206:21: note: candidate: template gazebo::transport::SubscriberPtr gazebo::transport::Node::Subscribe(const string&, void (*)(const boost::shared_ptr&), bool)
SubscriberPtr Subscribe(const std::string &_topic,
^
/usr/include/gazebo-7/gazebo/transport/Node.hh:206:21: note: template argument deduction/substitution failed:
/home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.cc:27:121: note: mismatched types ‘void (*)(const boost::shared_ptr&)’ and ‘boost::_bi::bind_t&, ignition::math::Vector3), boost::_bi::list2, boost::_bi::value>>>’
ault/contact-surface/front_left_normal", boost::bind(&cb1, _1, normal_wheel1));
^
In file included from /usr/include/gazebo-7/gazebo/transport/transport.hh:6:0,
from /usr/include/gazebo-7/gazebo/gazebo_core.hh:22,
from /usr/include/gazebo-7/gazebo/gazebo.hh:20,
from /home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.hh:5,
from /home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.cc:1:
/usr/include/gazebo-7/gazebo/transport/Node.hh:236:21: note: candidate: template gazebo::transport::SubscriberPtr gazebo::transport::Node::Subscribe(const string&, void (T::*)(const string&), T*, bool)
SubscriberPtr Subscribe(const std::string &_topic,
^
/usr/include/gazebo-7/gazebo/transport/Node.hh:236:21: note: template argument deduction/substitution failed:
/home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.cc:27:121: note: mismatched types ‘void (T::*)(const string&)’ and ‘boost::_bi::bind_t&, ignition::math::Vector3), boost::_bi::list2, boost::_bi::value>>>’
ault/contact-surface/front_left_normal", boost::bind(&cb1, _1, normal_wheel1));
^
In file included from /usr/include/gazebo-7/gazebo/transport/transport.hh:6:0,
from /usr/include/gazebo-7/gazebo/gazebo_core.hh:22,
from /usr/include/gazebo-7/gazebo/gazebo.hh:20,
from /home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.hh:5,
from /home/angelos/catkin_ws/src/innoclimber/innoclimber_simulation/innoclimber_gazebo/plugins/net_normalForce_calc.cc:1:
/usr/include/gazebo-7/gazebo/transport/Node.hh:265:21: note: candidate: gazebo::transport::SubscriberPtr gazebo::transport::Node::Subscribe(const string&, void (*)(const string&), bool)
SubscriberPtr Subscribe(const std::string &_topic,
^
/usr/include/gazebo-7/gazebo/transport/Node.hh:265:21: note: no known conversion for argument 2 from ‘boost::_bi::bind_t&, ignition::math::Vector3), boost::_bi::list2, boost::_bi::value>>>’ to ‘void (*)(const string&) {aka void (*)(const std::__cxx11::basic_string&)}’
innoclimber/innoclimber_simulation/innoclimber_gazebo/CMakeFiles/netNormalForceCalc_plugin.dir/build.make:62: recipe for target 'innoclimber/innoclimber_simulation/innoclimber_gazebo/CMakeFiles/netNormalForceCalc_plugin.dir/plugins/net_normalForce_calc.cc.o' failed
make[2]: *** [innoclimber/innoclimber_simulation/innoclimber_gazebo/CMakeFiles/netNormalForceCalc_plugin.dir/plugins/net_normalForce_calc.cc.o] Error 1
CMakeFiles/Makefile2:1636: recipe for target 'innoclimber/innoclimber_simulation/innoclimber_gazebo/CMakeFiles/netNormalForceCalc_plugin.dir/all' failed
make[1]: *** [innoclimber/innoclimber_simulation/innoclimber_gazebo/CMakeFiles/netNormalForceCalc_plugin.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j3 -l3" failed
Thanks for your time!
↧