编程语言
首页 > 编程语言> > rpg_ig_active源码阅读(四)

rpg_ig_active源码阅读(四)

作者:互联网

今天看的是flying_gazebo_stereo_cam的code_base文件夹下的部分和ros_nodes文件夹下的部分

pcl_rerouter.cpp

namespace ros_tools:

  PclRerouter::PclRerouter( ros::NodeHandle nh, std::string in_name, std::string out_name  )
  : nh_(nh)
  , forward_one_(false)
  , has_published_one_(false)
  , one_to_srv_(false)
  {
    // 话题
    pcl_subscriber_ = nh_.subscribe( in_name, 1, &PclRerouter::pclCallback, this );
    pcl_publisher_ = nh_.advertise<sensor_msgs::PointCloud2>(out_name, 1);
    // server
    pcl_service_caller_ = nh_.serviceClient<ig_active_reconstruction_msgs::PclInput>(out_name);
  }

controller.cpp

namespace flying_gazebo_stereo_cam:

  Controller::Controller(std::string cam_model_name)
  : cam_model_name_(cam_model_name)
  , has_moved_(false)
  , keepPublishing_(false)
  , cam_to_image_(0.5,0.5,-0.5,0.5)
  {
  }

其他的函数

robot_communication_interface.cpp

namespace flying_gazebo_stereo_cam:
只有CommunicationInterface这一个类 继承的是 ig_active_reconstruction::robot::CommunicationInterface
有两个公有的成员变量

typedef ig_active_reconstruction::views::View View;
typedef ig_active_reconstruction::robot::MovementCost MovementCost;

和两个私有成员变量

std::shared_ptr<Controller> cam_controller_; //! For movements etc.
ros_tools::PclRerouter pcl_rerouter_;
  CommunicationInterface::CommunicationInterface( ros::NodeHandle nh, std::shared_ptr<Controller> controller, std::string in_name, std::string out_name )
  : cam_controller_(controller)
  , pcl_rerouter_(nh,in_name,out_name)
  {
  }

其他函数有:

auto distance = current.position - target_pos;
cost.cost = distance.norm();
    auto distance = start_view.pose().position - target_view.pose().position;
    cost.cost = distance.norm();

robot_interface.cpp

是一个gazebo里相机的ros节点实现,节点的名称是robot_interface

参数

  std::string model_name, camera_frame_name, world_frame_name, sensor_in_topic, sensor_out_name;
  ros_tools::getExpParam(model_name,"model_name");
  ros_tools::getExpParam(camera_frame_name,"camera_frame_name");
  ros_tools::getExpParam(world_frame_name,"world_frame_name");
  ros_tools::getExpParam(sensor_in_topic,"sensor_in_topic");
  ros_tools::getExpParam(sensor_out_name,"sensor_out_name");

controller

  std::shared_ptr<Controller> controller = std::make_shared<Controller>(model_name);
  //! publish tf
  controller->startTfPublisher(camera_frame_name,world_frame_name);

关于智能指针的用法,是C++11标准里的,可以参考
常见用法是

std::shared_ptr<Test> p = std::make_shared<Test>();
std::shared_ptr<Test> p(new Test);

其中make_shared的优先级高于new

interface

  boost::shared_ptr<CommunicationInterface> robot_interface =
      boost::make_shared<CommunicationInterface>(nh,controller,sensor_in_topic,sensor_out_name);

communication interface

ig_active_reconstruction::robot::RosServerCI comm_unit(nh,robot_interface);

把通讯接口给ROS
这里还需要看 目前没看到

标签:std,name,frame,controller,源码,cam,active,ros,ig
来源: https://blog.csdn.net/weixin_42518636/article/details/112850973