ROBOTIS-GIT / turtlebot3

ROS packages for Turtlebot3
http://turtlebot3.robotis.com
Apache License 2.0
1.49k stars 1.02k forks source link

Diiferent calculation of velocity in odometry topic caused by timestamp type. #752

Open shanpenghui opened 3 years ago

shanpenghui commented 3 years ago

ISSUE TEMPLATE ver. 0.4.0

  1. Which TurtleBot3 platform do you use?

    • [ ] Burger
    • [ ] Waffle
    • [√ ] Waffle Pi
  2. Which ROS is working with TurtleBot3?

    • [ ] ROS 1 Kinetic Kame
    • [ ] ROS 1 Melodic Morenia
    • [ ] ROS 1 Noetic Ninjemys
    • [ ] ROS 2 Dashing Diademata
    • [ ] ROS 2 Eloquent Elusor
    • [√ ] ROS 2 Foxy Fitzroy
    • [ ] etc (Please specify your ROS Version here)
  3. Which SBC(Single Board Computer) is working on TurtleBot3?

    • [ ] Intel Joule 570x
    • [ ] Raspberry Pi 3B+
    • [ √] Raspberry Pi 4
    • [ ] etc (Please specify your SBC here)
  4. Which OS you installed on SBC?

    • [ ] Raspbian distributed by ROBOTIS
    • [ ] Ubuntu MATE (16.04/18.04/20.04)
    • [√ ] Ubuntu preinstalled server (18.04/20.04)
    • [ ] etc (Please specify your OS here)
  5. Which OS you installed on Remote PC?

    • [ ] Ubuntu 16.04 LTS (Xenial Xerus)
    • [ ] Ubuntu 18.04 LTS (Bionic Beaver)
    • [ √] Ubuntu 20.04 LTS (Focal Fossa)
    • [ ] Windows 10
    • [ ] MAC OS X (Specify version)
    • [ ] etc (Please specify your OS here)
  6. Specify the software and firmware version(Can be found from Bringup messages)

    • Software version: [foxy-devel]
    • Firmware version: [foxy-devel]
  7. Specify the commands or instructions to reproduce the issue.

    • ros2 launch turtlebot3_bringup robot.launch.py
  8. Copy and Paste the error messages on terminal.

    • The output of velocity in odometry is zero.
  9. Please describe the issue in detail.

    • HERE I'm doing the job that integrate the odom and imu. But the result seems something get wrong when I fuse the odometry data. So I check the odometry and found that the timestamp format is the reason. The origin code is below in turtlebot3_node/src/odometry.cpp
 static rclcpp::Time last_time = joint_state_msg->header.stamp;
 rclcpp::Duration duration(joint_state_msg->header.stamp.nanosec - last_time.nanoseconds());

And the velocity output is zero. But the output is correct when I change the type from rclcpp::Time to builtin_interfaces::msg::Time.

  static builtin_interfaces::msg::Time last_time = joint_state_msg->header.stamp;
  rclcpp::Duration duration(joint_state_msg->header.stamp.nanosec - last_time.nanosec);

There are two functions used that type: joint_state_callback and joint_state_and_imu_callback.

Please check it if I get something missed or wrong.

Thank you very much.

ROBOTIS-Ashe commented 3 years ago

Hi @shanpenghui . Thank you for your questions.

rclcpp::Time is a function Initializes the time values ​​for seconds and nanoseconds individually. But builtin_interfaces::msg::Time is of type msg. Please refer to the link below for more details.

Also, it is an image of /odom & /joint_states topic when publishing cmd_vel to turtlebot3 burger

Thank you for your reference.