Robotics StackExchange | Archived questions

How to start gazebo using roscore & rosrun gazebo_ros gazebo?

I am unable to start gazebo with the following command:

roscore & rosrun gazebo_ros gazebo

this produces the following:

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

Yet, I am able to start gazebo using roscore, gzserver and gzclient in separate terminals. Running ROS hydro, ubuntu 12.04. P.S. Also posted this on ROS forum here: link text

edit 1

roslaunch gazebo_ros empty_world.launch 

produces the following:

PARAMETERS
* /rosdistro
* /rosversion
* /use_sim_time
NODES
 /
gazebo (gazebo_ros/gzserver)
gazebo_gui (gazebo_ros/gzclient)
auto-starting new master
process[master]: started with pid [2049]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to c42a8666-375c-11e4-8516-08002748e08d
process[rosout-1]: started with pid [2062]
started core service [/rosout]
process[gazebo-2]: started with pid [2065]
process[gazebo_gui-3]: started with pid [2079]
terminate called after throwing an instance of 'std::bad_alloc'
what():  std::bad_alloc
Aborted (core dumped)
[gazebo-2] process has died [pid 2065, exit code 134, cmd /opt/ros/hydro/lib/gazebo_ros/gzserver /opt/ros/hydro/share/hector_gazebo_worlds/worlds/rolling_landscape_120m.world __name:=gazebo __log:=/home/usr/.ros/log/c42a8666-375c-11e4-8516-08002748e08d/gazebo-2.log].
log file: /home/usr/.ros/log/c42a8666-375c-11e4-8516-08002748e08d/gazebo-2*.log

edit 2

For backtrace I type:

gdb gzserver empty_world.launch

Then the following appears:


GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from /usr/local/bin/gzserver...done.
/home/daniel/empty_world.launch: No such file or directory.
(gdb)

Then I type: run The following appears:


Starting program: /usr/local/bin/gzserver 
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe200f700 (LWP 2754)]
[New Thread 0x7fffe180e700 (LWP 2755)]
[New Thread 0x7fffe100d700 (LWP 2756)]
[New Thread 0x7fffd3fff700 (LWP 2757)]
[New Thread 0x7fffd1064700 (LWP 2758)]
[New Thread 0x7fffd0863700 (LWP 2759)]
[New Thread 0x7fffc9d55700 (LWP 2760)]
[New Thread 0x7fffc9554700 (LWP 2761)]
[New Thread 0x7fffc8731700 (LWP 2762)]
[New Thread 0x7fffbbfff700 (LWP 2763)]
[New Thread 0x7fffbb7fe700 (LWP 2764)]
[New Thread 0x7fffbaffd700 (LWP 2765)]
[New Thread 0x7fffba7fc700 (LWP 2766)]

And never goes to segfault.

edit 3

I run the following:

rosrun gazebo_ros debug

This produces:


GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from /usr/local/bin/gzserver...done.
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe200f700 (LWP 3381)]
[New Thread 0x7fffd7126700 (LWP 3382)]
[New Thread 0x7fffd6925700 (LWP 3383)]
[ WARN] [1410593874.754148775]: No ROS master - start roscore to continue...
[ WARN] [1410593875.255158359]: Canceled loading Gazebo ROS API plugin by sigint event
[New Thread 0x7fffd6124700 (LWP 3384)]
[New Thread 0x7fffd48b4700 (LWP 3385)]
[New Thread 0x7fffc665f700 (LWP 3386)]
[New Thread 0x7fffc3d9d700 (LWP 3387)]
[New Thread 0x7fffc359c700 (LWP 3388)]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff78f63cb in gazebo::event::EventT::Connect(boost::function const&) (this=0x7ffff7dd93a0, _subscriber=...)
    at /home/daniel/gazebo/gazebo/gazebo/common/Event.hh:580
580       if (!this->myDataPtr->connections.empty())

I type: bt


> #0  0x00007ffff78f63cb in gazebo::event::EventT (gazebo::common::UpdateInfo
> const&)>::Connect(boost::function (gazebo::common::UpdateInfo const&)>
> const&) (this=0x7ffff7dd93a0,
> _subscriber=...)
>     at /home/daniel/gazebo/gazebo/gazebo/common/Event.hh:580
> #1  0x00007ffff7094a5d in ConnectWorldUpdateBegin boost::_mfi::mf1 gazebo::sensors::SimTimeEventHandler,
> gazebo::common::UpdateInfo const&>,
> boost::_bi::list2,
> boost::arg<1> > > > (_subscriber=...)
>     at /home/daniel/gazebo/gazebo/gazebo/common/Events.hh:138
> #2  gazebo::sensors::SimTimeEventHandler::SimTimeEventHandler
> (this=0x156e1f0)
>     at /home/daniel/gazebo/gazebo/gazebo/sensors/SensorManager.cc:664
> #3  0x00007ffff7094bf3 in gazebo::sensors::SensorManager::Init (
>     this=0x7ffff7661240)
>     at /home/daniel/gazebo/gazebo/gazebo/sensors/SensorManager.cc:185
> #4  0x00007ffff708a0c4 in gazebo::sensors::init ()
>     at /home/daniel/gazebo/gazebo/gazebo/sensors/SensorsIface.cc:59
> #5  0x0000000000429db5 in gazebo::setupServer (_argc=5,
> _argv=0x6b5e00)
>     at /home/daniel/gazebo/gazebo/gazebo/gazebo.cc:144
> #6  0x0000000000414b29 in gazebo::Server::ParseArgs
> (this=0x6b5ca0, 
>     _argc=, _argv=)
>     at /home/daniel/gazebo/gazebo/gazebo/Server.cc:213
> #7  0x000000000040e4ce in main (argc=5, argv=0x7fffffffdc88)
>     at /home/daniel/gazebo/gazebo/gazebo/server_main.cc:37

