Skip to main content

ros调试----rosparm

当程序有许多参数传入时,通常会通过rosparm进行传递,
传递形式为在roslaunch文件中的node中,使用rosparm,比如
<node pkg="tvio" type="image_processor_node" name="image_processor"  output="screen" >
      <rosparam command="load" file="$(arg calibration_file)"/>
      <param name="grid_row" value="4"/>
      <param name="grid_col" value="5"/>

      <remap from="~imu" to="/xsens_imu_data"/>
      <remap from="~cam0_image" to="/camera/left/image_raw"/>
      <remap from="~cam1_image" to="/camera/right/image_raw"/>
 </node>
其中,calibration_file为指定的rosparam格式的yaml文件。
可以通过launch文件启动调试,但是不是很习惯,还是喜欢用Clion的可视化调试。
方法:
1)在终端中手动加载rosparam参数:
python /opt/ros/kinetic/bin/rosparam  load  /xxxx/camchain.yaml
参数一旦加载后,会保持在本机上的参数服务器中(是不是和roscore相关),程序运行就能读取到。
2)remap中的参数项通过程序的命令行参数形式传入:
image_processor   ~imu:=/xsens_imu_data     ~cam0_image:=/camera/left/image_raw ~cam1_image:=/camera/right/image_raw
param中的参数还不知道如何传入。


代码中从参数服务器获取参数的方式:
nh_.param<std::string>("/cam0/distortion_model",cam0_distortion_model, std::string("radtan"));
nh_.getParam("/cam0/resolution",cam0_resolution_temp);
对于内置类型,比如int、string等,以上两种都是可以的。
但经常需要从参数中传入矩阵或者向量,比如矩阵的内参外参等,这时候都要用第二种形式:
std::vector<float> cam0_distortion_temp;
nh_.getParam("/cam0/distortion_coeffs",cam0_distortion_temp);
cam0_distortion_coeffs = cv::Vec4d(cam0_distortion_temp[0],cam0_distortion_temp[1],
                                   cam0_distortion_temp[2],cam0_distortion_temp[3]);
注意,第二种参数传递形式中,是没有默认值的。因此,必须保证程序执行时参数服务器中已有该参数。不然后后面使用到变量cam0_distortion_temp的地方就会报错。

Comments

Popular posts from this blog

一、VO篇(monocular、stereo)

单目相关的一些资源 1、该作者实现了最简单的单目、Stereo VO,都是基于点特征的 Monocular Visual Odometry using OpenCV Visual Odmetry from scratch - A tutorial for beginners     2、Matlab官方文档中的例子: Monocular Visual Odometry 3、基于RANSC野点剔除: https://github.com/sunzuolei/mvo_ransac/tree/master/mvo_ransac   在Android平台的实现: https://github.com/sunzuolei/mvo_android  https://github.com/sunzuolei/vo_basis 这里还向相关的视频  4、论文+代码   http://www.cs.cmu.edu/~rahuls/pub/icra2005-rahuls.pdf http://www.cs.cmu.edu/~vo/vo-0-2.tgz  5、libviso2  单双目   基于点和线的VO:包括双目、单目(svo) http://mapir.uma.es/mapirwebsite/index.php/people/115-people/164-ruben-gomez.html   6、fovis 7、bpvo https://github.com/halismai/bpvo  该套算法来自CMU,以及作者的另一套开源算法photobundle,有作者的博士论文链接,拜读。       双目vo:  https://github.com/ucsdxiaoyuzhou/CSE252C_visual_odometry https://github.com/fovis/fovis 深度相机或者stereo https://github.com/jaiprakashgogi/visualodometry 带有简...

AHRS开源项目

ros中集成的组件: 9DOF https://github.com/ccny-ros-pkg/imu_tools 该算法是Sebastian Madgwick博士 2009 年开源的研究项目。 原始项目: http://x-io.co.uk/open-source-imu-and-ahrs-algorithms/ 但是一直没有在维护更新,后被集成到ros中。  另一套6DOF的开源AHRS系统, http://autopilot.sourceforge.net/kalman.html