@@ -201,7 +201,7 @@ void GazeboRosEklavya::UpdateChild()
201
201
// Compute odometric pose
202
202
odom_pose_[0 ] += dr * cos ( odom_pose_[2 ] );
203
203
odom_pose_[1 ] += dr * sin ( odom_pose_[2 ] );
204
- odom_pose_[2 ] - = da;
204
+ odom_pose_[2 ] + = da;
205
205
206
206
// Compute odometric instantaneous velocity
207
207
odom_vel_[0 ] = dr / step_time.Double ();
@@ -219,23 +219,31 @@ void GazeboRosEklavya::UpdateChild()
219
219
joints_[RIGHT]->SetVelocity ( 0 , wheel_speed_[RIGHT] / (wd / 2.0 ) );
220
220
joints_[RIGHT]->SetMaxForce ( 0 , torque_ );
221
221
}
222
+ // getting data for base_footprint to odom transform
223
+ math::Pose pose = this ->my_parent_ ->GetState ().GetPose ();
222
224
225
+ btQuaternion qt1 (pose.rot .x , pose.rot .y , pose.rot .z , pose.rot .w );
226
+ // btVector3 vt(pose.pos.x, pose.pos.y, pose.pos.z);
227
+
228
+ // tf::Transform base_footprint_to_odom(qt1, vt);
229
+ // transform_broadcaster_->sendTransform(tf::StampedTransform(base_footprint_to_odom,current_time,odom_frame,base_footprint_frame));
230
+ // publish odom topic
223
231
nav_msgs::Odometry odom;
224
232
odom.header .stamp .sec = time_now.sec ;
225
233
odom.header .stamp .nsec = time_now.nsec ;
226
234
odom.header .frame_id = " odom" ;
227
235
odom.child_frame_id = " base_footprint" ;
228
- odom.pose .pose .position .x = odom_pose_[0 ];
229
- odom.pose .pose .position .y = odom_pose_[1 ];
236
+ odom.pose .pose .position .x = pose. pos . x ; // odom_pose_[0];
237
+ odom.pose .pose .position .y = pose. pos . y ; // odom_pose_[1];
230
238
odom.pose .pose .position .z = 0 ;
231
239
232
240
btQuaternion qt;
233
241
qt.setEuler (0 ,0 ,odom_pose_[2 ]);
234
242
235
- odom.pose .pose .orientation .x = qt.getX ();
236
- odom.pose .pose .orientation .y = qt.getY ();
237
- odom.pose .pose .orientation .z = qt.getZ ();
238
- odom.pose .pose .orientation .w = qt.getW ();
243
+ odom.pose .pose .orientation .x = pose. rot . x ; // qt.getX();
244
+ odom.pose .pose .orientation .y = pose. rot . y ; // qt.getY();
245
+ odom.pose .pose .orientation .z = pose. rot . z ; // qt.getZ();
246
+ odom.pose .pose .orientation .w = pose. rot . w ; // qt.getW();
239
247
240
248
double pose_cov[36 ] = { 1e-3 , 0 , 0 , 0 , 0 , 0 ,
241
249
0 , 1e-3 , 0 , 0 , 0 , 0 ,
@@ -303,8 +311,8 @@ void GazeboRosEklavya::OnCmdVel( const geometry_msgs::TwistConstPtr &msg)
303
311
vr = msg->linear .x ;
304
312
va = msg->angular .z ;
305
313
306
- wheel_speed_[LEFT] = vr - va * (wheel_sep_) / 2 ;
307
- wheel_speed_[RIGHT] = vr + va * (wheel_sep_) / 2 ;
314
+ wheel_speed_[LEFT] = vr + va * (wheel_sep_) / 2 ;
315
+ wheel_speed_[RIGHT] = vr - va * (wheel_sep_) / 2 ;
308
316
}
309
317
310
318
void GazeboRosEklavya::spin ()
0 commit comments