@@ -98,7 +98,7 @@ void Kinematics::setPose(const std::string& source_frame, const ros::Time& updat
9898
9999 if (source_frame == frame_id_)
100100 {
101- setPosition (p.position , debug);
101+ setPosition (update_time, p.position , debug);
102102 setAttitude (p.orientation );
103103 ROS_DEBUG_STREAM_COND (debug_ && publisher_, " XXXXXXXX SAME FRAME = \n " << p);
104104 }
@@ -115,7 +115,7 @@ void Kinematics::setPose(const std::string& source_frame, const ros::Time& updat
115115 cur_pt.header .stamp = update_time;
116116 // transform point
117117 tf2::doTransform (cur_pt, ts_pt, ts);
118- setPosition (ts_pt.pose .position , debug);
118+ setPosition (update_time, ts_pt.pose .position , debug);
119119 setAttitude (ts_pt.pose .orientation );
120120 ROS_DEBUG_STREAM_COND (debug_ && publisher_, " XXXXXXXX FROM POINT = \n " << cur_pt);
121121 ROS_DEBUG_STREAM_COND (debug_ && publisher_, " XXXXXXXX TRANSFORM = \n " << ts);
@@ -164,23 +164,15 @@ bool Kinematics::getPoseStamped(std::string& target_frame_id, geometry_msgs::Po
164164 return true ;
165165}
166166
167- void Kinematics::setPosition (const geometry_msgs::Point& p, int debug) {
168- checkPosition (p.x , p.y , p.z , debug);
169- position_.x = p.x ;
170- position_.y = p.y ;
171- position_.z = p.z ;
172- }
173-
174- void Kinematics::setPosition (const AM::Point& p, int debug) {
175- checkPosition (p.x , p.y , p.z , debug);
176- position_ = p;
177- }
178-
179- void Kinematics::setPosition (double x, double y, double z, int debug) {
167+ void Kinematics::setPosition (const ros::Time& update_time, double x, double y, double z, int debug) {
180168 checkPosition (x, y, z, debug);
181169 position_.x = x;
182170 position_.y = y;
183171 position_.z = z;
172+
173+ // SSS Calculate speed
174+
175+ update_time_ = update_time;
184176}
185177
186178#define MAX_POS_ERR 1.0
@@ -226,6 +218,10 @@ void Kinematics::setOrientation(double w, double x, double y, double z) {
226218 attitude_.throttle = 0 ;
227219}
228220
221+ void Kinematics::updateVelocity (double x, double y, double z, double t,
222+ int debug) {
223+ }
224+
229225void Kinematics::setVelocity (const geometry_msgs::Vector3& linear,
230226 const geometry_msgs::Vector3& angular) {
231227 setLinearVelocity (linear);
@@ -435,12 +431,11 @@ void Kinematics::sendKinematics() {
435431void Kinematics::updateCB (const nav_msgs::Odometry::ConstPtr& msg) {
436432 // LOG_MSG(topic_+"-R", msg, 2); // TODO (dan) bag_logger
437433 setUpdated (true );
438- // setPose(msg->child_frame_id, msg->header.stamp, msg->pose.pose);
439- setPosition (msg->pose .pose .position );
434+ setPosition (msg->header .stamp , msg->pose .pose .position );
440435 setAttitude (msg->pose .pose .orientation );
441436 setLinearVelocity (msg->twist .twist .linear );
442- // update_time_ = msg->header.stamp;
443- update_time_ = ros::Time::now ();
437+ update_time_ = msg->header .stamp ;
438+ // update_time_ = ros::Time::now();
444439
445440// setOdometry(msg);
446441// print(">>>>>>> RECEIVING KINEMATICS: ", true);
@@ -506,11 +501,11 @@ void Kinematics::test() {
506501 printf (" Linear velocity x:%f, y:%f, z:%f\n " , van.x , van.y , van.z );
507502
508503 printf (" Kinematics: setPosition - x,y,z\n " );
509- setPosition (p.pose .position .x , p.pose .position .y , p.pose .position .z );
504+ setPosition (ros::Time::now (), p.pose .position .x , p.pose .position .y , p.pose .position .z );
510505 print (" TEST" );
511506
512507 printf (" Kinematics: setPosition - position\n " );
513- setPosition (p.pose .position );
508+ setPosition (ros::Time::now (), p.pose .position );
514509 print (" TEST" );
515510
516511 printf (" Kinematics: setPose\n " );
0 commit comments