0
$\begingroup$

Rosanswers logo

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);
}
}

Originally posted by Obeseturtle on ROS Answers with karma: 185 on 2019-01-30

Post score: 1


Original comments

Comment by William on 2019-01-31:
To be clear, does the snippet above run and then crash?

Comment by Obeseturtle on 2019-01-31:
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.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by William with karma: 17335 on 2019-01-30

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Obeseturtle on 2019-01-30:
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?

Comment by William on 2019-01-30:
Can you link a minimal example? Maybe I can spot something that way, but nothing off the top of my head.

Comment by Obeseturtle on 2019-01-30:
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.

Comment by Obeseturtle on 2019-01-31:
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.

Comment by petal on 2019-07-20:
Hello! Did you solve this issue?

Comment by Obeseturtle on 2019-07-22:
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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.