[ROS2] calling method in Node class
Hi, I would like to create a node class that keeps calling a Service.
class GetObject : public rclcpp::Node
{
public:
GetObject() : Node("main")
{
auto getobj = this->create_client<canopen_msgs::srv::GetObject>("/get_object");
}
void Get()
{
// code that calls the Service
}
}
What is the correct way of calling the Get() method ? I would like to have following structure:
int main(int argc, char *argv[])
{
rclcpp::init(argc, argv);
auto GetConstructor = std::make_shared<GetObject>();
while (rclcpp::ok())
{
// call the Get() method
}
return 0;
}
Thanks !