Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "Neighbor.hpp"
00009
00010 #include <boost/lexical_cast.hpp>
00011
00012 #include <telekyb_interface/TeleKybCore.hpp>
00013
00014 namespace telekyb_behavior {
00015
00016 Neighbor::Neighbor(int robotID_)
00017 : robotID(robotID_), receivedOnceVar(false), initDoneVar(false), formationConditionDoneVar(false)
00018 {
00019 if (!telekyb_interface::TeleKybCore::getTeleKybCoreMainNodeHandle(robotID, nodeHandle)) {
00020 ROS_ERROR("Unable to get NodeHandle for TeleKybCore %d", robotID);
00021 return;
00022 }
00023
00024
00025 vpSub = nodeHandle.subscribe<geometry_msgs::PointStamped>(
00026 VP_TOPIC,1, &Neighbor::neighborVPCallback, this);
00027
00028 initDoneSub = nodeHandle.subscribe<std_msgs::Bool>(
00029 INITDONE_TOPIC,1, &Neighbor::neighborInitDone, this);
00030
00031 formationConditionDoneSub = nodeHandle.subscribe<std_msgs::Bool>(
00032 CONDITIONDONE_TOPIC,1, &Neighbor::neighborFormationConditionDone, this);
00033 }
00034
00035 Neighbor::~Neighbor() {
00036
00037 }
00038
00039
00040 void Neighbor::neighborVPCallback(const geometry_msgs::PointStamped::ConstPtr& stateMsg)
00041 {
00042 messageTimer.reset();
00043
00044
00045 virtualPoint = Position3D(stateMsg->point.x,stateMsg->point.y,stateMsg->point.z);
00046
00047
00048 receivedOnceVar = true;
00049 }
00050
00051 void Neighbor::neighborInitDone(const std_msgs::Bool::ConstPtr& msg)
00052 {
00053 initDoneVar = (bool)msg->data;
00054 }
00055
00056 void Neighbor::neighborFormationConditionDone(const std_msgs::Bool::ConstPtr& msg)
00057 {
00058 formationConditionDoneVar = (bool)msg->data;
00059 }
00060
00061
00062 Position3D Neighbor::getVirtualPoint() const
00063 {
00064 return virtualPoint;
00065 }
00066
00067 bool Neighbor::receivedOnce() const
00068 {
00069 return receivedOnceVar;
00070 }
00071
00072 bool Neighbor::formationConditionDone() const
00073 {
00074 return formationConditionDoneVar;
00075 }
00076
00077 bool Neighbor::initDone() const
00078 {
00079 return initDoneVar;
00080 }
00081
00082 Time Neighbor::getElapsedMessageTime() const
00083 {
00084 return messageTimer.getElapsed();
00085 }
00086
00087 }