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!
Could you try sourcing Gazebo's setup after sourcing your workspace?
. /usr/share/gazebo/setup.sh
. Also, you try getting a backtrace with gdb?Hi! Thanks for the comment. Yes let me try to source the Gazebo source first. (already tried gdb with not much luck)
@chapulina that actually worked! But, why would that be required??
Same! I followed this and it worked for me. Why though???
Any official solution instead of workaround?
Sorry for spam, but could you mark chapulina's answer as a correct answer?