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

电子书籍整理

状态估计: 神书:  stste estimation for robotics.  barfoot 微分集合&李群: 李群的大部头神书: Notes on Differential Geometry and Lie Groups INTRODUCTION TODIFFERENTIAL GEOMETRY Introduction to Smooth Manifolds & Lie Groups INTRODUCTION TO DIFFERENTIABLEMANIFOLDS  (笔记类型,一百多页) 一个很好的教学笔记: Lie groups, Lie Algebras, projective geomtry and optimization for 3D Geometry, Engineering and Computer Vision 张量:  A Student’s Guide to Vectors and Tensors

ROS、惯导、OpenCV、开源算法中坐标表示的理解

ros中tf系统的坐标表示: http://wiki.ros.org/tf/Overview/Transformations tf中坐标转换方向 ros中各个坐标系的定义: http://www.ros.org/reps/rep-0105.html#odom rovio算法中的坐标表示: https://github.com/ethz-asl/rovio/wiki/Coordinate-Frames-and-Notation 变换的理解:       两个坐标系的同一个点,由c1系转换到c2系,称为坐标变换,或俗称点变换;只考虑两个坐标系的变换,称为基变换,俗称坐标系变换。坐标变换和基变换方向相反,但表达的坐标系是同一个。变换要考虑变换的方向和描述的坐标系两个问题。 一般的变换中,都是以坐标系下的一个坐标点作为参照进行转换推导,参见《视觉SLAM14讲》P41的推导。因此,得到的变换R、t,是坐标的变换,即简单的理解为点的变换。 在VIO中一样,IMU即使看不到点,也以其坐标系下的 一个点作为参考(比如,将重力从n系转换到b系,将重力看作一个点)。 考虑点P在1、2坐标系的表示分别为P1、P2, 坐标点P从P1变换到P2: P2 = R_21*P1+ t_21_2 坐标系1、2的坐标基变换则为从2变换到1: R_12 、 t_12_2 因此,坐标变换的描述坐标系为终点坐标系,基变换的描述坐标系为起点坐标系 在tf/message的ros框架下,以tf为例: 描述坐标系为frame_id, -> 全局坐标系 坐标基变换(坐标系变换):frame_id -> child_frame_id 坐标变换(点变换):child_frame_id -> frame_id 在ros message中变换也是基于坐标基的变换。  有的是基于点的,查看源码的注释,比如loockTransform(),注释中就说了是变换data。sendTrsnform()中通过frame_id和child_frame_id进行识别。 更新: 最直接的记忆方式就跟据全局坐标系, 比如,标定结果中,T_cam0_imu, 意味着将点从imu坐标系转换到cam0坐标系,对于...