CeresSolver采用稀疏矩阵求解大规模BA时参数块设定

2023-05-16

CeresSolver采用稀疏矩阵求解大规模BA时参数块设定

前言

在大规模BA求解中,通常会关注到相机位姿与路标参数构成矩阵的稀疏性,将相机位姿参数与路标点参数分组,采用舒尔补充等方法进行消元求解数据量大的组别,提升求解效率,具体可以参考ceres的LinearSolver¶部分。

在实际使用中,构造代价函数时需明确哪些参数为路标点参数,需要被消去;哪些参数为相机参数,首先求解,相当于将参数分组,并决定其消去的顺序。ceres内置了自动分组的方法,但有时不能奏效,此时就需要我们手工指定参数块的分组,并且来决定参数被消去的顺序。

CeresSolver教程相关说明

Ordering

The order in which variables are eliminated in a linear solver can have a significant of impact on the efficiency and accuracy of the method. For example when doing sparse Cholesky factorization, there are matrices for which a good ordering will give a Cholesky factor with O(n) storage, where as a bad ordering will result in an completely dense factor.

线性解算器中变量的消除顺序对方法的效率和准确性有重大影响。例如,在进行稀疏Cholesky分解时,对于某些矩阵,良好的排序将给出具有O(n)存储的Cholesky因子,而糟糕的排序将导致完全稠密因子。

Ceres allows the user to provide varying amounts of hints to the solver about the variable elimination ordering to use. This can range from no hints, where the solver is free to decide the best ordering based on the user’s choices like the linear solver being used, to an exact order in which the variables should be eliminated, and a variety of possibilities in between.

Ceres允许用户向解算器提供不同数量的关于变量消除顺序使用的提示。这可能包括从没有提示,解算器可以根据用户的选择(如使用的线性解算器)自由决定最佳顺序,到消除变量的确切顺序,以及介于两者之间的各种可能性。

Instances of the ParameterBlockOrdering class are used to communicate this information to Ceres.

[ParameterBlockOrdering]的实例类用于将此信息传达给Ceres。

Formally an ordering is an ordered partitioning of the parameter blocks. Each parameter block belongs to exactly one group, and each group has a unique integer associated with it, that determines its order in the set of groups. We call these groups Elimination Groups

形式上,排序是参数块的有序划分。每个参数块只属于一个组,每个组都有一个与之关联的唯一整数,该整数决定了它在组集中的顺序。我们称之为消除组*

Given such an ordering, Ceres ensures that the parameter blocks in the lowest numbered elimination group are eliminated first, and then the parameter blocks in the next lowest numbered elimination group and so on. Within each elimination group, Ceres is free to order the parameter blocks as it chooses. For example, consider the linear system

给定这样的顺序,Ceres确保首先消除编号最低的消除组中的参数块,然后消除下一个编号最低的消除组中的参数块,依此类推。在每个消除组中,Ceres可以根据自己的选择自由排列参数块。例如,考虑线性系统
x + y = 3 2 x + 3 y = 7 x+y=3\\ 2x+3y=7 x+y=32x+3y=7
There are two ways in which it can be solved. First eliminating x from the two equations, solving for y and then back substituting for x, or first eliminating y, solving for x and back substituting for y. The user can construct three orderings here.

有两种方法可以解决这个问题。首先从两个方程中消除x,解出y,然后反代x,或者先消除y,解出x,反代y。用户可以在这里构造三个排序s。

  1. {0:x},{1:y} : Eliminate x first.
  2. {0:y},{1:x} : Eliminate y first.
  3. {0:x,y} : Solver gets to decide the elimination order.

Thus, to have Ceres determine the ordering automatically using heuristics, put all the variables in the same elimination group. The identity of the group does not matter. This is the same as not specifying an ordering at all. To control the ordering for every variable, create an elimination group per variable, ordering them in the desired order.

因此,为了让Ceres使用启发法自动确定排序,将所有变量放在同一个消除组中。团体的身份无关紧要。这与根本不指定排序相同。要控制每个变量的顺序,请为每个变量创建一个消除组,并按所需顺序对它们进行排序。

If the user is using one of the Schur solvers (DENSE_SCHUR, SPARSE_SCHUR, ITERATIVE_SCHUR) and chooses to specify an ordering, it must have one important property. The lowest numbered elimination group must form an independent set in the graph corresponding to the Hessian, or in other words, no two parameter blocks in in the first elimination group should co-occur in the same residual block. For the best performance, this elimination group should be as large as possible. For standard bundle adjustment problems, this corresponds to the first elimination group containing all the 3d points, and the second containing the all the cameras parameter blocks.

如果用户正在使用一个舒尔解算器(“稠密舒尔”、“稀疏舒尔”、“迭代舒尔”),并选择指定排序,则它必须具有一个重要属性。编号最低的消除组必须在对应于Hessian的图中形成一个独立集,或者换句话说,第一个消除组中的两个参数块不应同时出现在同一个剩余块中。为了获得最佳性能,该淘汰组应尽可能大。对于标准束调整问题,这对应于包含所有3d点的第一个消除组,以及包含所有摄影机参数块的第二个消除组。

