Robotics StackExchange | Archived questions

Why do I get "core dumped" error while subscribing to a topic ?

Hi !

I try to create a library, which is directly linked to my simulated robot in Gazebo. Here, I want to access some data such as speed rotation rate of the wheels, their position and so on. I get those values in my World plugin and publish them on topic, using a custom message :

message WheelBoardStateMsg
{
    required string name =1;
    required float drive_speed_radps_ =2;
    required float steering_speed_radps_ =3;
    required float abs_angle_rad_ =4;
}

and :

message WheelBoardStateMsgMultiple
{
    required WheelBoardStateMsg wheelboard_1_state =1;
    required  WheelBoardStateMsg wheelboard_2_state =2;
    required  WheelBoardStateMsg wheelboard_4_state =3;
    required  WheelBoardStateMsg wheelboard_8_state =4;
}

In my library, I want to be able to subscribe to this topic so I created this subscribing function :

typedef const boost::shared_ptr<plugin_msgs::msgs::WheelBoardStateMsgMultiple const> ConstWheelBoardStateMsgMultiplePtr;

// Function is called everytime a message is received.
void robot_gazebo::callbackwheelboard(ConstWheelBoardStateMsgMultiplePtr &_msg){ 
    std::cout << "message received\n" << std::endl; 
    std::cout << _msg->DebugString() << std::endl;
}
int robot_gazebo::subscribeToWheelboardsState(){
// Listen to Gazebo topic
    gazebo::transport::SubscriberPtr subwheelboardstate = this->robot_node->Subscribe("/gazebo/robot_world/robot/wheel_board_state_messages", &robot_gazebo::callbackwheelboard, this);

// Busy wait loop...replace with your own code as needed.
  gazebo::common::Time::MSleep(10);

return 0;
}

I am trying to execute this test file :

int main(int _argc, char **_argv)
{
    robot_gazebo *my_robot = new robot_gazebo(_argc, _argv);

    while (1)
    {
        my_robot->subscribeToWheelboardsState();
    }
    return 0;
}

with :

/////////////////////////////////////////////////
robot_gazebo::robot_gazebo(int _argc, char **_argv)
{
    // Load gazebo
    gazebo::client::setup(_argc, _argv);
    robot_gazebo::setRobotName("robot");
    robot_gazebo::setTopicName("~/"+robot_gazebo::getRobotName()+"/joint_cmd");

    robot_gazebo::createNode();

}
/////////////////////////////////////////////////
robot_gazebo::~robot_gazebo()
{
    // Make sure to shut everything down.
    gazebo::client::shutdown();
}
/////////////////////////////////////////////////
void robot_gazebo::createNode() { // Create our node for communication
  gazebo::transport::NodePtr a_node(new gazebo::transport::Node());
  a_node->Init();
  robot_gazebo::setNode(a_node);
}

void robot_gazebo::setNode(gazebo::transport::NodePtr newnode) { this->robot_node = newnode;}

When I execute this script using

gdb ./test core

it is working for a while and then I get this error :

test: /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::transport::Connection; typename boost::detail::sp_member_access<T>::type = gazebo::transport::Connection*]: Assertion `px != 0' failed.
Abandon (core dumped)

Thread 4 "test" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffc4dc7700 (LWP 16019)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51  ../sysdeps/unix/sysv/linux/raise.c: No files or folders of this type.

Does anyone know what is going on? Thanks in advance, have a good day.

Asked by laura on 2020-08-31 04:37:35 UTC

Comments

Answers