1 #include "header/coordInterfaceMissMan.h" 5 this->robotName = robotName;
7 std::string topicRoot =
"/uwsim/" + robotName +
"_MissionManager/";
9 std::cout <<
"[" << robotName <<
"][COORD_INTERFACE] Start"<<std::endl;
11 pubToCoord = nh.advertise<peg_msgs::toCoord>((topicRoot +
"toCoord"), 1);
16 readyPub = nh.advertise<std_msgs::Bool>(topicRoot +
"ready", 1);
24 std::string topicStart =
"/uwsim/Coord/StartStopBoth";
25 startSub = nh.subscribe(topicStart, 1, &CoordInterfaceMissMan::startSubCallback,
this);
28 std::string topicCoopVel =
"/uwsim/Coord/CoopVel";
29 coopVelSub = nh.subscribe(topicCoopVel, 1, &CoordInterfaceMissMan::subMMFromCoordCallBack,
this);
35 toCoordMsg.JJsharp.layout.dim.push_back(std_msgs::MultiArrayDimension());
36 toCoordMsg.JJsharp.layout.dim.push_back(std_msgs::MultiArrayDimension());
37 toCoordMsg.JJsharp.layout.dim[0].label =
"row";
38 toCoordMsg.JJsharp.layout.dim[1].label =
"column";
39 toCoordMsg.JJsharp.layout.dim[0].size = VEHICLE_DOF;
40 toCoordMsg.JJsharp.layout.dim[1].size = VEHICLE_DOF;
41 toCoordMsg.JJsharp.layout.dim[0].stride = VEHICLE_DOF*VEHICLE_DOF;
42 toCoordMsg.JJsharp.layout.dim[1].stride = VEHICLE_DOF;
43 toCoordMsg.JJsharp.layout.data_offset = 0;
47 updateGoalArrived =
false;
48 subUpdatedGoal = nh.subscribe(
"/uwsim/Coord/updatedGoal", 1, &CoordInterfaceMissMan::subUpdatedGoalCallback,
this);
52 void CoordInterfaceMissMan::pubIamReadyOrNot(
bool ready){
53 std_msgs::Bool ready_msg;
54 ready_msg.data = ready;
55 readyPub.publish(ready_msg);
58 void CoordInterfaceMissMan::startSubCallback(
const std_msgs::Bool::ConstPtr& msg){
62 bool CoordInterfaceMissMan::getStartFromCoord(){
77 Eigen::Matrix<double, VEHICLE_DOF, VEHICLE_DOF> admisVelTool_eigen){
80 toCoordMsg.xDot.twist.linear.x = nonCoopCartVel_eigen(0);
81 toCoordMsg.xDot.twist.linear.y = nonCoopCartVel_eigen(1);
82 toCoordMsg.xDot.twist.linear.z = nonCoopCartVel_eigen(2);
83 toCoordMsg.xDot.twist.angular.x = nonCoopCartVel_eigen(3);
84 toCoordMsg.xDot.twist.angular.y = nonCoopCartVel_eigen(4);
85 toCoordMsg.xDot.twist.angular.z = nonCoopCartVel_eigen(5);
88 toCoordMsg.JJsharp.data.clear();
93 std::vector<double> temp(VEHICLE_DOF*VEHICLE_DOF, 0);
95 for (
int i=0; i<VEHICLE_DOF; i++){
96 for (
int j=0; j<VEHICLE_DOF; j++){
97 posRow = i*VEHICLE_DOF;
98 temp[posRow + j] = admisVelTool_eigen(i,j);
101 toCoordMsg.JJsharp.data = temp;
102 pubToCoord.publish(toCoordMsg);
108 int CoordInterfaceMissMan::getCoopCartVel(
109 Eigen::Matrix<double, VEHICLE_DOF, 1> *coopCartVel_eigen){
111 int vectSize = tempCoopVel.size();
120 if (vectSize != VEHICLE_DOF){
121 std::cout <<
"[" << robotName <<
"][COORD_INTERFACE] ERROR:" 122 <<
"something wrong with dimension of xDot_coopVel received from " 123 <<
"Coordinator" << std::endl;
127 for (
int i=0; i<vectSize; i++){
128 (*coopCartVel_eigen)(i,0) = tempCoopVel.at(i);
142 void CoordInterfaceMissMan::subMMFromCoordCallBack(
const geometry_msgs::TwistStamped& msg){
144 tempCoopVel.resize(6);
146 tempCoopVel.at(0) = msg.twist.linear.x;
147 tempCoopVel.at(1) = msg.twist.linear.y;
148 tempCoopVel.at(2) = msg.twist.linear.z;
149 tempCoopVel.at(3) = msg.twist.angular.x;
150 tempCoopVel.at(4) = msg.twist.angular.y;
151 tempCoopVel.at(5) = msg.twist.angular.z;
159 if (updateGoalArrived){
160 (*wTgoalTool_eigen)(0,3) = updatedPosLin.x;
161 (*wTgoalTool_eigen)(1,3) = updatedPosLin.y;
162 (*wTgoalTool_eigen)(2,3) = updatedPosLin.z;
165 (*wTgoalTool_eigen)(0,0) = updatedPosAng.at(0);
166 (*wTgoalTool_eigen)(1,0) = updatedPosAng.at(1);
167 (*wTgoalTool_eigen)(2,0) = updatedPosAng.at(2);
168 (*wTgoalTool_eigen)(0,1) = updatedPosAng.at(3);
169 (*wTgoalTool_eigen)(1,1) = updatedPosAng.at(4);
170 (*wTgoalTool_eigen)(2,1) = updatedPosAng.at(5);
171 (*wTgoalTool_eigen)(0,2) = updatedPosAng.at(6);
172 (*wTgoalTool_eigen)(1,2) = updatedPosAng.at(7);
173 (*wTgoalTool_eigen)(2,2) = updatedPosAng.at(8);
176 updateGoalArrived =
false;
184 void CoordInterfaceMissMan::subUpdatedGoalCallback(
const peg_msgs::transformMat::ConstPtr &msg){
185 updateGoalArrived =
true;
186 updatedPosLin = msg->linPosition.vector;
187 updatedPosAng.resize(9);
188 for (
int i = 0; i < 9; i++){
189 updatedPosAng.at(i) = msg->rotation[i].data;
int getUpdatedGoal(Eigen::Matrix4d *wTgoalTool_eigen)
change goal thingss
int publishToCoord(Eigen::Matrix< double, VEHICLE_DOF, 1 > nonCoopCartVel_eigen, Eigen::Matrix< double, VEHICLE_DOF, VEHICLE_DOF > admisVelTool_eigen)
CoordInterface::publishToCoord publish the necessary thing to the coordinator node.
CoordInterfaceMissMan(ros::NodeHandle nh, std::string robotName)