If the user leaves the choice to Ceres, then the solver uses an approximate maximum independent set algorithm to identify the first elimination group [LiSaad].

如果用户将选择权留给Ceres,则解算器使用近似最大独立集算法来识别第一个消除组[LiSaad].

CeresSolver中对应类的实现

ParameterBlockOrdering

  • class ParameterBlockOrdering

    ParameterBlockOrdering is a class for storing and manipulating an ordered collection of groups/sets with the following semantics:Group IDs are non-negative integer values. Elements are any type that can serve as a key in a map or an element of a set.An element can only belong to one group at a time. A group may contain an arbitrary number of elements.Groups are ordered by their group id.

    ParameterBlockOrdering是一个用于存储和操作有序的组/集集合的类,具有以下语义:组ID是非负整数值。元素是可以作为地图中的键或集合中的元素的任何类型。一个元素一次只能属于一个组。一个组可以包含任意数量的元素。组按其组id排序。

  • bool ParameterBlockOrdering::AddElementToGroup(const double *element, const int group)¶

    Add an element to a group. If a group with this id does not exist, one is created. This method can be called any number of times for the same element. Group ids should be non-negative numbers. Return value indicates if adding the element was a success.

    向组中添加元素。如果不存在具有此id的组,则会创建一个组。对于同一个元素,可以多次调用此方法。组ID应该是非负数。返回值指示添加元素是否成功。

  • void ParameterBlockOrdering::Clear()¶

    Clear the ordering.

    清除命令

  • bool ParameterBlockOrdering::Remove(const double *element)¶

    Remove the element, no matter what group it is in. If the element is not a member of any group, calling this method will result in a crash. Return value indicates if the element was actually removed.

    移除该元素,无论它在哪个组中。如果元素不是任何组的成员,调用此方法将导致崩溃。返回值指示元素是否已实际删除。

  • void ParameterBlockOrdering::Reverse()¶

    Reverse the order of the groups in place.

    颠倒分组顺序。

  • int ParameterBlockOrdering::GroupId(const double *element) const

    Return the group id for the element. If the element is not a member of any group, return -1.

    返回元素的组id。如果元素不是任何组的成员,则返回-1。

  • bool ParameterBlockOrdering::IsMember(const double *element) const

    True if there is a group containing the parameter block.

    如果存在包含参数块的组,则为True。

  • int ParameterBlockOrdering::GroupSize(const int group) const

    This function always succeeds, i.e., implicitly there exists a group for every integer.

    这个函数总是成功的,也就是说,每个整数隐式地存在一个组。

  • int ParameterBlockOrdering::NumElements() const

    Number of elements in the ordering.

    排序中的元素数。

  • int ParameterBlockOrdering::NumGroups() const

    Number of groups with one or more elements.

    包含一个或多个元素的组数。

代码实战

ceres::ParameterBlockOrdering* ordering = new ceres::ParameterBlockOrdering();
 
