Go to the documentation of this file.00001 #include "robodyn_controllers/BaseFrameDetector.h"
00002 #include <iostream>
00003
00004 BaseFrameDetector::BaseFrameDetector()
00005 {
00006 }
00007
00008 BaseFrameDetector::~BaseFrameDetector()
00009 {
00010 }
00011
00012 int BaseFrameDetector::PopulateEEFStateInfo(const r2_msgs::GripperPositionState& eefState)
00013 {
00014 unsigned int neef = eefState.name.size();
00015
00016 if (neef != eefState.locked.size() || neef != eefState.loaded.size())
00017 {
00018 return -1;
00019 }
00020
00021
00022 for (unsigned int i = 0; i < neef; i++)
00023 {
00024 endEffectorMap[eefState.name[i]].locked = eefState.locked[i];
00025 endEffectorMap[eefState.name[i]].loaded = eefState.loaded[i];
00026 }
00027
00028 return 0;
00029
00030 }
00031
00032 int BaseFrameDetector::PopulateBaseVerifInfo(const r2_msgs::GripperPositionState& baseVerif)
00033 {
00034 unsigned int neef = baseVerif.name.size();
00035
00036 if (neef != baseVerif.verified.size())
00037 {
00038 return -1;
00039 }
00040
00041
00042 for (unsigned int i = 0; i < neef; i++)
00043 {
00044 endEffectorMap[baseVerif.name[i]].verified = baseVerif.verified[i];
00045 }
00046
00047 return 0;
00048
00049 }
00050
00051 void BaseFrameDetector::PopulateBaseFrameMsg(const std::string& baseFrameCmd, r2_msgs::StringArray& baseList)
00052 {
00053
00054 baseList.header.stamp = ros::Time::now();
00055 bfList.clear();
00056
00057
00058 std::map<std::string, EndEffectorData>::const_iterator it = endEffectorMap.begin();
00059
00060 while (it != endEffectorMap.end())
00061 {
00062
00063 std::string bfName = GripperToBaseFrame(it->first);
00064
00065
00066 if (it->second.locked == 1 && it->second.verified == 1 && bfName != it->first)
00067 {
00068 bfList.push_back(bfName);
00069 }
00070
00071 it++;
00072 }
00073
00074
00075 if (!baseFrameCmd.empty())
00076 {
00077 if (bfList.empty() && endEffectorMap.find(BaseFrameToGripper(baseFrameCmd)) == endEffectorMap.end())
00078 {
00079
00080 if (baseList.data.empty())
00081 {
00082 baseList.data.push_back(baseFrameCmd);
00083 }
00084 }
00085 }
00086
00087
00088 std::vector<std::string>::iterator itv = std::find(bfList.begin(), bfList.end(), baseFrameCmd);
00089
00090 if (itv != bfList.end())
00091 {
00092 baseList.data.push_back(baseFrameCmd);
00093 bfList.erase(itv);
00094 }
00095
00097
00098
00099 for (unsigned int i = 0; i < bfList.size(); i++)
00100 {
00101 baseList.data.push_back(bfList[i]);
00102 }
00103
00104 return;
00105 }
00106
00107