Ask Your Question
0

[ROS2-Crystal] rclcpp::executors Interrupt guard condition

asked 2019-01-30 18:54:58 -0500

Obeseturtle gravatar image

updated 2019-01-30 22:59:46 -0500

Hi,

After upgrading to ROS2 crystal clemmys, I am receiving a error message:

Failed to create interrupt guard condition in Executor constructor

The same code was used in ROS bouncy but for some reason I am receiving the above mentioned error on Crystal.

The source of the issue is caused when assigning the executor rclcpp::executors::SingleThreadedExecutor executor;.

I am currently trying to pass arguments on assignment to avoid this error message. Was there any changes to how the executors should be called on crystal?


Update:

I tried to reproduce the error message using a simple example using a pure ROS package. I received a different error message this time but, I believe it something to do with the original issue I am facing.

#include <iostream>
#include "rclcpp/executor.hpp"
#include "std_msgs/msg/string.hpp"
#include "rclcpp/rclcpp.hpp"


    std::shared_ptr<rclcpp::Node> master_node;


        void static topic_callback(std_msgs::msg::String::SharedPtr msg)
      {
        std::cout  <<" Subscriber Received [" << msg->data << "]" << std::endl;
      }


    int main(){
    rclcpp::init(0, nullptr);

    rclcpp::executors::MultiThreadedExecutor executor;
    master_node = rclcpp::Node::make_shared("MasterNode");
    auto subscription_ = master_node->create_subscription<std_msgs::msg::String>("TopicName",topic_callback);

    executor.add_node(master_node);


    executor.spin_node_some(master_node);

    }

Just to give a little background on what I am trying to do. Script A is the main code. I will initialize ROS and create a node in script B.

The std::shared_ptr<rclcpp::Node> master_node; is being saved in a Header file of script B which will be used as a global variable.

Other scrips will use this pointer to create their publishers and subscribers. For example script C will create a publisher publisher_ = master_node->create_publisher<std_msgs::msg::String>("topic"); and script D will subscribe to said publisher or other publishers subscription_ = master_node->create_subscription<std_msgs::msg::String>("TopicName",topic_callback); .

The reason I want to use (Single/Multi)ThreadingExecutor is due to main code's thread being used in other matters.


Update2:

I believe the following is a better representation of my current code.

using rclcpp::executors::MultiThreadedExecutor;



std::shared_ptr<rclcpp::Node> master_node;


    void topic_callback(std_msgs::msg::String::SharedPtr msg)
  {
    std::cout  <<" Subscriber Received [" << msg->data << "]" << std::endl;
  }


int main(){
rclcpp::init(0, nullptr);

MultiThreadedExecutor executor;
master_node = rclcpp::Node::make_shared("MasterNode");
auto subscription_ = master_node->create_subscription<std_msgs::msg::String>("TopicName",topic_callback);

executor.add_node(master_node);
std::thread executor_thread(std::bind(&MultiThreadedExecutor::spin, &executor));
executor_thread.detach();
while(true){
std::cout << "hey" << std::endl;
usleep(3000000);
}
}
edit retag flag offensive close merge delete

Comments

To be clear, does the snippet above run and then crash?

William gravatar imageWilliam ( 2019-01-30 23:56:00 -0500 )edit

The update1 code will crash. The update2 code ran without issue. Because I did not see the same error message when using the Update2's code, I began to suspect that some other issue was occurring. It seems that the Interrupt guard condition also occurs if init is not called.

Obeseturtle gravatar imageObeseturtle ( 2019-01-31 00:24:50 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-01-30 20:15:47 -0500

William gravatar image

updated 2019-01-30 20:16:29 -0500

This can happen if the executor is created after rclcpp::shutdown is called or SIGINT is received, either due to ctrl-c or something else signaling.

edit flag offensive delete link more

Comments

I initialized ROS using rclcpp::init(0, nullptr); I have created a couple of publishers with no issue. If my understanding is correct this would mean that the shutdown has not been called.

This issue only effects the subscribers. Is there something I am not setting correctly?

Obeseturtle gravatar imageObeseturtle ( 2019-01-30 20:29:10 -0500 )edit

Can you link a minimal example? Maybe I can spot something that way, but nothing off the top of my head.

William gravatar imageWilliam ( 2019-01-30 21:43:33 -0500 )edit

Sure, Ill add the information as an edit to my original question. Thank you for taking the time out of your day to answer my question.

Obeseturtle gravatar imageObeseturtle ( 2019-01-30 22:08:06 -0500 )edit
1

Hi,

It seems that the script C constructor was being initialized before script B. The error message seen was due to the ROS node not being initialized. This is why the example I provided in my Update2: worked but it didn't on the main script.

Obeseturtle gravatar imageObeseturtle ( 2019-01-31 00:18:12 -0500 )edit

Hello! Did you solve this issue?

petal gravatar imagepetal ( 2019-07-20 12:59:49 -0500 )edit

Yes, it is just an issue of initializing the ROS node before creating a PUB/SUB. If you Like you can create your own ticket so I can see the code and help you out.

Obeseturtle gravatar imageObeseturtle ( 2019-07-22 21:09:10 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-01-30 18:54:58 -0500

Seen: 175 times

Last updated: Jan 30