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

#include <cp_costmap_switch.hpp>

Inheritance diagram for cl_nav2z::CpCostmapSwitch:
Inheritance graph
Collaboration diagram for cl_nav2z::CpCostmapSwitch:
Collaboration graph

Public Types

enum class  StandardLayers { GLOBAL_OBSTACLES_LAYER = 0 , LOCAL_OBSTACLES_LAYER = 1 , GLOBAL_INFLATED_LAYER = 2 , LOCAL_INFLATED_LAYER = 3 }
 

Public Member Functions

 CpCostmapSwitch ()
 
void onInitialize () override
 
bool exists (std::string layerName)
 
void enable (std::string layerName)
 
void enable (StandardLayers layerType)
 
void disable (std::string layerName)
 
void disable (StandardLayers layerType)
 
void registerProxyFromDynamicReconfigureServer (std::string costmapName, std::string enablePropertyName="enabled")
 
- Public Member Functions inherited from smacc2::ISmaccComponent
 ISmaccComponent ()
 
virtual ~ISmaccComponent ()
 
virtual std::string getName () const
 

Static Public Member Functions

static std::string getStandardCostmapName (StandardLayers layertype)
 

Static Public Attributes

static std::array< std::string, 4 > layerNames
 

Private Attributes

std::map< std::string, std::shared_ptr< CpCostmapProxy > > costmapProxies
 
cl_nav2z::ClNav2Znav2zClient_
 

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 41 of file cp_costmap_switch.hpp.

Member Enumeration Documentation

◆ StandardLayers

Enumerator
GLOBAL_OBSTACLES_LAYER 
LOCAL_OBSTACLES_LAYER 
GLOBAL_INFLATED_LAYER 
LOCAL_INFLATED_LAYER 

Definition at line 44 of file cp_costmap_switch.hpp.

Constructor & Destructor Documentation

◆ CpCostmapSwitch()

cl_nav2z::CpCostmapSwitch::CpCostmapSwitch ( )

Definition at line 34 of file cp_costmap_switch.cpp.

34{}

Member Function Documentation

◆ disable() [1/2]

void cl_nav2z::CpCostmapSwitch::disable ( StandardLayers  layerType)

Definition at line 111 of file cp_costmap_switch.cpp.

112{
113 this->disable(getStandardCostmapName(layerType));
114}
void disable(std::string layerName)
static std::string getStandardCostmapName(StandardLayers layertype)

References disable(), and getStandardCostmapName().

Here is the call graph for this function:

◆ disable() [2/2]

void cl_nav2z::CpCostmapSwitch::disable ( std::string  layerName)

Definition at line 93 of file cp_costmap_switch.cpp.

94{
95 RCLCPP_INFO(getLogger(), "[CpCostmapSwitch] disabling %s", layerName.c_str());
96
97 if (!exists(layerName))
98 {
99 RCLCPP_ERROR(getLogger(), "[CpCostmapSwitch] costmap %s does not exist", layerName.c_str());
100 return;
101 }
102 else
103 {
104 RCLCPP_INFO(
105 getLogger(), "[CpCostmapSwitch] costmap %s found. Calling dynamic reconfigure server.",
106 layerName.c_str());
107 costmapProxies[layerName]->setCostmapEnabled(false);
108 }
109}
std::map< std::string, std::shared_ptr< CpCostmapProxy > > costmapProxies
bool exists(std::string layerName)
rclcpp::Logger getLogger() const

References costmapProxies, exists(), and smacc2::ISmaccComponent::getLogger().

Referenced by disable().

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

◆ enable() [1/2]

void cl_nav2z::CpCostmapSwitch::enable ( StandardLayers  layerType)

Definition at line 88 of file cp_costmap_switch.cpp.

89{
90 this->enable(getStandardCostmapName(layerType));
91}
void enable(std::string layerName)

References enable(), and getStandardCostmapName().

Here is the call graph for this function:

◆ enable() [2/2]

void cl_nav2z::CpCostmapSwitch::enable ( std::string  layerName)

