Ask Your Question

Cannot launch gzclient on a launch file - results in shared_ptr assertion error

asked 2020-08-06 11:17:11 -0600

TSC gravatar image

updated 2020-08-06 11:45:22 -0600

  • System: Ubuntu 18.0.4
  • ROS distro: ROS 2 Dashing
  • Gazebo version: 9.13.2
  • gazebo_ros: 3.3.5-3bionic.20200711.114532
  • gazebo_ros_pkgs: 3.3.5-3bionic.20200711.125338

Hi there,

So I have a weird issue where I can use, for example, ros2 launch gazebo_ros verbose:=true pause:=true Timer:=true, or even the example correctly after sourcing the global space setup.bash (with source /opt/ros/dashing/setup.bash), but after sourcing a local (colcon) workspace, I am not able to launch any of these examples, resulting in an error as follows:

gzclient: /usr/include/boost/smart_ptr/shared_ptr.hpp:734:typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = gazebo::rendering::Camera; typename boost::detail::sp_member_access<T>::type gazebo::rendering::Camera*]: Assertion `px != 0' failed.

which as far as I know is a common error which might have many different sources. The one I am pointing right now is to the possibility that the Gazebo env variables get disconfigured/changed when sourcing the workspace, but I don't have anything in the workspace that actually triggers a change in GAZEBO_*_PATH variables.

The above is some of the tests I tried outside of the custom launch file I am creating, but the idea is to run a launch file that as a structure like the following:

   gazebo_launch_dir = os.path.join(
      get_package_share_directory('gazebo_ros'), 'launch')


            [gazebo_launch_dir, '/'])

            [gazebo_launch_dir, '/'])

The above launch file also fails on launching the client, as spoken.

Any tips to find the problem causing this are welcomed. Thanks in advance!

edit retag flag offensive close merge delete



Could you try sourcing Gazebo's setup after sourcing your workspace? . /usr/share/gazebo/ Also, you try getting a backtrace with gdb?

chapulina gravatar image chapulina  ( 2020-08-06 12:05:46 -0600 )edit

Hi! Thanks for the comment. Yes let me try to source the Gazebo source first. (already tried gdb with not much luck)

TSC gravatar image TSC  ( 2020-08-06 12:07:39 -0600 )edit

@chapulina that actually worked! But, why would that be required??

TSC gravatar image TSC  ( 2020-08-06 12:08:47 -0600 )edit

Same! I followed this and it worked for me. Why though???

Any official solution instead of workaround?

kak13 gravatar image kak13  ( 2021-08-30 08:19:55 -0600 )edit

Sorry for spam, but could you mark chapulina's answer as a correct answer?

kak13 gravatar image kak13  ( 2021-08-30 08:20:30 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-09-26 22:15:46 -0600

Moving the comment to an answer. The solution is to source Gazebo's setup file, i.e.:

. /usr/share/gazebo/

This is needed to set some necessary environment variables in case they're going to be overridden, which is a common use case. More context in this issue.

edit flag offensive delete link more


encountered same problem, this was the fix for me.

morten gravatar image morten  ( 2021-11-23 08:33:31 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-08-06 11:17:11 -0600

Seen: 729 times

Last updated: Sep 26 '21