event.h in ROS2

asked 2019-10-02 03:40:43 -0600

jlepers gravatar image

Hi everyone,

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 initialise 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 wich of those 2 cases is the best?

Thanks in advance !

edit retag flag offensive close merge delete