Home | Tutorials | Wiki | Issues
Ask Your Question
0

Custom plugins causes assertion error of boost

asked 2018-06-01 02:11:19 -0600

dnikitop gravatar image

Created a custom plugin to apply force to a link. When only one of these plugins are applied to the urdf, the system works fine. When two are applied to different links, this error pops up and gazebo does not open. Also use ros_control for motor actuation. This error happens even if that is disabled as well.

public: virtual void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
{
  // Store the pointer to the model
  this->model = _parent;
  this->link_name = _sdf->GetElement("BodyName")->Get<std::string>();
  this->link = model->GetLink(this->link_name);

  if(!ros::isInitialized())
  {
    return;
  }
  ros::Duration gazebo_period(model->GetWorld()->Physics()->GetMaxStepSize());
  // Listen to the update event. This event is broadcast every
  // simulation iteration.

  this->rosNode.reset(new ros::NodeHandle(link_name));

  // central_pub = n.advertise<std_msgs::Float32>("force_node_out",10);
  ros::SubscribeOptions so =
       ros::SubscribeOptions::create<std_msgs::Float32>(
       "/" + link_name + "/for_cmd",
       1,
       boost::bind(&ModelPush::OnRosMsg, this, _1),
       ros::VoidPtr(), &this->rosQueue);
   this->rosSub = this->rosNode->subscribe(so);

  // Spin up the queue helper thread.
  this->rosQueueThread =
  std::thread(boost::bind(&ModelPush::QueueThread, this));


  this->updateConnection = event::Events::ConnectWorldUpdateEnd(
      boost::bind(&ModelPush::OnUpdate, this));


  }
// Called by the world update start event
public:  void OnUpdate()
{
  this->link->AddRelativeForce(ignition::math::Vector3d(0,0,force));
}

The error given... C:\fakepath\GazeboError.png

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-06-02 10:52:11 -0600

You should check if this->link is not null, you could be asking for the wrong name, and then the program crashes when you try to access it on OnUpdate.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-06-01 02:11:19 -0600

Seen: 53 times

Last updated: Jun 02 '18