1 #include "header/missionManager.h" 15 int main(
int argc,
char **argv)
18 std::cout <<
"[MAIN] Please insert the two robots name"<< std::endl;
23 missionManagerA.execute();
54 ros::init(argc, argv, robotName +
"_MissionManager");
55 std::cout <<
"[" << robotName <<
"][MISSION_MANAGER] Start" << std::endl;
57 if (LOG && (argc > 3)){
65 MissionManager::~MissionManager(){clearTaskList();}
84 boost::asio::io_service io;
99 void MissionManager::setGoals(){
102 double goalLinearVect[] = {-0.287, -0.062, 7.424};
103 Eigen::Matrix4d wTgoalVeh_eigen = Eigen::Matrix4d::Identity();
105 wTgoalVeh_eigen.topLeftCorner(3,3) = Eigen::Matrix3d::Identity();
107 wTgoalVeh_eigen(0, 3) = goalLinearVect[0];
108 wTgoalVeh_eigen(1, 3) = goalLinearVect[1];
109 wTgoalVeh_eigen(2, 3) = goalLinearVect[2];
112 double goalLinearVectEE[] = {-0.27, -0.102, 2.124};
113 Eigen::Matrix4d wTgoalEE_eigen = Eigen::Matrix4d::Identity();
115 wTgoalEE_eigen.topLeftCorner(3,3) = Eigen::Matrix3d::Identity();
120 wTgoalEE_eigen(0, 3) = goalLinearVectEE[0];
121 wTgoalEE_eigen(1, 3) = goalLinearVectEE[1];
122 wTgoalEE_eigen(2, 3) = goalLinearVectEE[2];
125 double goalLinearVectTool[] = {-0.27, -0.102, 2.124};
127 Eigen::Matrix4d wTgoalTool_eigen = Eigen::Matrix4d::Identity();
129 wTgoalTool_eigen.topLeftCorner(3,3) = Eigen::Matrix3d::Identity();
132 wTgoalTool_eigen(0, 3) = goalLinearVectTool[0];
133 wTgoalTool_eigen(1, 3) = goalLinearVectTool[1];
134 wTgoalTool_eigen(2, 3) = goalLinearVectTool[2];
138 robInfo.transforms.wTgoalVeh_eigen = wTgoalVeh_eigen;
139 robInfo.transforms.wTgoalEE_eigen = wTgoalEE_eigen;
140 robInfo.transforms.wTgoalTool_eigen = wTgoalTool_eigen;
144 void MissionManager::initrobotInterface(){
146 robotInterface(argc, argv,
"pipe");
147 robotInterface.init();
150 void MissionManager::initKdlHelper(){
152 std::string filename =
"/home/tori/UWsim/Peg/model/g500ARM5.urdf";
153 std::string vehicle =
"base_link";
154 std::string link0 =
"part0";
155 std::string endEffector =
"end_effector";
156 kdlHelper(filename, link0, endEffector);
162 kdlHelper.
getFixedFrame(vehicle, link0, &(robInfo.robotStruct.vTlink0));
165 void MissionManager::setInitialState(){
167 robotInterface.getJointState(&(robInfo.robotState.jState));
168 robotInterface.getwTv(&(robInfo.robotState.
wTv_eigen));
169 robotInterface.getwTt(&(robInfo.transforms.wTt_eigen));
170 robotInterface.getOtherRobPos(&(robInfo.exchangedInfo.otherRobPos));
172 kdlHelper.getEEpose(robInfo.robotState.jState, &(robInfo.robotState.link0Tee_eigen));
174 robInfo.robotState.vTee_eigen = robInfo.robotStruct.vTlink0 * robInfo.robotState.link0Tee_eigen;
178 computeWholeJacobian(&robInfo, ee);
181 void MissionManager::setKdl4Tool(){
182 Eigen::Matrix4d eeTtool =
183 FRM::invertTransf(robInfo.robotState.
wTv_eigen*robInfo.robotState.vTee_eigen)
184 * robInfo.transforms.wTt_eigen;
186 kdlHelper.
getJacobianTool(robInfo.robotState.jState, &(robInfo.robotState.link0_Jtool_man));
187 computeWholeJacobian(&robInfo, tool);
190 void MissionManager::initController(){
191 controller(robotName);
192 setTaskListInit(&tasks, robotName);
193 controller.setTaskList(tasks);
197 void MissionManager::ControlLoop(boost::asio::io_service io,
double ms){
201 boost::asio::deadline_timer loopRater(io, boost::posix_time::milliseconds(ms));
204 robotInterface.getJointState(&(robInfo.robotState.jState));
205 robotInterface.getwTv(&(robInfo.robotState.
wTv_eigen));
206 robotInterface.getwTt(&(robInfo.transforms.wTt_eigen));
207 robotInterface.getOtherRobPos(&(robInfo.exchangedInfo.otherRobPos));
210 kdlHelper.getEEpose(robInfo.robotState.jState, &(robInfo.robotState.link0Tee_eigen));
212 robInfo.robotState.vTee_eigen = robInfo.robotStruct.vTlink0 * robInfo.robotState.link0Tee_eigen;
215 computeWholeJacobian(&robInfo, ee);
217 kdlHelper.
getJacobianTool(robInfo.robotState.jState, &(robInfo.robotState.link0_Jtool_man));
218 computeWholeJacobian(&robInfo, tool);
222 controller.updateTransforms(&robInfo);
227 robotInterface.sendyDot(yDot);
228 robotInterface.spinOnce();
254 void MissionManager::setTaskListInit(){
260 bool ineqType =
false;
278 tasks->push_back(
new LastTask(TOT_DOF, eqType, robotName));
289 void MissionManager::clearTaskList(){
290 for (std::vector< Task* >::iterator it = tasks.begin() ; it != tasks.end(); ++it)
298 void MissionManager::createLogFolders(){
301 if (pathLog.size() != 0){
303 for (
int i =0; i< tasks.size(); ++i){
304 PRT::createDirectory(pathLog +
"/" +tasks[i]->getName());
306 std::cout <<
"[" << robotName
307 <<
"][MISSION_MANAGER] Created Log Folders in " 308 << pathLog << std::endl;
int getJacobianEE(std::vector< double > jointPos, Eigen::Matrix< double, 6, ARM_DOF > *jacobianEE_eigen)
KDLHelper::getJacobianEE respect base frame of arm (link0)
int getFixedFrame(std::string frameOrigin, std::string frameTarget, Eigen::Matrix4d *xTx_eigen)
KDLHelper::getFixedFrame get relative position of things inside the urdf file of the robot that NOT c...
std::vector< double > execAlgorithm(std::vector< Task * > tasks)
Controller::execAlgorithm this function calls the step of the algorithm modifying (in the for) each t...
int setToolSolvers(Eigen::Matrix4d eeTtool_eigen)
KDLHelper::setToolSolvers.
"Fake" Task needed as last to algorithm, it has all fixed matrices of eye and zeros so no setxx are n...
The ObstacleAvoidEETask class Usage of this task can be for avoiding with the end effector...
int getJacobianTool(std::vector< double > jointPos, Eigen::Matrix< double, 6, ARM_DOF > *jacobianTool_eigen)
KDLHelper::getJacobianTool respect base frame of arm (link0)
MissionManager(int argc, char **argv)
DEBUG.
Task to make the end effector reach a goal (both linear and angular position)
The ObstacleAvoidVehicleTask class (where the obstacle is the other vehicle, at the moment only for t...
Eigen::Matrix< double, 6, ARM_DOF > link0_Jee_man
Jacobians.
Eigen::Matrix4d wTv_eigen
Transforms.
int setEESolvers()
KDLHelper::setEESolvers Initialize the kinematic solvers (jacob and pose) for the arm End Effector...