flat7th

memo/20120311

created 2012-03-11 modified 2012-03-12 

ROSturtlebotturtlebot_simulatorgazebo


Linkmemo
Challenges with headless turtlebot_gazebo on remote machineROS answers.ros.org
ticket #132




I found "using variables without initialize" bug in "simulator_gazebo_plugins".
That cause the corrupted very large value of odometry {x, y}.

[problem]
When you try to use turtlebot simulator (gazebo),
sometimes the node "/gazebo" publishes the topic "/odom" with very large
initial position {x, y} like 1e+31 or so.

[cause]
In turtlebot_gazebo_plugins/src/gazebo_ros_create.cpp,
variables below are used without being initialized.
  • prev_update_time
  • odom_pose[0]
  • odom_pose[1]
  • odom_pose[2]

I know that recentry turtlebot_gazebo_plugins/src/gazebo_ros_create.cpp was patched
about NaN value (in GazeboRosCreate::UpdateChild()) .
The patch didn't fix the problem I found.

I don't know how to report bug-report and patch, so I'm glad if someone does.

[environment]
  • ubuntu 11.10 32bit
  • ros-electric (updated with apt-get)

[how to reproduce]
(not 100%. because that is caused with "using uninitialized variable" in C++.)

Start 3 terminals separately and type it.
$ roscore
$ roslaunch turtlebot_gazebo turtlebot_empty_world.launch
$ rostopic echo /odom

Check values of pose.pose.position.x and y.
If it shows like below, you successed to reproduce.

pose:
  pose:
    position:
      x: 1.86493744726e+31
      y: 4.86171422416e+30

[how to fix]
initialize variables.

[patch]
keizo@soi:~/ros_workspace/turtlebot_gazebo_plugins.keizo/src$ diff -c /opt/ros/electric/stacks/turtlebot_simulator/turtlebot_gazebo_plugins/src/gazebo_ros_create.cpp .
*** /opt/ros/electric/stacks/turtlebot_simulator/turtlebot_gazebo_plugins/src/gazebo_ros_create.cpp 2012-02-29 07:52:33.000000000 +0900
--- ./gazebo_ros_create.cpp 2012-03-11 22:59:59.026536682 +0900
***************
*** 153,158 ****
--- 153,159 ----
    js_.velocity.push_back(0);
    js_.effort.push_back(0);

+   prev_update_time_ = 0;
    last_cmd_vel_time_ = 0;
  }

***************
*** 172,177 ****
--- 173,184 ----
    if (joints_[FRONT]) set_joints_[FRONT] = true;
    if (joints_[REAR]) set_joints_[REAR] = true;

+   //initialize time and odometry position
+   prev_update_time_ = last_cmd_vel_time_ =
+     Simulator::Instance()->GetSimTime();
+   odom_pose_[0] = 0.0;
+   odom_pose_[1] = 0.0;
+   odom_pose_[2] = 0.0;
  }

  void GazeboRosCreate::FiniChild()



[ Unnecessary additional information ]
[indirect problem]
When you try to use turtlebot simulator (gazebo) and slam_gmapping,
the node slam_gmapping dies with a message "bad_alloc" exception.

[cause]
Ordinary, the initial value of odometory's {x, y} should be nearly equal to zero.
but it shows sometimes very large like 1e+31 or so.

When the node "slam_gmapping" receives that large value, it try to enlarge map too much.
And it cause a "not enough memory" situation and "bad_alloc" exception.

If you want to reproduce, you need to add "output_frame" param described blelow
to turtlebot_gazebo/launch/robot.launch .

<node pkg="robot_pose_ekf parameter" .... >
   ....
   <param name="output_frame" value="odom"/>
</node>

[comment]
I'm not good at English, I apologize about my poor English.
I hope this information helps you. and also me.



ROS の gazebo

タートルボットのシミュレータ(gazebo)で、トピック /odom の x, y の初期値が不正に巨大な値になっています。

マップを作成するため slam_gmapping を起動すると、オドメトリの x, y が巨大であるため、マップを拡張しようとしてたくさんのメモリを確保しようとし、bad_alloc 例外を吐いて落ちます。

原因は、turtlebot_gazebo_plugins/src/gazebo_ros_create.cpp にて、
以下の変数を未初期化で使ってるから。なんとまぁ。
  • prev_update_time
  • odom_pose[0]
  • odom_pose[1]
  • odom_pose[2]

対処は、初期化すること。

で、バグレポート出したいのですが出し方分かりませんorz...
チケット出してみました。