SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
cl_nav2z::GoalCheckerSwitcher Class Reference

#include <goal_checker_switcher.hpp>

Inheritance diagram for cl_nav2z::GoalCheckerSwitcher:
Inheritance graph
Collaboration diagram for cl_nav2z::GoalCheckerSwitcher:
Collaboration graph

Public Member Functions

 GoalCheckerSwitcher (std::string goal_checker_selector_topic="goal_checker_selector", std::string default_goal_checker_name="goal_checker")
 
void onInitialize () override
 
virtual ~GoalCheckerSwitcher ()
 
void setDefaultGoalChecker ()
 
void setGoalCheckerId (std::string goal_checker_id)
 
- Public Member Functions inherited from smacc2::ISmaccComponent
 ISmaccComponent ()
 
virtual ~ISmaccComponent ()
 
virtual std::string getName () const
 

Private Attributes

std::string goal_checker_selector_topic_
 
std::string default_goal_checker_name_
 
rclcpp::Publisher< std_msgs::msg::String >::SharedPtr goal_checker_selector_pub_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccComponent
virtual void onInitialize ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename TComponent >
void requiresComponent (TComponent *&requiredComponentStorage, bool throwExceptionIfNotExist=false)
 
template<typename TComponent >
void requiresComponent (std::string name, TComponent *&requiredComponentStorage, bool throwExceptionIfNotExist=false)
 
template<typename TClient >
void requiresClient (TClient *&requiredClientStorage)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingNamedComponent (std::string name, TArgs... targs)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger () const
 
ISmaccStateMachinegetStateMachine ()
 
- Protected Attributes inherited from smacc2::ISmaccComponent
ISmaccStateMachinestateMachine_
 
ISmaccClientowner_
 

Detailed Description

Definition at line 31 of file goal_checker_switcher.hpp.

Constructor & Destructor Documentation

◆ GoalCheckerSwitcher()

cl_nav2z::GoalCheckerSwitcher::GoalCheckerSwitcher ( std::string  goal_checker_selector_topic = "goal_checker_selector",
std::string  default_goal_checker_name = "goal_checker" 
)

Definition at line 24 of file goal_checker_switcher.cpp.

26: goal_checker_selector_topic_(goal_checker_selector_topic),
27 default_goal_checker_name_(default_goal_checker_name)
28{
29}

◆ ~GoalCheckerSwitcher()

cl_nav2z::GoalCheckerSwitcher::~GoalCheckerSwitcher ( )
virtual

Definition at line 31 of file goal_checker_switcher.cpp.

31{}

Member Function Documentation

◆ onInitialize()

void cl_nav2z::GoalCheckerSwitcher::onInitialize ( )
overridevirtual

Reimplemented from smacc2::ISmaccComponent.

Definition at line 33 of file goal_checker_switcher.cpp.

34{
35 rclcpp::QoS qos(rclcpp::KeepLast(1));
36 qos.transient_local().reliable();
37
39 getNode()->create_publisher<std_msgs::msg::String>(goal_checker_selector_topic_, qos);
40}
rclcpp::Publisher< std_msgs::msg::String >::SharedPtr goal_checker_selector_pub_
rclcpp::Node::SharedPtr getNode()

References smacc2::ISmaccComponent::getNode(), goal_checker_selector_pub_, and goal_checker_selector_topic_.

Here is the call graph for this function:

◆ setDefaultGoalChecker()

void cl_nav2z::GoalCheckerSwitcher::setDefaultGoalChecker ( )

Definition at line 42 of file goal_checker_switcher.cpp.

43{
44 setGoalCheckerId(default_goal_checker_name_); // default id in navigation2 stack
45}
void setGoalCheckerId(std::string goal_checker_id)

References default_goal_checker_name_, and setGoalCheckerId().

Here is the call graph for this function:

◆ setGoalCheckerId()

void cl_nav2z::GoalCheckerSwitcher::setGoalCheckerId ( std::string  goal_checker_id)

Definition at line 47 of file goal_checker_switcher.cpp.

48{
49 RCLCPP_INFO_STREAM(getLogger(), "[GoalCheckerSwitcher] Setting goal checker: " << goalcheckerid);
50
51 // controller_server_node_->wait_for_service();
52 // std::vector<rclcpp::Parameter> params{ rclcpp::Parameter("current_goal_checker", goalcheckerid) };
53 // auto futureResults = controller_server_node_->set_parameters(params);
54
55 std_msgs::msg::String msg;
56 msg.data = goalcheckerid;
57 this->goal_checker_selector_pub_->publish(msg);
58
59 // int i = 0;
60 // for (auto& res : futureResults.get())
61 // {
62 // RCLCPP_INFO_STREAM(getLogger(), "[GoalCheckerSwitcher] parameter result: "
63 // << params[i].get_name() << "=" << params[i].as_string()
64 // << ". Result: " << res.successful);
65 // i++;
66
67 // if (!res.successful)
68 // RCLCPP_ERROR_STREAM(this->getLogger(), "[GoalCheckerSwitcher] goal checker could not properly
69 // switch "
70 // "the goal checker of the controller_server");
71 // }
72}
rclcpp::Logger getLogger() const

References smacc2::ISmaccComponent::getLogger(), and goal_checker_selector_pub_.

Referenced by cl_nav2z::CbAbsoluteRotate::onEntry(), cl_nav2z::CbNavigateBackwards::onEntry(), cl_nav2z::CbNavigateForward::onEntry(), cl_nav2z::CbNavigateGlobalPosition::onEntry(), cl_nav2z::CbUndoPathBackwards::onEntry(), and setDefaultGoalChecker().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ default_goal_checker_name_

std::string cl_nav2z::GoalCheckerSwitcher::default_goal_checker_name_
private

Definition at line 44 of file goal_checker_switcher.hpp.

Referenced by setDefaultGoalChecker().

◆ goal_checker_selector_pub_

rclcpp::Publisher<std_msgs::msg::String>::SharedPtr cl_nav2z::GoalCheckerSwitcher::goal_checker_selector_pub_
private

Definition at line 45 of file goal_checker_switcher.hpp.

Referenced by onInitialize(), and setGoalCheckerId().

◆ goal_checker_selector_topic_

std::string cl_nav2z::GoalCheckerSwitcher::goal_checker_selector_topic_
private

Definition at line 43 of file goal_checker_switcher.hpp.

Referenced by onInitialize().


The documentation for this class was generated from the following files: