1

I'm a student and currently experimenting with the QoS-settings in ROS 2. I'm trying to implement the (RMW_EVENT_REQUESTED_DEADLINE_MISSED) event.

First I declare the subscription and event:

static const rmw_subscription_t sub1
{
    "sub1", (void *) "gets deadline missed",  "topic1"
};
static const rmw_event_t deadline_missed =
{
    "event 1" , (void *) "deadline missed", RMW_EVENT_REQUESTED_DEADLINE_MISSED
};

After that I try to initialize the event:

rmw_subscription_event_init(deadline_missed, sub1, RMW_EVENT_REQUESTED_DEADLINE_MISSED);

But I get an error ( No matching function for call to 'rmw_subscription_event_init')

The program suggests me to change my subscription and event declaration to:

static const rmw_subscription_t *const sub1
{
    "sub1", (void *) "gets deadline missed",  "topic1"
};
static rmw_event_t *const deadline_missed =
{
       "event 1" , (void *) "deadline missed", RMW_EVENT_REQUESTED_DEADLINE_MISSED
};

But then I get the following error (Excess elements in scalar initializer).

How do I fix this problem and which of those 2 cases is the best? Or is there a completely other way of creating this event?

Thanks in advance!

1 Answer 1

1

rmw_subscription_event_init takes pointers as argument so you need to pass the memory adress of your objects rmw_subscription_tand rmw_event_t :

rmw_subscription_event_init(&deadline_missed, &sub1, RMW_EVENT_REQUESTED_DEADLINE_MISSED);

You can also change the definition of sub1 and deadline_missed to be pointers (as you suggested), but in that case you need to properly initialize the pointers to your structs. I recommand reading these excellent answers for more information.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.