Gazebo | Ignition | Community
Ask Your Question
1

‘setupClient’ is not a member of ‘gazebo’?

asked 2015-03-02 21:28:02 -0600

winston gravatar image

I followed the tutorial(animated box) here: Animated box. After I 'make' it in the build folder, I got the error in the file independent_listener.cc

 error: ‘setupClient’ is not a member of ‘gazebo’

What's the matter?

PS. I use gazebo 1.9 with ROS hydro on Ubuntu 12.04 LTS. The content of independent_listener.cc:

#include <gazebo/transport/transport.hh>
#include <gazebo/msgs/msgs.hh>
#include <gazebo/gazebo.hh>

#include <iostream>

/////////////////////////////////////////////////
// Function is called every time a message is received.
void posesStampedCallback(ConstPosesStampedPtr &posesStamped)
{
  std::cout << posesStamped->DebugString();

  ::google::protobuf::int32 sec = posesStamped->time().sec();
  ::google::protobuf::int32 nsec = posesStamped->time().nsec();
  std::cout << "Read time: sec: " << sec << " nsec: " << nsec << std::endl;

  for (int i =0; i < posesStamped->pose_size(); ++i)
  {
    const ::gazebo::msgs::Pose &pose = posesStamped->pose(i);
    std::string name = pose.name();
    if (name == std::string("box"))
    {
      const ::gazebo::msgs::Vector3d &position = pose.position();

      double x = position.x();
      double y = position.y();
      double z = position.z();

      std::cout << "Read position: x: " << x
          << " y: " << y << " z: " << z << std::endl;
    }
  }
}

/////////////////////////////////////////////////
int main(int _argc, char **_argv)
{
  // Load gazebo
  gazebo::setupClient(_argc, _argv);

  // Create our node for communication
  gazebo::transport::NodePtr node(new gazebo::transport::Node());
  node->Init();

  // Listen to Gazebo pose info topic
  gazebo::transport::SubscriberPtr sub =
  node->Subscribe("~/pose/info", posesStampedCallback);

  // Busy wait loop...replace with your own code as needed.
  while (true)
    gazebo::common::Time::MSleep(10);

  // Make sure to shut everything down.
  gazebo::shutdown();
}
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2015-03-03 06:40:00 -0600

AndreiHaidu gravatar image

Hi,

your gazebo is probably too old, as you can see the tutorial applies for versions 4+

Cheers, Andrei

edit flag offensive delete link more

Comments

Yes, you are right. I just found out the answer but forgot to post it. 'setupClient' is not defined in the old version of Gazebo. Thanks.

winston gravatar imagewinston ( 2015-03-03 07:20:53 -0600 )edit
1

In gazebo 7+ it is supposed to be `gazebo::client::setup(argc, argv)`, include gazebo_client.hh instead of gazebo.hh and need to include gazebo_config.hh initially to get GAZEBO_MAJOR_VERSION.

Lucas Walter gravatar imageLucas Walter ( 2017-07-06 15:20:47 -0600 )edit
0

answered 2020-05-06 22:56:48 -0600

Which version of gazebo did you upgrade to? Thanks.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2015-03-02 21:28:02 -0600

Seen: 1,031 times

Last updated: Mar 03 '15