ConstRaySensorPtr error in shared_ptr.hpp:648

asked 2018-01-06 00:56:02 -0500

zesaro gravatar image

I have a SensorPlugin which subscribes to the sensor given as parameter in the Load function. My goal is to get the msg from the topic and publish it to ros. But I am already failing in subscribing. When I print the DebugString of the msg I get the following error

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

I am not doing much. So where is the problem? My code looks like this:

public: virtual void Load(sensors::SensorPtr _sensor, sdf::ElementPtr _sdf) {
            this->sensor = _sensor;
            this->sdf = sdf;

            std::string topicName = sensor->Topic();
            this->node = transport::NodePtr(new transport::Node());
            this->node->Init();
            this->sub = this->node->Subscribe(topicName, &SensorPlugin::OnMsg, this);
        }

    private: void OnMsg(ConstRaySensorPtr &_msg)
        {
                std::cout << _msg->DebugString() << std::endl;
         }

Using gz topic -e "..." and an external subscriber running the same code are working. I get the correct topic from sensor->Topic(). Is there a conflict using a SensorPlugin instead of RaySensorPlugin? I can't imagine that.

edit retag flag offensive close merge delete