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

#include <cp_goal_checker_switcher.hpp>

Inheritance diagram for cl_nav2z::CpGoalCheckerSwitcher:
Inheritance graph
Collaboration diagram for cl_nav2z::CpGoalCheckerSwitcher:
Collaboration graph

Public Member Functions

 CpGoalCheckerSwitcher (std::string goal_checker_selector_topic="goal_checker_selector", std::string default_goal_checker_name="goal_checker")
 
void onInitialize () override
 
virtual ~CpGoalCheckerSwitcher ()
 
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
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>
SmaccComponentTypecreateSiblingComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentTypecreateSiblingNamedComponent (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 cp_goal_checker_switcher.hpp.

Constructor & Destructor Documentation

◆ CpGoalCheckerSwitcher()

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

Definition at line 24 of file cp_goal_checker_switcher.cpp.

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

◆ ~CpGoalCheckerSwitcher()

cl_nav2z::CpGoalCheckerSwitcher::~CpGoalCheckerSwitcher ( )
virtual

Definition at line 31 of file cp_goal_checker_switcher.cpp.

31{}

Member Function Documentation

◆ onInitialize()

void cl_nav2z::CpGoalCheckerSwitcher::onInitialize ( )
overridevirtual

Reimplemented from smacc2::ISmaccComponent.

Definition at line 33 of file cp_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::CpGoalCheckerSwitcher::setDefaultGoalChecker ( )

Definition at line 42 of file cp_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::CpGoalCheckerSwitcher::setGoalCheckerId ( std::string  goal_checker_id)

Definition at line 47 of file cp_goal_checker_switcher.cpp.

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

Definition at line 44 of file cp_goal_checker_switcher.hpp.

Referenced by setDefaultGoalChecker().

◆ goal_checker_selector_pub_

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

Definition at line 45 of file cp_goal_checker_switcher.hpp.

Referenced by onInitialize(), and setGoalCheckerId().

◆ goal_checker_selector_topic_

std::string cl_nav2z::CpGoalCheckerSwitcher::goal_checker_selector_topic_
private

Definition at line 43 of file cp_goal_checker_switcher.hpp.

Referenced by onInitialize().


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