ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

error: ‘options’ does not name a type

asked 2022-07-21 05:28:28 -0500

cjoshi17 gravatar image

Hello,

I am using ROS 2 Galactic on Ubuntu 20.04. I am trying to create a callback group using the tutorial on ROS2 documentation. I am getting this error

error: ‘options’ does not name a type

This is how I am defining my group:

rclcpp::CallbackGroup::SharedPtr my_callback_group = create_callback_group(rclcpp::CallbackGroupType::Reentrant);
rclcpp::SubscriptionOptions options;
options.callback_group = my_callback_group;

I have also tried:

auto my_callback_group = create_callback_group(rclcpp::CallbackGroupType::Reentrant);
rclcpp::SubscriptionOptions options;
options.callback_group = my_callback_group;

I still get the same error. Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2022-07-21 23:45:20 -0500

cjoshi17 gravatar image

I found out my problem, I was trying to define this options.callback_group = my_callback_group; after my variable declaration in my class declaration. When I added this in my constructor it worked for me. Thanks for you help

edit flag offensive delete link more
0

answered 2022-07-21 09:08:25 -0500

ljaniec gravatar image

Can you try with:

auto options = rclcpp::SubscriptionOptions();

?

edit flag offensive delete link more

Comments

1

You can add this changed code snippet in the separate answer or in the edit of the question for the future readers :)

ljaniec gravatar image ljaniec  ( 2022-07-22 03:52:41 -0500 )edit

I did that, thanks for suggesting it :)

cjoshi17 gravatar image cjoshi17  ( 2022-07-22 05:03:03 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-07-21 05:28:28 -0500

Seen: 544 times

Last updated: Jul 21 '22