鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    使用camera-calibration进行相机标定时,launch起不来对应node,只创建了日志,但是没有输出

    已定时 已固定 已锁定 已移动
    手眼标定
    相机标定 ros node起不来
    2
    4
    499
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 5
      568837184
      最后由 编辑

      背景,需要进行相机雷达标定:按照这篇贴子的攻略在做
      https://github.com/heethesh/lidar_camera_calibration

      目前卡在这里这一步
      “运行 Camera Calibration
      这个启动文件将播放 rosbag 记录并从 ROS 运行包。默认情况下,结果存储在 中。camera_calibration ~/.ros/camera_info“

      roslaunch lidar_camera_calibration camera_calibration.launch
      

      我录制的topic在相机传参的时候已经改写了名字,camera_calibration.launch源代码如下

      <?xml version="1.0" encoding="UTF-8"?>
      <launch>
      
          <arg name="camera" default="/camera/color" />
          <arg name="size" default="7x5" />
          <arg name="square" default="0.05" />
          <arg name="k-coefficients" default="2" />
      
          <!-- Play rosbag record -->
          <include file="$(find lidar_camera_calibration)/launch/play_rosbag.launch">
              <arg name="bagfile" value="test.bag" />
          </include>
      
          <!-- Run camera calibration -->
          <node   
              pkg="camera_calibration"
              type="cameracalibrator.py"
              name="cameracalibrator"
              output="screen"
              args="--size=$(arg size) 
                    --square=$(arg square)
                    --k-coefficients=$(arg k-coefficients) 
                    --no-service-check" >
      
              <!-- Remap input topics -->
              <remap from="image" to="$(arg camera)/image_raw" />
              <remap from="camera" to="$(arg camera)/camera_info" />
          </node>
      
      </launch>
      

      异常有以下三点
      1.并没有在~/.ros/里面看到camera_info的数据

      2.camera_calibration.launch运行的是时候理论上应该把cameracalibrator的node起起来,但是rosnode list里面并没有看到bb5734ff-d5da-4a38-9346-a1a5e080a39a-image.png

      3,在~/.ros/log/latest路径下cameracalibrator-3.log有被创建,但是没有数据输出
      4d5939e9-6d4b-47bf-a282-dfb47a754019-image.png

      已经尝试过的方法:
      1.我尝试过在cameracalibrator.py里面输入打印日志的代码

      rospy.loginfo("start camera_calibration")
      

      但是rosout.log里面是没有对应输出的

      2.重新catkin build 对应 lidar_camera_calibration工作空间,但是没有用

      我个人猜测是这个node实际上没起来,但是debug不出来,请各位大佬指教一下

      1 条回复 最后回复 回复 引用 0
      • 小伊小
        机器人小伊
        最后由 编辑

        从你描述的情况来看,确实有几个可能的问题导致 cameracalibrator 节点没有正常启动和运行。以下是一些步骤和建议,可以帮助你进行故障排除和解决问题:

        1. 检查 ROS 环境设置

        确保你的 ROS 环境已经正确设置,包括 ROS 工作空间是否已经被正确编译(catkin_make 或 catkin build),并且所有必要的依赖都已经安装。

        2. 检查节点名称和参数

        • 确保 camera_calibration.launch 文件中 <arg> 标签设置的参数值是你系统中实际存在的 topic 名称和值。
        • 检查 cameracalibrator.py 脚本是否确实接受你在 launch 文件中设置的参数(特别是那些被用作 remap 的参数)。

        3. 检查 rosbag 播放

        由于你的 play_rosbag.launch 文件被包含在 camera_calibration.launch 中,确保:

        • rosbag 文件 test.bag 确实存在且路径正确。
        • play_rosbag.launch 文件是否正确无误地配置了所有必要的参数。

        4. 查看节点启动错误

        • 查看 ~/.ros/log/latest/cameracalibrator-*.log 文件的内容,可能会有更详细的错误信息。

        • 使用 roslaunch 命令时加上 --screen 选项来直接在终端显示输出,这有助于实时查看节点启动过程中的输出和错误信息。

          roslaunch --screen lidar_camera_calibration camera_calibration.launch
          

        5. 检查 topic 连接

        • 使用 rostopic list 查看所有正在发布的 topic。
        • 使用 rostopic echo /<topic_name> 查看某个 topic 的具体内容,确保 camera 的 topic 确实有数据输出。
        • 检查 camera topic 的名称和 camera_calibration.launch 文件中设置的是否一致。

        6. 调试脚本

        • 如果 cameracalibrator.py 是你自己修改的或不确定的,尝试用原始版本的脚本看是否能正常工作。
        • 在 cameracalibrator.py 中添加更多的 rospy.loginfo() 语句来跟踪执行流程。

        7. 权限问题

        • 确保你有足够的权限来读取 rosbag 文件和执行 Python 脚本。

        8. ROS 版本兼容性

        • 确保你的 ROS 版本与 camera_calibration 包兼容。有时候,新版本的 ROS 可能不完全兼容旧版本的包。

        通过以上步骤,你应该能够定位到问题的具体原因,并采取相应的措施来解决它。如果问题依然存在,可能需要更详细的日志信息或考虑向该包的开发者或社区寻求帮助。


        以上为生成回答,仅供参考~

        我是小伊,已接入ChatGpt,所有回复,仅供参考~

        5 1 条回复 最后回复 回复 引用 0
        • 5
          568837184 @小伊
          最后由 编辑

          @小伊
          1.catkin build是正常使用的,482a3f51-8b28-4f3f-8136-31450a4dec27-image.png

          2.对应输入topic包里有数据,且名字也是能对应的7208ca56-a9e5-4467-86f2-dec7a3ce693f-image.png

          cameracalibrator.py 脚本是系统自带的,理论上同格式的应该会被接收,如果接受不了也不应该node起不来

          3.路径正常,有数据,且播放的lunch不应该影响并列的node的启动吧

          4.```
          roslaunch lidar_camera_calibration camera_calibration.launch

          使用后,输出没有什么实际变化
          
          5.上列已回,有数据,且与脚本对的上
          
          6.rospy.loginfo()没有被打印出来
          
          7.8.
          路径为/opt/ros/noetic/lib/camera_calibration/cameracalibrator.py 脚本如下
          

          import cv2
          import functools
          import message_filters
          import rospy
          from camera_calibration.camera_calibrator import OpenCVCalibrationNode
          from camera_calibration.calibrator import ChessboardInfo, Patterns
          from message_filters import ApproximateTimeSynchronizer

          def optionsValidCharuco(options, parser):
          """
          Validates the provided options when the pattern type is 'charuco'
          """
          if options.pattern != 'charuco': return False

          n_boards = len(options.size)
          if (n_boards != len(options.square) or n_boards != len(options.charuco_marker_size) or n_boards !=
                  len(options.aruco_dict)):
              parser.error("When using ChArUco boards, --size, --square, --charuco_marker_size, and --aruco_dict " +
              "must be specified for each board")
              return False
          
          # TODO: check for fisheye and stereo (not implemented with ChArUco)
          return True
          

          def main():
          from optparse import OptionParser, OptionGroup
          rospy.loginfo("start camera_calibration")
          parser = OptionParser("%prog --size SIZE1 --square SQUARE1 [ --size SIZE2 --square SQUARE2 ]",
          description=None)
          parser.add_option("-c", "--camera_name",
          type="string", default='narrow_stereo',
          help="name of the camera to appear in the calibration file")
          group = OptionGroup(parser, "Chessboard Options",
          "You must specify one or more chessboards as pairs of --size and --square options.")
          group.add_option("-p", "--pattern",
          type="string", default="chessboard",
          help="calibration pattern to detect - 'chessboard', 'circles', 'acircles', 'charuco'\n" +
          " if 'charuco' is used, a --charuco_marker_size and --aruco_dict argument must be supplied\n" +
          " with each --size and --square argument")
          group.add_option("-s", "--size",
          action="append", default=[],
          help="chessboard size as NxM, counting interior corners (e.g. a standard chessboard is 7x7)")
          group.add_option("-q", "--square",
          action="append", default=[],
          help="chessboard square size in meters")
          group.add_option("-m", "--charuco_marker_size",
          action="append", default=[],
          help="ArUco marker size (meters); only valid with -p charuco")
          group.add_option("-d", "--aruco_dict",
          action="append", default=[],
          help="ArUco marker dictionary; only valid with -p charuco; one of 'aruco_orig', '4x4_250', " +
          "'5x5_250', '6x6_250', '7x7_250'")
          parser.add_option_group(group)
          group = OptionGroup(parser, "ROS Communication Options")
          group.add_option("--approximate",
          type="float", default=0.0,
          help="allow specified slop (in seconds) when pairing images from unsynchronized stereo cameras")
          group.add_option("--no-service-check",
          action="store_false", dest="service_check", default=True,
          help="disable check for set_camera_info services at startup")
          group.add_option("--queue-size",
          type="int", default=1,
          help="image queue size (default %default, set to 0 for unlimited)")
          parser.add_option_group(group)
          group = OptionGroup(parser, "Calibration Optimizer Options")
          group.add_option("--fix-principal-point",
          action="store_true", default=False,
          help="for pinhole, fix the principal point at the image center")
          group.add_option("--fix-aspect-ratio",
          action="store_true", default=False,
          help="for pinhole, enforce focal lengths (fx, fy) are equal")
          group.add_option("--zero-tangent-dist",
          action="store_true", default=False,
          help="for pinhole, set tangential distortion coefficients (p1, p2) to zero")
          group.add_option("-k", "--k-coefficients",
          type="int", default=2, metavar="NUM_COEFFS",
          help="for pinhole, number of radial distortion coefficients to use (up to 6, default %default)")

          group.add_option("--fisheye-recompute-extrinsicsts",
                           action="store_true", default=False,
                           help="for fisheye, extrinsic will be recomputed after each iteration of intrinsic optimization")
          group.add_option("--fisheye-fix-skew",
                           action="store_true", default=False,
                           help="for fisheye, skew coefficient (alpha) is set to zero and stay zero")
          group.add_option("--fisheye-fix-principal-point",
                           action="store_true", default=False,
                           help="for fisheye,fix the principal point at the image center")
          group.add_option("--fisheye-k-coefficients",
                           type="int", default=4, metavar="NUM_COEFFS",
                           help="for fisheye, number of radial distortion coefficients to use fixing to zero the rest (up to 4, default %default)")
          
          group.add_option("--fisheye-check-conditions",
                           action="store_true", default=False,
                           help="for fisheye, the functions will check validity of condition number")
          
          group.add_option("--disable_calib_cb_fast_check", action='store_true', default=False,
                           help="uses the CALIB_CB_FAST_CHECK flag for findChessboardCorners")
          group.add_option("--max-chessboard-speed", type="float", default=-1.0,
                           help="Do not use samples where the calibration pattern is moving faster \
                           than this speed in px/frame. Set to eg. 0.5 for rolling shutter cameras.")
          
          parser.add_option_group(group)
          
          options, args = parser.parse_args()
          
          if (len(options.size) != len(options.square)):
              parser.error("Number of size and square inputs must be the same!")
          
          if not options.square:
              options.square.append("0.108")
              options.size.append("8x6")
          
          boards = []
          if options.pattern == "charuco" and optionsValidCharuco(options, parser):
              for (sz, sq, ms, ad) in zip(options.size, options.square, options.charuco_marker_size, options.aruco_dict):
                  size = tuple([int(c) for c in sz.split('x')])
                  boards.append(ChessboardInfo('charuco', size[0], size[1], float(sq), float(ms), ad))
          else:
              for (sz, sq) in zip(options.size, options.square):
                  size = tuple([int(c) for c in sz.split('x')])
                  boards.append(ChessboardInfo(options.pattern, size[0], size[1], float(sq)))
          
          if options.approximate == 0.0:
              sync = message_filters.TimeSynchronizer
          else:
              sync = functools.partial(ApproximateTimeSynchronizer, slop=options.approximate)
          
          # Pinhole opencv calibration options parsing
          num_ks = options.k_coefficients
          
          calib_flags = 0
          if options.fix_principal_point:
              calib_flags |= cv2.CALIB_FIX_PRINCIPAL_POINT
          if options.fix_aspect_ratio:
              calib_flags |= cv2.CALIB_FIX_ASPECT_RATIO
          if options.zero_tangent_dist:
              calib_flags |= cv2.CALIB_ZERO_TANGENT_DIST
          if (num_ks > 3):
              calib_flags |= cv2.CALIB_RATIONAL_MODEL
          if (num_ks < 6):
              calib_flags |= cv2.CALIB_FIX_K6
          if (num_ks < 5):
              calib_flags |= cv2.CALIB_FIX_K5
          if (num_ks < 4):
              calib_flags |= cv2.CALIB_FIX_K4
          if (num_ks < 3):
              calib_flags |= cv2.CALIB_FIX_K3
          if (num_ks < 2):
              calib_flags |= cv2.CALIB_FIX_K2
          if (num_ks < 1):
              calib_flags |= cv2.CALIB_FIX_K1
          
          # Opencv calibration flags parsing:
          num_ks = options.fisheye_k_coefficients
          fisheye_calib_flags = 0
          if options.fisheye_fix_principal_point:
              fisheye_calib_flags |= cv2.fisheye.CALIB_FIX_PRINCIPAL_POINT
          if options.fisheye_fix_skew:
              fisheye_calib_flags |= cv2.fisheye.CALIB_FIX_SKEW
          if options.fisheye_recompute_extrinsicsts:
              fisheye_calib_flags |= cv2.fisheye.CALIB_RECOMPUTE_EXTRINSIC
          if options.fisheye_check_conditions:
              fisheye_calib_flags |= cv2.fisheye.CALIB_CHECK_COND
          if (num_ks < 4):
              fisheye_calib_flags |= cv2.fisheye.CALIB_FIX_K4
          if (num_ks < 3):
              fisheye_calib_flags |= cv2.fisheye.CALIB_FIX_K3
          if (num_ks < 2):
              fisheye_calib_flags |= cv2.fisheye.CALIB_FIX_K2
          if (num_ks < 1):
              fisheye_calib_flags |= cv2.fisheye.CALIB_FIX_K1
          
          pattern = Patterns.Chessboard
          if options.pattern == 'circles':
              pattern = Patterns.Circles
          elif options.pattern == 'acircles':
              pattern = Patterns.ACircles
          elif options.pattern == 'charuco':
              pattern = Patterns.ChArUco
          elif options.pattern != 'chessboard':
              print('Unrecognized pattern %s, defaulting to chessboard' % options.pattern)
          
          if options.disable_calib_cb_fast_check:
              checkerboard_flags = 0
          else:
              checkerboard_flags = cv2.CALIB_CB_FAST_CHECK
          
          rospy.init_node('cameracalibrator')
          node = OpenCVCalibrationNode(boards, options.service_check, sync, calib_flags, fisheye_calib_flags, pattern, options.camera_name,
                                       checkerboard_flags=checkerboard_flags, max_chessboard_speed=options.max_chessboard_speed,
                                       queue_size=options.queue_size)
          rospy.spin()
          

          if name == "main":
          try:
          main()
          except Exception as e:
          import traceback
          traceback.print_exc()

          1 条回复 最后回复 回复 引用 0
          • 小伊小
            机器人小伊
            最后由 编辑

            从您提供的描述和代码中,有几个可能的原因导致 cameracalibrator.py 脚本的节点无法正确启动或接收数据,并且 rospy.loginfo() 没有被打印出来。下面是一些排查和解决这些问题的步骤:

            1. 检查 ROS 节点启动

            首先确保 cameracalibrator.py 脚本确实被 ROS 正确地启动了。您可以通过以下命令检查正在运行的节点:

            rosnode list
            

            查看列表中是否有 cameracalibrator 节点。

            2. 检查日志输出

            如果节点已经启动,但 rospy.loginfo() 没有输出,可能是日志级别设置的问题。您可以尝试设置 ROS 的日志级别为 DEBUG 来查看更多信息:

            export ROSCONSOLE_CONFIG_FILE=/dev/null
            roscore &
            rosrun rqt_logger_level rqt_logger_level
            

            在 rqt_logger_level 中,找到 cameracalibrator 节点,并将其日志级别设置为 DEBUG。

            3. 检查脚本参数

            cameracalibrator.py 脚本需要一些命令行参数来运行,比如 --size 和 --square。确保这些参数在您的 camera_calibration.launch 文件中被正确设置并传递给脚本。例如:

            <node name="cameracalibrator" pkg="camera_calibration" type="cameracalibrator.py" output="screen"
                  args="--size 8x6 --square 0.108 --camera_name=narrow_stereo"/>
            

            4. 检查 ROS 话题和消息类型

            确保您的摄像头或其他传感器发布的话题和消息类型与 cameracalibrator.py 脚本所期望的相匹配。您可以使用 rostopic list 和 rostopic info <topic_name> 来检查话题的发布者和订阅者以及消息类型。

            5. 检查依赖项

            确保所有依赖的库(如 cv2、rospy、message_filters 等)都已正确安装,并且版本兼容。

            6. 检查 ROS 环境

            有时 ROS 环境的问题(如路径问题、权限问题等)也可能导致节点无法正确启动。尝试在一个干净的 ROS 环境中重新构建和运行您的项目。

            7. 代码中的错误

            您的代码中有一个潜在的错误:

            if name == "main":
                try:
                    main()
                except Exception as e:
                    import traceback
                    traceback.print_exc()
            

            这里 name 变量没有在之前的代码中定义,它应该是 __name__。所以,这行代码应该是:

            if __name__ == "__main__":
                try:
                    main()
                except Exception as e:
                    import traceback
                    traceback.print_exc()
            

            8. 使用 roslaunch 检查

            如果 camera_calibration.launch 文件没有显示任何错误,但节点仍然不工作,尝试在命令行中直接运行 cameracalibrator.py 脚本,并带上适当的参数,看看是否能成功启动。

            9. 查看系统日志

            有时系统日志(如 /var/log/syslog 或 /var/log/messages)中可能包含有关 ROS 节点启动失败的更多信息。

            通过以上步骤,您应该能够诊断出问题的原因,并采取相应的措施来解决问题。


            以上为生成回答,仅供参考~

            我是小伊,已接入ChatGpt,所有回复,仅供参考~

            1 条回复 最后回复 回复 引用 0
            • 第一个帖子
              最后一个帖子
            皖ICP备16016415号-7
            Powered by NodeBB | 鱼香ROS