Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

with

gazebo -s libmy_gazebo_ros_clock.so

the /clock is published OK. And, you may also remove the following parts from the above code, as well.

    In SystemClock::~SystemClock()
    // shutdown ros queue
    this->gazebo_callback_queue_thread_->join();
    delete this->gazebo_callback_queue_thread_;

    In SystemClock::Load
    /// \brief setup custom callback queue
    gazebo_callback_queue_thread_ = new boost::thread(&SystemClock::gazeboQueueThread,this);

/// \brief ros queue thread for this node
void SystemClock::gazeboQueueThread()
{
    ROS_DEBUG_STREAM("Callback thread id=" << boost::this_thread::get_id());
    static const double timeout = 0.001;
    while (this->rosnode_->ok())
    this->gazebo_queue_.callAvailable(ros::WallDuration(timeout));
}

with

gazebo -s libmy_gazebo_ros_clock.so

the /clock is published OK. And, you may also remove the following parts from the above code, as well.

    In SystemClock::~SystemClock()
    // shutdown ros queue
    this->gazebo_callback_queue_thread_->join();
    delete this->gazebo_callback_queue_thread_;

    In SystemClock::Load
    /// \brief setup custom callback queue
    gazebo_callback_queue_thread_ = new boost::thread(&SystemClock::gazeboQueueThread,this);

 /// \brief ros queue thread for this node
 void SystemClock::gazeboQueueThread()
 {
     ROS_DEBUG_STREAM("Callback thread id=" << boost::this_thread::get_id());
     static const double timeout = 0.001;
     while (this->rosnode_->ok())
     this->gazebo_queue_.callAvailable(ros::WallDuration(timeout));
 }

Go to the directory where you have your system plugin and with

gazebo -s libmy_gazebo_ros_clock.so

the /clock is published OK. And, you may also remove the following parts from the above code, as well.

    In SystemClock::~SystemClock()
    // shutdown ros queue
    this->gazebo_callback_queue_thread_->join();
    delete this->gazebo_callback_queue_thread_;

    In SystemClock::Load
    /// \brief setup custom callback queue
    gazebo_callback_queue_thread_ = new boost::thread(&SystemClock::gazeboQueueThread,this);

    /// \brief ros queue thread for this node
    void SystemClock::gazeboQueueThread()
    {
       ROS_DEBUG_STREAM("Callback thread id=" << boost::this_thread::get_id());
       static const double timeout = 0.001;
       while (this->rosnode_->ok())
       this->gazebo_queue_.callAvailable(ros::WallDuration(timeout));
     }