What is the difference between the 2 pieces of code -
tf2_ros::Buffer buffer(ros::Duration(10));
costmap_2d::Costmap2DROS costmap_one("costmap_one", buffer);
and
costmap_2d::Costmap2DROS *costmap_one = new costmap_2d::Costmap2DROS("costmap_one", buffer)
I understand that in the first case, we get a costmap_2d::Costmap2DROS object named costmap_one whereas in the second case, we get a pointer named costmap_one that points to a costmap_2d::Costmap2DROS object.
When should we use one over the other?