• ch4 报错修正 & Sophus使用


    ch4 报错& 修正

    (1)

    # 添加Eigen头文件
    include_directories( "/usr/include/eigen3" )
    
    • 1
    • 2

    (2)

    #include "sophus/so3.hpp"
    #include "sophus/se3.hpp"
    
    • 1
    • 2

    (3)
    请添加图片描述

    大量报错但都与SO3,SE3有关

    error: missing template arguments before ‘SO3_R’ error: ‘SO3_R’ was not declared in this scope
    error: missing template arguments before‘SO3_updated’
    error: ‘template classSophus::SE3’ used without template arguments

    SO3这种数据类型应该是不存在的,可以声明为Sophus::SO3d 或者 Sophus::SO3.
    SE3同理

    (4)

    error: no matching function for call to ‘Sophus::SO3::SO3(int, int, double)’

    Sophus::SO3d SO3_v( 0, 0, M_PI/2 );  // 亦可从旋转向量构造
    
    • 1

    似乎是这种构造方式没有了

    (5)

    cout<<"SO(3) from matrix: "<<SO3_R<<endl;
    
    • 1

    上面这个代码

    error: no match for ‘operator<<(operand types are ‘std::basic_ostream<char>and ‘Sophus::SO3d’ {aka ‘Sophus::SO3<double>})
    
    • 1

    修改成:

    cout<<"SO(3) from matrix: "<<SO3_R.log()<<endl;
    
    • 1

    总之<之类的全部加上.log()即可,输出SO(3)时,以so(3)形式输出

    (6)
    请添加图片描述

    CMakeLists.txt加入

    target_link_libraries( useSophus ${Sophus_LIBRARIES} fmt)
    
    • 1

    应该要放到add_executable( useSophus useSophus.cpp )后面不然会报这种错

    CMake Error at CMakeLists.txt:4 (target_link_libraries):
    Cannot specify link libraries for target “useSophus” which is not built by
    this project.

    Sophus使用

    ch4代码可以学习这篇,重复的内容、就不写了
    在CMakeLists.txt中

    # 为使用 sophus,您需要使用find_package命令找到它
    find_package( Sophus REQUIRED )
    include_directories( ${Sophus_INCLUDE_DIRS} )
    target_link_libraries( 程序名 ${Sophus_LIBRARIES} fmt)
    
    • 1
    • 2
    • 3
    • 4

    1.hat 为向量到反对称矩阵

    Sophus::SO3d::hat(so3)
    
    • 1

    2.vee为反对称到向量

    Sophus::SO3d::vee( Sophus::SO3d::hat(so3) )
    
    • 1

    3.增量扰动模型的更新

    Eigen::Vector3d update_so3(1e-4, 0, 0); //假设更新量为这么多
    Sophus::SO3d SO3_updated = Sophus::SO3d::exp(update_so3)*SO3_R;
    
    • 1
    • 2
  • 相关阅读:
    RabbitMQ 和 Kafka有什么异同?
    「实战应用」如何用DHTMLX将上下文菜单集成到JavaScript甘特图中(一)
    spy最新安装教程!!青龙+spy,东东豆豆多)
    体验下,大厂在使用功能的API网关!
    SpringSecurity认证流程
    Matlab 基础与应用
    音视频技术开发周刊 | 309
    思维导图软件 Xmind mac中文版特点介绍
    【云岚到家】-day03-2-门户缓存实现实战
    2024年最新 CKA 试题题库及答案详解 导航页
  • 原文地址:https://blog.csdn.net/weixin_50862344/article/details/126633519