turtlebot3_simulations: turtlebot3_drive does not publish to cmd_vel

I am using the melodic version of ROS with an Ubuntu 18.04 system.

I ran into an issue where the burger bot in gazebo, did not move when turtlebot3_simulation.launch file was launched.

When I ran “rqt_graph” node I found out that the “turtlebot3_drive” node did not publish to /cmd_vel topic and also it did not subscribe from /odom and /scan topics too.

I made the following change in the in the “turtlebot3_drive.cpp” file present in the “/turtlebot3_gazebo/src” folder and the issue was solved. I added the turtlebot3_drive.init(); line in the main() function as shown below:

int main(int argc, char* argv[])
{
  ros::init(argc, argv, "turtlebot3_drive");
  Turtlebot3Drive turtlebot3_drive;
  turtlebot3_drive.init();  //the line that I added

  ros::Rate loop_rate(125);

  while (ros::ok())
  {
    turtlebot3_drive.controlLoop();
    ros::spinOnce();
    loop_rate.sleep();
  }

  return 0;
}

Probably it happened because, some compilers do not run the init() function of a class, as soon as it’s object is created.

I thought I could post this here, as if anyone faced the same issue as me could get it sorted.

Thank you.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@jtisaacs If you are unable to move TurtleBot3 on Gazebo, you may not installed all necessary Gazebo packages such as gazebo-plugins. Please install all gazebo packages with below command and try again. Also, please note that Kinetic works best with Ubuntu 16.04. I’d recommend using Melodic for your Ubuntu 18.04 or install Ubuntu 16.04 to use ROS 1 Kinetic.

$ sudo apt install ros-kinetic-gazebo*

@adipandas You can try installing all gazebo packages with below command. First, check which gazebo version you are running then install necessary pacakges.

$ gazebo --version

If you are running gazebo 9,

$ sudo apt install ros-melodic-gazebo-*

If you are running gazebo 11,

$ sudo apt install ros-melodic-gazebo11*

@ROBOTIS-Will Your suggestion solved the issue. I actually did not consider checking my gazebo packages. Thank you. 😄

I think this issue can be closed now.