Cannot launch gzclient on a launch file - results in shared_ptr assertion error
- System: Ubuntu 18.0.4
- ROS distro: ROS 2 Dashing
- Gazebo version: 9.13.2
gazebo_ros
: 3.3.5-3bionic.20200711.114532gazebo_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 gazebo.launch.py verbose:=true pause:=true Timer:=true
, or even the spawn_entity_demo.launch.py
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') ... IncludeLaunchDescription( PythonLaunchDescriptionSource( [gazebo_launch_dir, '/gzserver.launch.py']) ), IncludeLaunchDescription( PythonLaunchDescriptionSource( [gazebo_launch_dir, '/gzclient.launch.py']) ),
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!
Asked by TSC on 2020-08-06 11:17:11 UTC
Answers
Moving the comment to an answer. The solution is to source Gazebo's setup file, i.e.:
. /usr/share/gazebo/setup.sh
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.
Asked by chapulina on 2021-09-26 22:15:46 UTC
Comments
encountered same problem, this was the fix for me.
Asked by morten on 2021-11-23 09:33:31 UTC
Comments
Could you try sourcing Gazebo's setup after sourcing your workspace?
. /usr/share/gazebo/setup.sh
. Also, you try getting a backtrace with gdb?Asked by chapulina on 2020-08-06 12:05:46 UTC
Hi! Thanks for the comment. Yes let me try to source the Gazebo source first. (already tried gdb with not much luck)
Asked by TSC on 2020-08-06 12:07:39 UTC
@chapulina that actually worked! But, why would that be required??
Asked by TSC on 2020-08-06 12:08:47 UTC
Same! I followed this and it worked for me. Why though???
Any official solution instead of workaround?
Asked by kak13 on 2021-08-30 08:19:55 UTC
Sorry for spam, but could you mark chapulina's answer as a correct answer?
Asked by kak13 on 2021-08-30 08:20:30 UTC