SMACC2
Loading...
Searching...
No Matches
cl_lifecycle_node.cpp
Go to the documentation of this file.
1// Copyright 2021 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Pablo Inigo Blasco, Brett Aldrich
18 *
19 ******************************************************************************************************************/
22#include <string>
23
24namespace cl_lifecycle_node
25{
27: nodeName_(node_name), eventMonitor_(nullptr)
28{
29}
30
32
34{
35 // Create service clients
36 client_get_state_ = this->getNode()->create_client<lifecycle_msgs::srv::GetState>(
38 client_change_state_ = this->getNode()->create_client<lifecycle_msgs::srv::ChangeState>(
40}
41
43{
44 auto request = std::make_shared<lifecycle_msgs::srv::ChangeState::Request>();
45 request->transition.id = state;
46 auto future = client_change_state_->async_send_request(request);
47 future.wait();
48}
49
51{
52 changeState(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE);
53}
54
56{
57 changeState(lifecycle_msgs::msg::Transition::TRANSITION_DEACTIVATE);
58}
59
61{
62 changeState(lifecycle_msgs::msg::Transition::TRANSITION_CONFIGURE);
63}
64
66{
67 changeState(lifecycle_msgs::msg::Transition::TRANSITION_CLEANUP);
68}
69
71{
72 changeState(lifecycle_msgs::msg::Transition::TRANSITION_UNCONFIGURED_SHUTDOWN);
73}
74
75} // namespace cl_lifecycle_node
rclcpp::Client< lifecycle_msgs::srv::ChangeState >::SharedPtr client_change_state_
rclcpp::Client< lifecycle_msgs::srv::GetState >::SharedPtr client_get_state_
rclcpp::Node::SharedPtr getNode()
Definition client.cpp:60