35 #include <Eigen/Dense>
42 #include <graft/GraftState.h>
60 geometry_msgs::TransformStamped
tf;
61 tf.header.stamp = msg.header.stamp;
62 tf.header.frame_id = msg.header.frame_id;
63 tf.child_frame_id = msg.child_frame_id;
65 tf.transform.translation.x = msg.pose.pose.position.x;
66 tf.transform.translation.y = msg.pose.pose.position.y;
67 tf.transform.translation.z = msg.pose.pose.position.z;
68 tf.transform.rotation = msg.pose.pose.orientation;
83 odom_.twist.twist.linear.x = state.twist.linear.x;
84 odom_.twist.twist.linear.y = state.twist.linear.y;
85 odom_.twist.twist.angular.z = state.twist.angular.z;
88 double diff = pow(
odom_.pose.pose.orientation.w, 2.0)-pow(
odom_.pose.pose.orientation.z, 2.0);
89 double mult = 2.0*
odom_.pose.pose.orientation.w*
odom_.pose.pose.orientation.z;
90 double theta = atan2(mult, diff);
91 if(std::abs(
odom_.twist.twist.angular.z) < 0.00001){
92 odom_.pose.pose.position.x +=
odom_.twist.twist.linear.x*dt*cos(theta)-
odom_.twist.twist.linear.y*dt*sin(theta);
93 odom_.pose.pose.position.y +=
odom_.twist.twist.linear.x*dt*sin(theta)+
odom_.twist.twist.linear.y*dt*cos(theta);
95 double curvature_x =
odom_.twist.twist.linear.x/
odom_.twist.twist.angular.z;
96 double curvature_y =
odom_.twist.twist.linear.y/
odom_.twist.twist.angular.z;
97 double new_theta = theta +
odom_.twist.twist.angular.z*dt;
99 odom_.pose.pose.position.x += -curvature_x*sin(theta) + curvature_x*sin(new_theta);
100 odom_.pose.pose.position.x += -curvature_y*cos(theta) + curvature_y*cos(new_theta);
101 odom_.pose.pose.position.y += curvature_x*cos(theta) - curvature_x*cos(new_theta);
102 odom_.pose.pose.position.y += -curvature_y*sin(theta) + curvature_y*sin(new_theta);
105 odom_.pose.pose.orientation.z = sin(theta/2.0);
106 odom_.pose.pose.orientation.w = cos(theta/2.0);
113 int main(
int argc,
char **argv)
115 ros::init(argc, argv,
"graft_ukf_velocity");
122 std::vector<boost::shared_ptr<GraftSensor> > topics;
123 std::vector<ros::Subscriber> subs;
142 odom_.pose.pose.position.x = 0.0;
143 odom_.pose.pose.position.y = 0.0;
144 odom_.pose.pose.position.z = 0.0;
146 odom_.pose.pose.orientation.w = 1.0;
147 odom_.pose.pose.orientation.x = 0.0;
148 odom_.pose.pose.orientation.y = 0.0;
149 odom_.pose.pose.orientation.z = 0.0;
151 odom_.twist.twist.linear.x = 0.0;
152 odom_.twist.twist.linear.y = 0.0;
153 odom_.twist.twist.linear.z = 0.0;
154 odom_.twist.twist.angular.x = 0.0;
155 odom_.twist.twist.angular.y = 0.0;
156 odom_.twist.twist.angular.z = 0.0;