// set all points in ordering to 0
for(int i = 0; i < num_points; i++){
    ordering->AddElementToGroup(points + i * point_block_size, 0);
}
// set all cameras in ordering to 1
for(int i = 0; i < num_cameras; i++){
    ordering->AddElementToGroup(cameras + i * camera_block_size, 1);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

CeresSolver采用稀疏矩阵求解大规模BA时参数块设定 的相关文章

  • pod、container、sidecar

    pod是一个小家庭 xff0c 它把密不可分的家庭成员 container 聚在一起 xff0c Infra container则是家长 xff0c 掌管家中共通资源 xff0c 解决顺序和依赖关系 xff0c 家庭成员通过sidecar方
  • 4种SQL标准的事务隔离级别

    SQL标准的事务隔离级别包括 xff1a 读未提交 xff08 read uncommitted xff09 xff1a 一个事务还没提交时 xff0c 它做的变更就能被别的事务看到 读提交 xff08 read committed xff
  • 设计容器网络插件的初步思路

    同一个 Pod 里面的所有用户容器的进出流量 xff0c 可以认为都是通过 Infra 容器完成的 当为Kubernetes 开发一个网络插件时 xff0c 应该重点考虑的是如何配置这个 Pod 的 Network Namespace xf
  • 各种显示接口DBI、DPI、LTDC、DSI、FSMC

    各种显示接口DBI DPI LTDC DSI FSMC qq 23899395 2019 06 05 17 30 36 4810 收藏 36 版权 首先 xff0c MIPI xff08 Mobile Industry Processor
  • 在ubuntu 16.04安装ROS Kinetic

    ubuntu16 04 已经发布一个月了 xff0c ROS的Kinetic也已经发布 xff0c 需要了解ROS发行版及支持维护的时间等 xff0c 可以参考如下网页 xff1a http wiki ros org Distributio
  • ROS创建工作空间和功能包

    所有的ROS程序 xff0c 包括我们自己开发的程序 xff0c 都被组织成功能包 xff0c 而ROS的功能包被存放在称之为工作空间的目录下 因此 xff0c 在我们写程序之前 xff0c 第一步是创建一个工作空间以容纳我们的功能包 1
  • MPU-6000(6050)介绍

    MPU 6000 xff08 6050 xff09 简介 MPU 60X0是全球首例9 轴运动处理传感器 它集成了3 轴MEMS陀螺仪 xff0c 3 轴MEMS加速度计 xff0c 以及一个可扩展的数字运动处理器DMP xff08 Dig
  • lwip/uip移植之一

    最近一直想移植一个tcp ip协议栈到板子上 xff0c 于是想到了lwip和uip lwip是一个比较完整的协议栈 xff0c 功能强大 xff0c 结合ucos系统更是方便完美 xff0c 但是需要几十k的ram xff0c 这点在我f
  • Nvidia Xavier GPIO 输入输出 中断 PWM

    文章目录 前言Jetson GPIO安装可用引脚点亮LEDGPIO输出示例GPIO输入示例GPIO EventGPIO InterruptPWM微信公众号 前言 Nvidia Jetson AGX Xavier 硬件相关 这篇讲到Xavie
  • Jetson Xavier/XavierNX/TX2 CANFD 配置使用

    目录 TX2 Xavier NX Xavier CAN特性TX2 Xavier NX Xavier 载板引出位置CAN收发器NVIDIA CAN DriverXavier CAN 引脚配置Jetson CAN 设置设置开机运行查看连接状态C
  • Altium Designer使用Git构想

    今天看了dtysky的 体三维显示器 PCB部分 LED阵列 用脚本写的上万个LED的自动布局和自动布线 很震惊 很欣赏 很喜欢 或许有很多我们可以想象的空间 这篇主要写Git Git主要管理文本文件 二进制文件却不大合适 尽管有 使用 G
  • 如何拿到阿里offer的?面试流程及面试题

    一个偶然的开始 交待一下 非广告 xff0c 第一次用拉勾 xff0c 感觉做的挺好 xff0c 以前一直用51job 从7月分开始 xff0c 打算找工作 xff0c 一个偶然的机会 xff0c 拉勾上一个蚂蚁金服的同学找到我 xff0c
  • STM32和Linux(转载)

    Linux和stm32 一个是软件平台一个是硬件平台 xff0c 完全不一样的 xff08 记住 xff0c 是平台 xff01 xff09 这样说吧 xff0c 既然你喜欢单片机 xff0c 就先学stm32 xff0c 把硬件基础打牢
  • PX4飞控问题之参数重置问题

    PX4在上电的时候会出现参数重置的问题 xff0c 出现这个问题的机率很小 xff0c 可能上电几千甚至上万次才会出现一次重置的情况 xff0c 但一旦出现了参数重置 xff0c 飞机就无法飞行 xff0c 得重新校准传感器 要解决这个问题
  • STM32硬件基础--LTDC显示图像

    STM32硬件基础 LTDC显示图像 海东青电子 2019 11 13 23 40 05字数 2 635阅读 3 102 海东青电子原创文章 xff0c 转载请注明出处 xff1a https www jianshu com p 21638
  • PX4轨迹生成公式推导

    PX4轨迹生成公式推导下载链接 对于多旋翼 飞行任务的时候 通过地面站画出航点 上传给飞控 飞控通过轨迹生成算法生成平滑的目标位置 速度及加速度 给位置控制模块控制飞机的位置 速度及加速度 PX4轨迹生成的方法为 约束加加速度的S型速度曲线
  • 植保无人机航线规划

    最近折腾了植保无人机航线规划的算法 支持任意多边形 不包括自相交多边形 的边界及障碍区域 其中涉及到了多边形内缩外扩 多边形的分解 多边形交集 并集 差集 深度优先搜索 最短路径算法 耗时两个多月 用C 实现整套算法 生成的库在missio
  • 现代控制工程笔记(一)控制系统的状态空间描述

    文章目录 1 基本概念2 系统的状态空间描述状态空间描述框图状态变量选取的非唯一性 3 由系统微分方程列写状态空间表达式一 微分方程中不包含输入函数的导数项相变量法其他方法 xff1a 二 微分方程中包含输入函数的导数项 4 由传递函数列写
  • 百度Apollo 2.0 车辆控制算法之LQR控制算法解读

    百度Apollo 2 0 车辆控制算法之LQR控制算法解读 Apollo 中横向控制的LQR控制算法在Latcontroller cc 中实现 根据车辆的二自由度动力学模型 1 根据魔术公式在小角度偏角的情况下有 轮胎的侧向力与轮胎的偏离角
  • 多传感器融合--MATLAB跟踪器介绍

    多传感器融合 MATLAB跟踪器介绍 MATLAB通过多目标跟踪器可以融合多传感器检测到的目标信息 xff0c 常用到的多目标跟踪器有trackerGNN trackerJPDA trackerTOMHT trackerPHD等 track

随机推荐