Definition at line 70 of file cp_costmap_switch.cpp.

71{
72 RCLCPP_INFO(getLogger(), "[CpCostmapSwitch] enabling %s", layerName.c_str());
73
74 if (!exists(layerName))
75 {
76 RCLCPP_ERROR(getLogger(), "[CpCostmapSwitch] costmap %s does not exist", layerName.c_str());
77 return;
78 }
79 else
80 {
81 RCLCPP_INFO(
82 getLogger(), "[CpCostmapSwitch] costmap %s found. Calling dynamic reconfigure server.",
83 layerName.c_str());
84 costmapProxies[layerName]->setCostmapEnabled(true);
85 }
86}

References costmapProxies, exists(), and smacc2::ISmaccComponent::getLogger().

Referenced by enable().

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

◆ exists()

bool cl_nav2z::CpCostmapSwitch::exists ( std::string  layerName)

Definition at line 60 of file cp_costmap_switch.cpp.

61{
62 if (!this->costmapProxies.count(layerName))
63 {
64 return false;
65 }
66
67 return true;
68}

References costmapProxies.

Referenced by disable(), and enable().

Here is the caller graph for this function:

◆ getStandardCostmapName()

std::string cl_nav2z::CpCostmapSwitch::getStandardCostmapName ( StandardLayers  layertype)
static

Definition at line 55 of file cp_costmap_switch.cpp.

56{
57 return CpCostmapSwitch::layerNames[(int)layertype];
58}
static std::array< std::string, 4 > layerNames

References layerNames.

Referenced by disable(), enable(), and onInitialize().

Here is the caller graph for this function:

◆ onInitialize()

void cl_nav2z::CpCostmapSwitch::onInitialize ( )
overridevirtual

Reimplemented from smacc2::ISmaccComponent.

Definition at line 36 of file cp_costmap_switch.cpp.

References smacc2::ISmaccComponent::getLogger(), getStandardCostmapName(), GLOBAL_INFLATED_LAYER, GLOBAL_OBSTACLES_LAYER, LOCAL_INFLATED_LAYER, LOCAL_OBSTACLES_LAYER, nav2zClient_, smacc2::ISmaccComponent::owner_, and registerProxyFromDynamicReconfigureServer().

Here is the call graph for this function:

◆ registerProxyFromDynamicReconfigureServer()

void cl_nav2z::CpCostmapSwitch::registerProxyFromDynamicReconfigureServer ( std::string  costmapName,
std::string  enablePropertyName = "enabled" 
)

Definition at line 25 of file cp_costmap_switch.cpp.

27{
28 RCLCPP_INFO(getLogger(), "[CpCostmapSwitch] registering costmap type: %s", costmapName.c_str());
29 auto proxy = std::make_shared<CpCostmapProxy>(
30 this->nav2zClient_->getName() + "/" + costmapName, enablePropertyName, getNode());
31 costmapProxies[costmapName] = proxy;
32}
rclcpp::Node::SharedPtr getNode()

References costmapProxies, smacc2::ISmaccComponent::getLogger(), smacc2::client_bases::ISmaccActionClient::getName(), smacc2::ISmaccComponent::getNode(), and nav2zClient_.

Referenced by onInitialize().

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

Member Data Documentation

◆ costmapProxies

std::map<std::string, std::shared_ptr<CpCostmapProxy> > cl_nav2z::CpCostmapSwitch::costmapProxies
private

◆ layerNames

std::array< std::string, 4 > cl_nav2z::CpCostmapSwitch::layerNames
static
Initial value:
= {
"global_costmap/obstacles_layer",
"local_costmap/obstacles_layer"
"global_costmap/inflater_layer",
"local_costmap/inflater_layer"}

Definition at line 52 of file cp_costmap_switch.hpp.

Referenced by getStandardCostmapName().

◆ nav2zClient_

cl_nav2z::ClNav2Z* cl_nav2z::CpCostmapSwitch::nav2zClient_
private

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