#include <ros/ros.h>
#include <tf2_ros/transform_listener.h>
#include "amr_control/amr_control.h"

int main(int argc, char** argv)
{
  ros::init(argc, argv, "move_base_node");
  ros::start();
  ROS_INFO("ros::this_node::getName() : %s", ros::this_node::getName().c_str());
  ros::NodeHandle nh(ros::this_node::getName());
  std::shared_ptr<tf2_ros::Buffer> buffer = std::make_shared<tf2_ros::Buffer>();
  tf2_ros::TransformListener tf2(*buffer);
  try
  {
    std::shared_ptr<amr_control::AmrController> amr_ctr_;
    amr_ctr_ = std::make_shared<amr_control::AmrController>(nh, buffer);
    ros::spin();
    if(amr_ctr_ != nullptr) 
      amr_ctr_->stop();
    amr_ctr_.reset();
  }
  catch (const std::exception& exc)
  {
    ROS_ERROR("Exception: %s", exc.what());
  }
  return 0;
}