1 #include "header/coordInterfaceCoord.h" 3 CoordInterfaceCoord::CoordInterfaceCoord(ros::NodeHandle nh, std::string robotName){
5 this->robotName = robotName;
6 std::cout <<
"[COORDINATOR][COORD_INTERFACE_to_" << robotName <<
"] Start"<<std::endl;
9 std::string topicReady =
"/uwsim/" + robotName+
"_MissionManager" +
"/ready";
10 readyRobSub = nh.subscribe(topicReady, 1, &CoordInterfaceCoord::readyRobSubCallback,
this);
13 std::string topicCoordFromMM =
"/uwsim/" + robotName +
"_MissionManager/toCoord";
14 subCoordFromMM = nh.subscribe(topicCoordFromMM, 1, &CoordInterfaceCoord::subCoordFromMMCallBack,
this);
20 bool CoordInterfaceCoord::getReadyRob(){
21 return this->readyRob;
32 int CoordInterfaceCoord::getNonCoopCartVel(
33 Eigen::Matrix<double, VEHICLE_DOF, 1> *nonCoopCartVel_eigen){
36 int vectSize = tempXdot.size();
45 if (vectSize != VEHICLE_DOF){
46 std::cout <<
"[COORDINATOR][COORD_INTERFACE_to_" << robotName <<
"] ERROR:" 47 <<
"something wrong with dimension of xDot_tool received from " 48 << robotName << std::endl;
52 for (
int i=0; i<vectSize; i++){
53 (*nonCoopCartVel_eigen)(i,0) = tempXdot.at(i);
69 int CoordInterfaceCoord::getJJsharp(
70 Eigen::Matrix<double, VEHICLE_DOF, VEHICLE_DOF> *admisVelTool_eigen){
73 int nSize = tempJJsharp.size();
82 if (nSize != VEHICLE_DOF*VEHICLE_DOF){
83 std::cout <<
"[COORDINATOR][COORD_INTERFACE_to_" << robotName <<
"] ERROR:" 84 <<
"something wrong with dimension of JJ# received from " 85 << robotName << std::endl;
91 for (
int i=0; i<VEHICLE_DOF; i++){
92 for (
int j=0; j<VEHICLE_DOF; j++){
93 posRow = i*VEHICLE_DOF;
94 (*admisVelTool_eigen)(i,j) = tempJJsharp.at(posRow + j);
103 void CoordInterfaceCoord::readyRobSubCallback(
const std_msgs::Bool::ConstPtr& start){
104 readyRob = start->data;
116 void CoordInterfaceCoord::subCoordFromMMCallBack(
const peg_msgs::toCoord::ConstPtr& msg){
120 tempXdot.at(0) = msg->xDot.twist.linear.x;
121 tempXdot.at(1) = msg->xDot.twist.linear.y;
122 tempXdot.at(2) = msg->xDot.twist.linear.z;
123 tempXdot.at(3) = msg->xDot.twist.angular.x;
124 tempXdot.at(4) = msg->xDot.twist.angular.y;
125 tempXdot.at(5) = msg->xDot.twist.angular.z;
129 tempJJsharp.resize(msg->JJsharp.layout.dim[0].stride);
130 tempJJsharp = msg->JJsharp.data;