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

MrCheesecake's profile - activity

2023-04-30 16:51:50 -0500 marked best answer How to call spin_some or spin_until_future_complete in member functions

Hi together,

my coding style of ROS2 is to put all stuff into an object and member functions. Now I wonder how to use spin_some or spin_until_future_complete inside a member function of my object? I tried with this, but that doesn't work.

Here is how I create the object:

int main(int argc, char * argv[])
{
  rclcpp::init(argc, argv);
  rclcpp::spin(std::make_shared<myNode>());
  rclcpp::shutdown();
  return 0;
}

Example for a service call I want to make:

auto request = std::make_shared<std_srvs::srv::SetBool::Request>();
request->data = true;

auto result = client_->async_send_request(request);
 if (rclcpp::spin_until_future_complete(this, result) != rclcpp::executor::FutureReturnCode::SUCCESS)
{
  RCLCPP_ERROR(this->get_logger(), "Failed");
}
2023-04-30 16:51:50 -0500 received badge  Guru (source)
2023-04-30 16:51:50 -0500 received badge  Enlightened (source)
2022-10-11 13:10:51 -0500 received badge  Great Answer (source)
2022-10-11 13:10:50 -0500 received badge  Good Question (source)
2022-04-04 07:36:36 -0500 received badge  Famous Question (source)
2022-04-04 07:36:36 -0500 received badge  Popular Question (source)
2022-04-04 07:36:36 -0500 received badge  Notable Question (source)
2022-03-03 06:00:21 -0500 received badge  Nice Question (source)
2021-12-22 03:17:32 -0500 received badge  Good Answer (source)
2021-12-05 01:12:11 -0500 received badge  Nice Answer (source)
2021-08-07 00:43:05 -0500 received badge  Popular Question (source)
2021-08-07 00:43:05 -0500 received badge  Notable Question (source)
2021-07-18 17:25:57 -0500 received badge  Self-Learner (source)
2021-07-06 02:06:50 -0500 received badge  Famous Question (source)
2021-05-11 15:22:34 -0500 received badge  Necromancer (source)
2021-05-05 13:05:55 -0500 received badge  Necromancer (source)
2021-01-10 23:35:31 -0500 received badge  Taxonomist
2021-01-05 02:24:15 -0500 received badge  Notable Question (source)
2020-12-23 10:02:18 -0500 received badge  Famous Question (source)
2020-12-16 19:46:22 -0500 received badge  Notable Question (source)
2020-10-28 17:42:52 -0500 received badge  Nice Question (source)
2020-09-24 07:12:30 -0500 received badge  Student (source)
2020-09-21 01:41:34 -0500 received badge  Notable Question (source)
2020-08-29 09:24:03 -0500 received badge  Famous Question (source)
2020-08-19 09:51:18 -0500 received badge  Notable Question (source)
2020-07-23 06:27:46 -0500 received badge  Popular Question (source)
2020-07-20 13:56:15 -0500 received badge  Popular Question (source)
2020-07-20 08:34:56 -0500 asked a question How to create a ROS2 library

How to create a ROS2 library Hey together, I'm building some nodes and want to add a general logging function into my c

2020-07-16 11:48:27 -0500 commented answer [ROS2] How to implement a sync service client in a node?

I also did tests on eloquent and foxy now, but the results have been more bad. But I found a fix which works for me. Th

2020-07-16 09:40:34 -0500 answered a question How to pass constants using a .idl file directly ?

Have a look under Constants of this link https://mhanckow.students.wmi.amu.edu.pl/corba/IDL.html#281057 I think you hav

2020-07-16 08:44:40 -0500 commented answer [ROS2] How to implement a sync service client in a node?

I tried your code and also modified my code in this way. 25-90% of the service calls from a node or the command line too

2020-07-16 07:57:08 -0500 received badge  Popular Question (source)
2020-07-15 07:54:15 -0500 commented answer No stdout logging output in ROS2 using launch

Does this work with Dashing or only newer versions? I'm getting: [ERROR] [launch]: Caught exception in launch (see debu

2020-07-15 06:54:56 -0500 commented answer ROS2 add parameter to c++ and launch file

Thanks from my side too! Is there a way I can change the parameters and use it without building the package again? Afai

2020-07-02 08:16:17 -0500 asked a question Receive DSS from RTI Connext in standard ROS2 (eProsima Fast-RTPS)

Receive DSS from RTI Connext in standard ROS2 (eProsima Fast-RTPS) Hi together, I have a program which uses RTI Connext

2020-07-02 08:14:07 -0500 asked a question Receive RTI Connext DDS data using default ROS2 DDS implementation

Receive RTI Connext DDS data using default ROS2 DDS implementation Hi together, I have a program which uses RTI Connext

2020-06-10 08:40:32 -0500 commented answer [ROS2] How to implement a sync service client in a node?

Unfortunately I'm using C++. But i assume, that the trick is to use MultiThreadedExecutor and CallbackGroups right? Ot

2020-06-10 07:13:28 -0500 commented question [ROS2] How to implement a sync service client in a node?

@jdlangs thanks for your answer, do you have a example or explanation on how to use callbackgroups. There is not much ab

2020-06-08 14:13:35 -0500 received badge  Popular Question (source)
2020-06-05 10:56:59 -0500 commented answer How to change ROS2 node's topic in runtime?

It's possible as I described. Just create a new subscription/publisher and replace the old one by it.

2020-06-05 10:30:14 -0500 received badge  Rapid Responder (source)
2020-06-05 10:30:14 -0500 answered a question How to change ROS2 node's topic in runtime?

Do you want to change it multiple times in runtime or only at startup? If at startup dynamically without compiling, I wo

2020-06-05 10:11:55 -0500 commented answer How to include a launch file from another node into a current project

You are welcome!

2020-06-05 10:10:22 -0500 commented question Ctrl+C can't kill the ros2 run

Can you stop the execution with strg+c when you start only one node directly? If not you have maybe some blocking code o

2020-06-05 10:08:25 -0500 received badge  Teacher (source)
2020-06-05 10:03:02 -0500 edited answer How to include a launch file from another node into a current project

Your include command looks fine, here is an example of a launch file that works for me: node_master.launch: <launch&

2020-06-05 10:01:23 -0500 received badge  Rapid Responder (source)
2020-06-05 10:01:23 -0500 answered a question How to include a launch file from another node into a current project

Your include command looks fine, here is an example of a launch file that works for me: node_master.launch: <laun