ROS_INFO与ROS_INFO_STREAM,ROS_INFO_STREAM_ONCE
ROS_INFO(“INFO message %d”,k),相当于c中的printf;
ROS_INFO_STREAM ( "INFO message." <<k);相当于c++中的cout;
ROS_INFO_STREAM_ONCE( "INFO message." <<k);相当于c++中的cout;但只执行一次
关于ros::NodeHandle
ros::NodeHandle n:命名空间为/node_namespace
ros::NodeHandle n("name"):命名空间为/node_namespace/name
ros::NodeHandle n("~"):命名空间为/node_namespace/node_name
打开文件流的方法
使用标准输入输出流
参考:https://blog.csdn.net/qq_28640763/article/details/109898803
#include <fstream>
std::ifstream fin(config_file,std::ios::in);
if(!fin.is_open())
{
std::cerr << "ERROR: Wrong path to settings" << std::endl;
}
char buf[100];
fin>>buf; //读取一行
std::cout<<"ww-"<<buf<<std::endl;
fin>>buf;
std::cout<<"ww-"<<buf<<std::endl;
fin.close();
使用opencv的cv::FileStorage对YAML格式文件进行操作
参考1:https://blog.csdn.net/zhhp1001/article/details/84816328
参考2:https://blog.csdn.net/sinat_41752325/article/details/124101002
cv::FileStorage fsSettings(config_file, cv::FileStorage::READ); //构造函数
if(!fsSettings.isOpened())
{
std::cerr << "ERROR: Wrong path to settings" << std::endl;
}
fsSettings["image_topic"] >> IMAGE_TOPIC;
fsSettings["imu_topic"] >> IMU_TOPIC;
MAX_CNT = fsSettings["max_cnt"];
MIN_DIST = fsSettings["min_dist"];
fsSettings.release();
YAML文件中的以下内容
projection_parameters:
fx: 4.616e+02
fy: 4.603e+02
cx: 3.630e+02
cy: 2.481e+02
cv::FileNode n = fs["distortion_parameters"];
m_fx = static_cast<double>(n["fx"]);
m_fy = static_cast<double>(n["fy"]);
m_cx = static_cast<double>(n["cx"]);
m_cy = static_cast<double>(n["cy"]);
4. 图像格式转换:cv_bridge
参考:http://wiki.ros.org/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages
cv_bridge是实现ROS图像消息和OpenCV图像之间进行转换的一个功能包
cv_bridge::CvImageConstPtr ptr = cv_bridge::toCvCopy(img_msg, sensor_msgs::image_encodings::MONO8);
cv::Mat cv_img = ptr->image;
5. 内存CPU查看
命令1:gnome-system-monitor
命令2:top