2 #include <tf/transform_listener.h> 3 #include "../header/publisher.h" 4 #include <eigen3/Eigen/Geometry> 7 typedef Eigen::Matrix<double, 3, 3> JacobianVehiclePose;
9 int main(
int argc,
char **argv)
11 ROS_INFO(
"[CONTROLLER] Start");
12 ros::init(argc, argv,
"controller");
15 std::string topicTwist =
"/uwsim/g500_A/twist_command_A";
16 ros::Publisher pubTwist = nh.advertise<geometry_msgs::TwistStamped>(topicTwist,1);
19 Publisher pubClassTwist(pubTwist);
20 geometry_msgs::TwistStamped twist;
21 twist.twist.linear.x=0;
22 twist.twist.linear.y=0;
23 twist.twist.linear.z=0;
24 twist.twist.angular.x=0;
25 twist.twist.angular.y=0;
26 twist.twist.angular.z=0;
29 tf::Vector3 goalPoint = tf::Vector3(-5.287, -0.062, 7.424);
31 tf::Transform goal = tf::Transform(tf::Matrix3x3(1, 0, 0, 0, 1, 0, 0, 0, 1), goalPoint);
33 tf::Vector3 yDot = tf::Vector3(0, 0, 0);
34 tf::Vector3 xDot = tf::Vector3(0, 0, 0);
37 tf::TransformListener tfListener;
38 tf::StampedTransform wTv;
41 tfListener.waitForTransform(
"world",
"/girona500_A", ros::Time(0), ros::Duration(3.0));
47 tfListener.lookupTransform(
"world",
"/girona500_A", ros::Time(0), wTv);
49 }
catch (tf::TransformException &ex) {
50 ROS_ERROR(
"%s",ex.what());
51 ros::Duration(1.0).sleep();
62 xDot = k * (goalPoint - wTv.getOrigin());
65 vect[0] = wTv.getBasis().getRow(0).getX();
66 vect[0] = wTv.getBasis().getRow(0).getY();
73 tf::Matrix3x3 jacobianVehiclePose = wTv.getBasis();
75 yDot = (jacobianVehiclePose.inverse() * xDot);
78 twist.twist.linear.x=yDot.getX();
79 twist.twist.linear.y=yDot.getY();
80 twist.twist.linear.z=yDot.getZ();
82 pubClassTwist.publish(twist);