edit 4

I think this is how I should have proceeded in edit 3 Started roscore in a terminal Started rosrun gazebo_ros debug in another terminal bt Produces the following:


#0  0x00007ffff4f4c0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff4f4f83b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ffff55a269d in __gnu_cxx::__verbose_terminate_handler() ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff55a0846 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff55a0873 in std::terminate() ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff55a096e in __cxa_throw ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff55a0e4d in operator new(unsigned long) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff769439e in allocate (__n=, this=)
    at /usr/include/c++/4.6/ext/new_allocator.h:92
#8  _M_allocate (__n=, this=)
    at /usr/include/c++/4.6/bits/stl_vector.h:150
#9  std::vector >::_M_insert_aux (
    this=0x7ffff7dd9460, __position=..., __x=)
    at /usr/include/c++/4.6/bits/vector.tcc:327
#10 0x00007fffda403cfe in gazebo::event::EventT::Connect(boost::function const&) ()
   from /opt/ros/hydro/lib/libgazebo_ros_api_plugin.so
#11 0x00007fffda403de4 in boost::shared_ptr gazebo::event::Events::ConnectWorldCreated to continue, or q  to quit---
, gazebo::GazeboRosApiPlugin, std::string>, boost::_bi::list2, boost::arg<1> > > >(boost::_bi::bind_t, boost::_bi::list2, boost::arg<1> > >) ()
   from /opt/ros/hydro/lib/libgazebo_ros_api_plugin.so
#12 0x00007fffda3cd827 in gazebo::GazeboRosApiPlugin::Load(int, char**) ()
   from /opt/ros/hydro/lib/libgazebo_ros_api_plugin.so
#13 0x00000000004299bc in setup (_argc=5, _argv=0x6b5e00)
    at /home/daniel/gazebo/gazebo/gazebo/gazebo.cc:62
#14 0x0000000000429c87 in gazebo::setupServer (_argc=5, _argv=0x6b5e00)
    at /home/daniel/gazebo/gazebo/gazebo/gazebo.cc:126
#15 0x0000000000414b29 in gazebo::Server::ParseArgs (this=0x6b5ca0, 
    _argc=, _argv=)
    at /home/daniel/gazebo/gazebo/gazebo/Server.cc:213
#16 0x000000000040e4ce in main (argc=5, argv=0x7fffffffdc88)
    at /home/daniel/gazebo/gazebo/gazebo/server_main.cc:37

edit 5

Done: did not find solution. Ended up uninstalling then reinstalling from source. Seems good so far...

Asked by Orso on 2014-09-11 04:20:30 UTC

Comments

Have you tried roslaunch gazebo_ros empty_world.launch?

Asked by scpeters on 2014-09-12 01:45:45 UTC

It looks like a similar error for rosrun gazebo_ros gazebo and roslaunch gazebo_ros empty_world.launch

Asked by Orso on 2014-09-12 16:45:21 UTC

Can you get a backtrace from the coredump?

Asked by scpeters on 2014-09-12 22:12:44 UTC

This will be a useful tutorial for generating the core file: http://wiki.ros.org/roslaunch/Tutorials/Roslaunch%20Nodes%20in%20Valgrind%20or%20GDB then try gdb gzserver corefile then run command thread apply all bt and paste the output here or in a gist so we can look at it

Asked by scpeters on 2014-09-14 19:31:26 UTC

Nevermind, looks like you posted it...

Asked by scpeters on 2014-09-14 19:33:32 UTC

The main thing I'm trying to find is which code statement triggered the problem. It looks like it came from gazebo::event::Events::ConnectWorldCreated (#11) called by gazebo::GazeboRosApiPlugin::Load (#12). I am investigating further...

Asked by scpeters on 2014-09-14 19:45:50 UTC

Thanks for investigating scpeters. Do you suggest I try a reinstall? Though, this will not be so helpful for the next lad that confronts this same problem, which could be me again.

Asked by Orso on 2014-09-15 10:55:56 UTC

I've looked into the problem, but I'm not sure what caused it. Did you say that reinstalling fixed the problem? If that's the case, then it would be very difficult to reproduce, which makes it hard for me to debug.

Asked by scpeters on 2014-09-22 12:02:04 UTC

Yes, re-install fixed the problem. It must be my own error as others have not experienced this. I will keep an eye out for any similar problems. thanks for your investigation. Do I need to credit you or close the question?

Asked by Orso on 2014-09-22 13:36:41 UTC

Why don't you post an answer saying that a re-build and re-install fixed the problem? I'll upvote it.

Asked by scpeters on 2014-09-22 13:42:16 UTC

Answers