[ros-users] running "navigationTutorialsRobotSetupOdom" example code on erratic_gazebo
yatish
ymishra at asu.edu
Fri Jun 4 10:19:57 UTC 2010
Hi all
I am trying to run the example code given under the section
"navigationTutorialsRobotSetupOdom" on Erratic_gazebo. The robot doesnt move
at all. The example code is as follows
#include <ros/ros.h>
#include <tf/transform_broadcaster.h>
#include <nav_msgs/Odometry.h>
int main(int argc, char** argv){
ros::init(argc, argv, "odometry_publisher");
ros::NodeHandle n;
ros::Publisher odom_pub = n.advertise<nav_msgs::Odometry>("odom", 50);
tf::TransformBroadcaster odom_broadcaster;
double x = 0.0;
double y = 0.0;
double th = 0.0;
double vx = 0.1;
double vy = -0.1;
double vth = 0.1;
ros::Time current_time, last_time;
current_time = ros::Time::now();
last_time = ros::Time::now();
ros::Rate r(1.0);
while(n.ok()){
current_time = ros::Time::now();
//compute odometry in a typical way given the velocities of the robot
double dt = (current_time - last_time).toSec();
double delta_x = (vx * cos(th) - vy * sin(th)) * dt;
double delta_y = (vx * sin(th) + vy * cos(th)) * dt;
double delta_th = vth * dt;
x += delta_x;
y += delta_y;
th += delta_th;
//since all odometry is 6DOF we'll need a quaternion created from yaw
geometry_msgs::Quaternion odom_quat =
tf::createQuaternionMsgFromYaw(th);
//first, we'll publish the transform over tf
geometry_msgs::TransformStamped odom_trans;
odom_trans.header.stamp = current_time;
odom_trans.header.frame_id = "odom";
odom_trans.child_frame_id = "base_link";
odom_trans.transform.translation.x = x;
odom_trans.transform.translation.y = y;
odom_trans.transform.translation.z = 0.0;
odom_trans.transform.rotation = odom_quat;
//send the transform
odom_broadcaster.sendTransform(odom_trans);
//next, we'll publish the odometry message over ROS
nav_msgs::Odometry odom;
odom.header.stamp = current_time;
odom.header.frame_id = "odom";
//set the position
odom.pose.pose.position.x = x;
odom.pose.pose.position.y = y;
odom.pose.pose.position.z = 0.0;
odom.pose.pose.orientation = odom_quat;
//set the velocity
odom.child_frame_id = "base_link";
odom.twist.twist.linear.x = vx;
odom.twist.twist.linear.y = vy;
odom.twist.twist.angular.z = vth;
//publish the message
odom_pub.publish(odom);
last_time = current_time;
r.sleep();
}
}
After running erratic)gazebo by the command roslaunch erratic_gazebo
erratic_2dnav_demo.launch i run the code.
Also rostopic list is as follows
/amcl_pose
/base_pose_ground_truth
/base_scan
/base_scan_shadow_filter
/base_scan_shadow_filtered
/base_scan_throttled
/calibrated
/clock
/cmd_vel
/diagnostics
/erratic_odometry
/erratic_odometry/odom
/initialpose
/joint_states
/map
/map_metadata
/mechanism_statistics
/move_base/cancel
/move_base/feedback
/move_base/goal
/move_base/result
/move_base/status
/move_base_node/NavfnROS/NavfnROS_costmap/inflated_obstacles
/move_base_node/NavfnROS/NavfnROS_costmap/obstacles
/move_base_node/NavfnROS/NavfnROS_costmap/robot_footprint
/move_base_node/NavfnROS/NavfnROS_costmap/unknown_space
/move_base_node/NavfnROS/plan
/move_base_node/TrajectoryPlannerROS/global_plan
/move_base_node/TrajectoryPlannerROS/local_plan
/move_base_node/current_goal
/move_base_node/global_costmap/inflated_obstacles
/move_base_node/global_costmap/obstacles
/move_base_node/global_costmap/robot_footprint
/move_base_node/global_costmap/unknown_space
/move_base_node/local_costmap/inflated_obstacles
/move_base_node/local_costmap/obstacles
/move_base_node/local_costmap/robot_footprint
/move_base_node/local_costmap/unknown_space
/move_base_node/local_costmap/voxel_grid
/move_base_node/local_costmap/voxel_grid_throttled
/move_base_simple/goal
/particlecloud
/reset_time
/rosout
/rosout_agg
/tf
/tf_message
/time
/visualization_marker
/visualization_marker_array
root at uav-laptop:~/ros/stacks/pr2_apps/pr2_teleop# rostopic list
/base_pose_ground_truth
/base_scan
/calibrated
/clock
/cmd_vel
/diagnostics
/erratic_odometry/odom
/joint_states
/mechanism_statistics
/rosout
/rosout_agg
/tf
/time
Can anyone help me out in finding why robot is not moving ?
Thanks
Yatish
--
View this message in context: http://ros-users.122217.n3.nabble.com/running-navigationTutorialsRobotSetupOdom-example-code-on-erratic-gazebo-tp869994p869994.html
Sent from the ROS-Users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
ros-users mailing list
ros-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ros-users
More information about the ros-users
mailing list