Skip to content

Commit 93e7870

Browse files
committed
controller working great
1 parent 8732859 commit 93e7870

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

eklavya_gazebo_plugins/src/gazebo_ros_eklavya.cpp

+17-9
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void GazeboRosEklavya::UpdateChild()
201201
// Compute odometric pose
202202
odom_pose_[0] += dr * cos( odom_pose_[2] );
203203
odom_pose_[1] += dr * sin( odom_pose_[2] );
204-
odom_pose_[2] -= da;
204+
odom_pose_[2] += da;
205205

206206
// Compute odometric instantaneous velocity
207207
odom_vel_[0] = dr / step_time.Double();
@@ -219,23 +219,31 @@ void GazeboRosEklavya::UpdateChild()
219219
joints_[RIGHT]->SetVelocity( 0, wheel_speed_[RIGHT] / (wd / 2.0) );
220220
joints_[RIGHT]->SetMaxForce( 0, torque_ );
221221
}
222+
// getting data for base_footprint to odom transform
223+
math::Pose pose = this->my_parent_->GetState().GetPose();
222224

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
223231
nav_msgs::Odometry odom;
224232
odom.header.stamp.sec = time_now.sec;
225233
odom.header.stamp.nsec = time_now.nsec;
226234
odom.header.frame_id = "odom";
227235
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];
230238
odom.pose.pose.position.z = 0;
231239

232240
btQuaternion qt;
233241
qt.setEuler(0,0,odom_pose_[2]);
234242

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();
239247

240248
double pose_cov[36] = { 1e-3, 0, 0, 0, 0, 0,
241249
0, 1e-3, 0, 0, 0, 0,
@@ -303,8 +311,8 @@ void GazeboRosEklavya::OnCmdVel( const geometry_msgs::TwistConstPtr &msg)
303311
vr = msg->linear.x;
304312
va = msg->angular.z;
305313

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;
308316
}
309317

310318
void GazeboRosEklavya::spin()

0 commit comments

Comments
 (0)