ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I have found the answers for most of my questions and now I'm able to do teleoperation. I am writing the answers in case someone else might the same problems.
So the answers;
In the odometry transform broadcaster, my mistake was to only create transforms between /odom and /base_link. This was the reason why I the robot only moved around a circle of odom frame. I have fixed this.
I still don't know why I only see /odom frame and no higher world frame.
Joint_state.velocity[] acts as what we treated. It's just a variable. So in my case since the joints are continuous they should be taken as angular velocities.
I didn't have a time differential so my usage was wrong. It is fixed by;
while (ros::ok())
{
ros::spinOnce(); //check new messages
current_time = ros::Time::now(); //set current time
nh_.getParam("wLeft",wLeft); //get left wheel angular velocity value from parameter server
nh_.getParam("wRight",wRight); //get right wheel angular velocity value from parameter server
vLeft = wheelRadius*wLeft; //linear velocity of left wheel
vRight = wheelRadius*wRight; //linear velocity of rigth wheel
vx = (vRight+vLeft)/2; //linear velocity in ROBOT frame
wth = (vRight-vLeft)/length; //angular velocity of the ROBOT
dt = (current_time - prev_time).toSec(); //time differential
delta_x = vx*cos(th)*dt; //change in x axis in world frame
delta_y = vx*sin(th)*dt; //change in y axis in world frame
delta_th = wth*dt; //change in the orientation
x += delta_x;
y += delta_y;
th += delta_th;
//broadcast transforms
broadcastTF(&broadcaster,"base_link",x,y,0,th);
broadcastTF(&broadcaster,"wheel_left",x,y,0,th);
broadcastTF(&broadcaster,"wheel_right",x,y,0,th);
//set previous time
prev_time = current_time;
//rest until loop rate is done
loop_rate.sleep();}//end of while