SMACC
Loading...
Searching...
No Matches
Public Member Functions | Static Private Member Functions | List of all members
cl_move_group_interface::CbMoveKnownState Class Reference

#include <cb_move_known_state.h>

Inheritance diagram for cl_move_group_interface::CbMoveKnownState:
Inheritance graph
Collaboration diagram for cl_move_group_interface::CbMoveKnownState:
Collaboration graph

Public Member Functions

 CbMoveKnownState (std::string pkg, std::string config_path)
 
virtual ~CbMoveKnownState ()
 
- Public Member Functions inherited from cl_move_group_interface::CbMoveJoints
 CbMoveJoints ()
 
 CbMoveJoints (const std::map< std::string, double > &jointValueTarget)
 
virtual void onEntry () override
 
virtual void onExit () override
 
- Public Member Functions inherited from smacc::SmaccAsyncClientBehavior
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
virtual ~SmaccAsyncClientBehavior ()
 
template<typename TCallback , typename T >
boost::signals2::connection onSuccess (TCallback callback, T *object)
 
template<typename TCallback , typename T >
boost::signals2::connection onFinished (TCallback callback, T *object)
 
template<typename TCallback , typename T >
boost::signals2::connection onFailure (TCallback callback, T *object)
 
- Public Member Functions inherited from smacc::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
ISmaccStateMachinegetStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage)
 
ros::NodeHandle getNode ()
 

Static Private Member Functions

static std::map< std::string, double > loadJointStatesFromFile (std::string pkg, std::string filepath)
 

Additional Inherited Members

- Public Attributes inherited from cl_move_group_interface::CbMoveJoints
boost::optional< double > scalingFactor_
 
std::map< std::string, double > jointValueTarget_
 
boost::optional< std::string > group_
 
- Protected Member Functions inherited from cl_move_group_interface::CbMoveJoints
void moveJoints (moveit::planning_interface::MoveGroupInterface &moveGroupInterface)
 
- Protected Member Functions inherited from smacc::SmaccAsyncClientBehavior
virtual void executeOnEntry () override
 
virtual void executeOnExit () override
 
void postSuccessEvent ()
 
void postFailureEvent ()
 
virtual void dispose () override
 
- Protected Member Functions inherited from smacc::ISmaccClientBehavior
virtual void runtimeConfigure ()
 
virtual void onEntry ()
 
virtual void onExit ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
ISmaccStategetCurrentState ()
 
virtual void executeOnEntry ()
 
virtual void executeOnExit ()
 
virtual void dispose ()
 
- Protected Attributes inherited from cl_move_group_interface::CbMoveJoints
ClMoveGroupmovegroupClient_
 

Detailed Description

Definition at line 15 of file cb_move_known_state.h.

Constructor & Destructor Documentation

◆ CbMoveKnownState()

cl_move_group_interface::CbMoveKnownState::CbMoveKnownState ( std::string  pkg,
std::string  config_path 
)

Definition at line 15 of file cb_move_known_state.cpp.

16 : CbMoveJoints(loadJointStatesFromFile(pkg, config_path))
17{
18}
static std::map< std::string, double > loadJointStatesFromFile(std::string pkg, std::string filepath)

◆ ~CbMoveKnownState()

cl_move_group_interface::CbMoveKnownState::~CbMoveKnownState ( )
virtual

Definition at line 20 of file cb_move_known_state.cpp.

21{
22
23}

Member Function Documentation

◆ loadJointStatesFromFile()

std::map< std::string, double > cl_move_group_interface::CbMoveKnownState::loadJointStatesFromFile ( std::string  pkg,
std::string  filepath 
)
staticprivate

Definition at line 27 of file cb_move_known_state.cpp.

28{
29 auto pkgpath = ros::package::getPath(pkg);
30 std::map<std::string, double> jointStates;
31
32 if(pkgpath == "")
33 {
34 ROS_ERROR_STREAM("[CbMoveKnownState] package not found for the known poses file: " << pkg << std::endl << " [IGNORING BEHAVIOR]");
35 return jointStates;
36 }
37
38 filepath = pkgpath +"/" + filepath;
39
40
41 ROS_INFO("[CbMoveKnownState] Opening file with joint known state: %s", filepath.c_str());
42
43
44 if(std::experimental::filesystem::exists(filepath))
45 {
46 ROS_INFO_STREAM("[CbMoveKnownState] known state file exists: " << filepath);
47 }
48 else
49 {
50 ROS_ERROR_STREAM("[CbMoveKnownState] known state file does not exists: " << filepath);
51 }
52
53 std::ifstream ifs(filepath.c_str(), std::ifstream::in);
54 if (ifs.good() == false)
55 {
56 ROS_ERROR("[CbMoveKnownState] Error opening file with joint known states: %s", filepath.c_str());
57 throw std::string("joint state files not found");
58 }
59
60 try
61 {
62#ifdef HAVE_NEW_YAMLCPP
63 YAML::Node node = YAML::Load(ifs);
64#else
65 YAML::Parser parser(ifs);
66 parser.GetNextDocument(node);
67#endif
68
69#ifdef HAVE_NEW_YAMLCPP
70 const YAML::Node &wp_node_tmp = node["joint_states"];
71 const YAML::Node *wp_node = wp_node_tmp ? &wp_node_tmp : NULL;
72#else
73 const YAML::Node *wp_node = node.FindValue("waypoints");
74#endif
75
76 if (wp_node != NULL)
77 {
78 try
79 {
80 for(YAML::const_iterator it=wp_node->begin();it != wp_node->end();++it)
81 {
82 std::string key = it->first.as<std::string>();
83 double value = it->second.as<double>();
84 ROS_DEBUG_STREAM(" joint - " << key << ": " << value);
85 jointStates[key] = value;
86 }
87
88 return jointStates;
89 }
90 catch(std::exception& ex)
91 {
92 ROS_ERROR("trying to convert to map, failed, errormsg: %s", ex.what());
93 }
94
95 ROS_INFO_STREAM("Parsed " << jointStates.size() << " joint entries.");
96 }
97 else
98 {
99 ROS_WARN_STREAM("Couldn't find any jointStates in the provided yaml file.");
100 }
101 }
102 catch (const YAML::ParserException &ex)
103 {
104 ROS_ERROR_STREAM("Error loading the Waypoints YAML file. Incorrect syntax: " << ex.what());
105 }
106 return jointStates;
107}

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