slam第六讲

znkz@znkz:~/下载/ceres-solver-master/build$ cmake ..
CMake Error at CMakeLists.txt:32 (cmake_minimum_required):
  CMake 3.5 or higher is required.  You are running version 2.8.12.2

 

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:george-edison55/cmake-3.x
sudo apt-get update

错误:

正在读取软件包列表... 完成
W: GPG 错误:http://dl.google.com stable Release: 由于没有公钥,无法验证下列签名: NO_PUBKEY 6494C6D6997C215E
W: 校验签名出错。此仓库未被更新,仍然使用以前的索引文件。GPG 错误:http://dl.google.com stable Release: 由于没有公钥,无法验证下列签名: NO_PUBKEY 6494C6D6997C215E

W: 无法下载 http://dl.google.com/linux/deb/dists/stable/Release  

由第三方提供的软件源可在软件更新——其它软件中查看,可删除不能用的软件源

sudo apt-get upgrade
znkz@znkz:~/下载$ cmake --version
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/bin
段错误 (核心已转储)

再执行一步:

sudo apt-get install cmake
znkz@znkz:~/下载$ cmake --version
cmake version 3.2.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

https://blog.csdn.net/lixiaogang_theanswer/article/details/73693004#commentBox

https://blog.csdn.net/love1055259415/article/details/79875113#commentBox

 

失败尝试:

znkz@znkz:~/下载$ cmake --version
cmake version 2.8.12.2

 

znkz@znkz:~/下载$ sudo apt-get autoremove cmake

会卸载原来的软件包

下列软件包将被【卸载】:
  account-plugin-windows-live cmake collada-dom-dev collada-dom2.4-dp-base
  collada-dom2.4-dp-dev dkms empathy-common evemu-tools evtest festival
  festlex-cmu festlex-poslex festvox-kallpc16k fltk1.3-doc fluid folks-common
  gazebo2 gstreamer0.10-nice gstreamer0.10-plugins-good gstreamer0.10-x
  gstreamer1.0-nice hddtemp joystick liballegro4.4 liballegro4.4-plugin-alsa
  libandroid-properties1 libapr1-dev libaprutil1-dev libasound2-dev
  libassimp-dev libassimp3 libavahi-client-dev libavahi-common-dev
  libavahi-core-dev libavahi-gobject0 libbz2-dev libcaca-dev
  libcegui-mk2-0.7.6 libcegui-mk2-dev libcppunit-1.13-0 libcppunit-dev
  libcurl4-openssl-dev libcwiid1 libdbus-1-dev libdevil-dev libdevil1c2
  libestools2.1 libevemu1 libfarstream-0.1-0 libfarstream-0.2-2
  libfltk-cairo1.3 libfltk-forms1.3 libfltk-gl1.3 libfltk-images1.3 libfltk1.1
  libfltk1.3 libfltk1.3-dev libfolks-eds25 libfolks25 libfreeimage-dev
  libfreeimage3 libgcrypt11-dev libgeos-3.4.2 libgeos-c1 libgnomecanvas2-0
  libgnomecanvas2-common libgnutls-dev libgnutlsxx27 libgoogle-perftools4
  libgpg-error-dev libgsl0-dev libgsl0ldbl libgupnp-igd-1.0-4 libidn11-dev
  libjemalloc1 libkrb5-dev liblcms1 liblcms1-dev liblcms2-dev libldap2-dev
  liblodo3.0 liblog4cxx10 liblog4cxx10-dev liblua5.1-0 liblua5.1-0-dev
  liblz4-1 liblz4-dev libmeanwhile1 libmng-dev libmng2 libnice10 libodbc1
  libogre-1.8-dev libogre-1.8.0 libois-1.3.0 libopenni2-0 libopenni2-dev
  liboxideqt-qmlplugin liboxideqtcore0 liboxideqtquick0 libp11-kit-dev
  libplayerc++3.0 libplayerc3.0 libplayercommon3.0 libplayercore3.0
  libplayerdrivers3.0 libplayerinterface3.0 libplayerjpeg3.0 libplayertcp3.0
  libplayerwkb3.0 libpmap3.0 libpoco-dev libpococrypto9 libpocodata9
  libpocofoundation9 libpocomysql9 libpoconet9 libpoconetssl9 libpocoodbc9
  libpocosqlite9 libpocoutil9 libpocoxml9 libpocozip9 libprotobuf-dev
  libprotobuf-lite8 libprotoc8 libpulse-dev libpurple-bin libpurple0
  libpyside-dev libpyside-py3-1.2 libpyside1.2 libqt5webkit5-qmlwebkitplugin
  libqwt-dev libqwt5-qt4 libqwt6 libreadline-dev libreadline6-dev librtmp-dev
  libsctp-dev libsdformat-dev libsdformat1 libsdl-image1.2 libsdl-image1.2-dev
  libsdl1.2-dev libsdl1.2debian libshiboken-dev libshiboken-py3-1.2
  libshiboken1.2 libsilly libslang2-dev libsnappy1 libspnav-dev libspnav0
  libstatgrab9 libtar0 libtasn1-6-dev libtcmalloc-minimal4 libtinfo-dev
  libtinyxml-dev libufe-xidgetter0 liburdfdom-dev liburdfdom-headers-dev
  liburdfdom-model-state0.2 liburdfdom-model0.2 liburdfdom-sensor0.2
  liburdfdom-world0.2 libv8-3.14.5 libvtk-java libwebp-dev libwebpdemux1
  libxaw7-dev libxerces-c3.1 libxmu-dev libxmu-headers libxpm-dev
  libyaml-cpp-dev libyaml-cpp0.5 libzephyr4 libzzip-0-13 libzzip-dev
  linux-headers-3.13.0-158 linux-headers-3.13.0-158-generic
  linux-headers-generic mongodb mongodb-clients mongodb-dev mongodb-server
  python-bluez python-bson python-bson-ext python-cwiid python-empy
  python-gridfs python-gst0.10 python-matplotlib python-matplotlib-data
  python-netifaces python-opengl python-psutil python-pydot python-pymongo
  python-pymongo-ext python-pyside python-pyside.phonon python-pyside.qtcore
  python-pyside.qtdeclarative python-pyside.qtgui python-pyside.qthelp
  python-pyside.qtnetwork python-pyside.qtopengl python-pyside.qtscript
  python-pyside.qtsql python-pyside.qtsvg python-pyside.qttest
  python-pyside.qtuitools python-pyside.qtwebkit python-pyside.qtxml
  python-qt4-dev python-qt4-gl python-qwt5-qt4 python-rosdep python-sip-dev
  python-support python-tz python-vtk python-zeitgeist
  qtdeclarative5-accounts-plugin qtdeclarative5-dialogs-plugin
  qtdeclarative5-privatewidgets-plugin
  qtdeclarative5-ubuntu-ui-extras-browser-plugin
  qtdeclarative5-ubuntu-ui-extras-browser-plugin-assets redis-server
  redis-tools robot-player ros-indigo-actionlib ros-indigo-actionlib-msgs
  ros-indigo-actionlib-tutorials ros-indigo-amcl ros-indigo-angles
  ros-indigo-ar-track-alvar ros-indigo-arbotix ros-indigo-arbotix-controllers
  ros-indigo-arbotix-python ros-indigo-arbotix-sensors ros-indigo-astra-camera
  ros-indigo-astra-launch ros-indigo-audio-capture ros-indigo-audio-common
  ros-indigo-audio-common-msgs ros-indigo-audio-play
  ros-indigo-base-local-planner ros-indigo-bfl ros-indigo-bond
  ros-indigo-bond-core ros-indigo-bondcpp ros-indigo-bondpy
  ros-indigo-calibration-msgs ros-indigo-camera-calibration
  ros-indigo-camera-calibration-parsers ros-indigo-camera-info-manager
  ros-indigo-capabilities ros-indigo-carrot-planner ros-indigo-catkin
  ros-indigo-class-loader ros-indigo-clear-costmap-recovery
  ros-indigo-cmake-modules ros-indigo-collada-parser ros-indigo-collada-urdf
  ros-indigo-common-msgs ros-indigo-common-tutorials
  ros-indigo-compressed-depth-image-transport
  ros-indigo-compressed-image-transport ros-indigo-control-msgs
  ros-indigo-costmap-2d ros-indigo-create-dashboard
  ros-indigo-create-description ros-indigo-create-driver
  ros-indigo-create-gazebo-plugins ros-indigo-create-node ros-indigo-csm
  ros-indigo-cv-bridge ros-indigo-depth-image-proc
  ros-indigo-depthimage-to-laserscan ros-indigo-desktop
  ros-indigo-desktop-full ros-indigo-diagnostic-aggregator
  ros-indigo-diagnostic-analysis ros-indigo-diagnostic-common-diagnostics
  ros-indigo-diagnostic-msgs ros-indigo-diagnostic-updater
  ros-indigo-diagnostics ros-indigo-driver-base ros-indigo-dwa-local-planner
  ros-indigo-dynamic-reconfigure ros-indigo-dynamixel-controllers
  ros-indigo-dynamixel-driver ros-indigo-dynamixel-motor
  ros-indigo-dynamixel-msgs ros-indigo-dynamixel-tutorials
  ros-indigo-ecl-streams ros-indigo-eigen-conversions
  ros-indigo-eigen-stl-containers ros-indigo-executive-smach
  ros-indigo-fake-localization ros-indigo-filters ros-indigo-freenect-camera
  ros-indigo-freenect-launch ros-indigo-freenect-stack ros-indigo-gateway-msgs
  ros-indigo-gazebo-msgs ros-indigo-gazebo-plugins ros-indigo-gazebo-ros
  ros-indigo-gazebo-ros-pkgs ros-indigo-gencpp ros-indigo-genlisp
  ros-indigo-geometric-shapes ros-indigo-geometry
  ros-indigo-geometry-tutorials ros-indigo-global-planner ros-indigo-gmapping
  ros-indigo-hokuyo-node ros-indigo-image-cb-detector ros-indigo-image-common
  ros-indigo-image-geometry ros-indigo-image-pipeline ros-indigo-image-proc
  ros-indigo-image-rotate ros-indigo-image-transport
  ros-indigo-image-transport-plugins ros-indigo-image-view
  ros-indigo-interactive-marker-tutorials ros-indigo-interactive-markers
  ros-indigo-joint-state-publisher ros-indigo-joint-states-settler
  ros-indigo-joy ros-indigo-joystick-drivers ros-indigo-kdl-conversions
  ros-indigo-kdl-parser ros-indigo-kobuki ros-indigo-kobuki-auto-docking
  ros-indigo-kobuki-bumper2pc ros-indigo-kobuki-capabilities
  ros-indigo-kobuki-controller-tutorial ros-indigo-kobuki-dashboard
  ros-indigo-kobuki-description ros-indigo-kobuki-gazebo-plugins
  ros-indigo-kobuki-keyop ros-indigo-kobuki-msgs ros-indigo-kobuki-node
  ros-indigo-kobuki-random-walker ros-indigo-kobuki-rapps
  ros-indigo-kobuki-safety-controller ros-indigo-kobuki-testsuite
  ros-indigo-laptop-battery-monitor ros-indigo-laser-assembler
  ros-indigo-laser-cb-detector ros-indigo-laser-filtering
  ros-indigo-laser-filters ros-indigo-laser-filters-jsk-patch
  ros-indigo-laser-geometry ros-indigo-laser-joint-processor
  ros-indigo-laser-joint-projector ros-indigo-laser-odometry
  ros-indigo-laser-odometry-core ros-indigo-laser-odometry-node
  ros-indigo-laser-ortho-projector ros-indigo-laser-pipeline
  ros-indigo-laser-proc ros-indigo-laser-scan-matcher
  ros-indigo-laser-scan-publisher-tutorial ros-indigo-laser-scan-sparsifier
  ros-indigo-laser-scan-splitter ros-indigo-laser-tilt-controller-filter
  ros-indigo-libfreenect ros-indigo-librealsense ros-indigo-librviz-tutorial
  ros-indigo-map-laser ros-indigo-map-msgs ros-indigo-map-server
  ros-indigo-media-export ros-indigo-message-filters
  ros-indigo-message-generation ros-indigo-mk ros-indigo-move-base
  ros-indigo-move-base-msgs ros-indigo-move-slow-and-clear ros-indigo-nav-core
  ros-indigo-nav-msgs ros-indigo-navfn ros-indigo-navigation
  ros-indigo-nodelet ros-indigo-nodelet-core ros-indigo-nodelet-topic-tools
  ros-indigo-nodelet-tutorial-math ros-indigo-octomap ros-indigo-openni-camera
  ros-indigo-openni-description ros-indigo-openni-launch
  ros-indigo-openni2-camera ros-indigo-openni2-launch
  ros-indigo-openslam-gmapping ros-indigo-orocos-kdl ros-indigo-pano-core
  ros-indigo-pano-py ros-indigo-pano-ros ros-indigo-pcl-conversions
  ros-indigo-pcl-msgs ros-indigo-pcl-ros ros-indigo-perception
  ros-indigo-perception-pcl ros-indigo-pluginlib
  ros-indigo-pluginlib-tutorials ros-indigo-pocketsphinx
  ros-indigo-pointcloud-to-laserscan ros-indigo-polled-camera
  ros-indigo-pr2-msgs ros-indigo-ps3joy ros-indigo-python-orocos-kdl
  ros-indigo-python-qt-binding ros-indigo-qt-dotgraph ros-indigo-qt-gui
  ros-indigo-qt-gui-cpp ros-indigo-qt-gui-py-common ros-indigo-random-numbers
  ros-indigo-realsense-camera ros-indigo-resource-retriever
  ros-indigo-rgbd-launch ros-indigo-robot ros-indigo-robot-model
  ros-indigo-robot-pose-ekf ros-indigo-robot-pose-publisher
  ros-indigo-robot-state-publisher ros-indigo-rocon-app-manager
  ros-indigo-rocon-app-manager-msgs ros-indigo-rocon-app-utilities
  ros-indigo-rocon-apps ros-indigo-rocon-bubble-icons ros-indigo-rocon-console
  ros-indigo-rocon-ebnf ros-indigo-rocon-gateway
  ros-indigo-rocon-gateway-utils ros-indigo-rocon-hub
  ros-indigo-rocon-hub-client ros-indigo-rocon-icons
  ros-indigo-rocon-interaction-msgs ros-indigo-rocon-interactions
  ros-indigo-rocon-launch ros-indigo-rocon-master-info
  ros-indigo-rocon-python-comms ros-indigo-rocon-python-redis
  ros-indigo-rocon-python-utils ros-indigo-rocon-python-wifi
  ros-indigo-rocon-qt-library ros-indigo-rocon-remocon
  ros-indigo-rocon-semantic-version ros-indigo-rocon-service-pair-msgs
  ros-indigo-rocon-std-msgs ros-indigo-rocon-uri ros-indigo-ros
  ros-indigo-ros-base ros-indigo-ros-comm ros-indigo-ros-core
  ros-indigo-ros-tutorials ros-indigo-rosbag ros-indigo-rosbag-migration-rule
  ros-indigo-rosbag-storage ros-indigo-rosbash ros-indigo-rosboost-cfg
  ros-indigo-rosbuild ros-indigo-rosclean ros-indigo-rosconsole
  ros-indigo-rosconsole-bridge ros-indigo-roscpp ros-indigo-roscpp-core
  ros-indigo-roscpp-tutorials ros-indigo-roscreate ros-indigo-rosgraph
  ros-indigo-rosgraph-msgs ros-indigo-roslang ros-indigo-roslaunch
  ros-indigo-roslib ros-indigo-roslint ros-indigo-roslisp ros-indigo-roslz4
  ros-indigo-rosmake ros-indigo-rosmaster ros-indigo-rosmsg ros-indigo-rosnode
  ros-indigo-rosout ros-indigo-rospack ros-indigo-rosparam ros-indigo-rospy
  ros-indigo-rospy-message-converter ros-indigo-rospy-tutorials
  ros-indigo-rosservice ros-indigo-rostest ros-indigo-rostopic
  ros-indigo-rosunit ros-indigo-roswtf ros-indigo-rotate-recovery
  ros-indigo-rqt-action ros-indigo-rqt-bag ros-indigo-rqt-bag-plugins
  ros-indigo-rqt-common-plugins ros-indigo-rqt-console ros-indigo-rqt-dep
  ros-indigo-rqt-graph ros-indigo-rqt-gui ros-indigo-rqt-gui-cpp
  ros-indigo-rqt-gui-py ros-indigo-rqt-image-view ros-indigo-rqt-launch
  ros-indigo-rqt-logger-level ros-indigo-rqt-moveit ros-indigo-rqt-msg
  ros-indigo-rqt-nav-view ros-indigo-rqt-plot ros-indigo-rqt-pose-view
  ros-indigo-rqt-publisher ros-indigo-rqt-py-common ros-indigo-rqt-py-console
  ros-indigo-rqt-reconfigure ros-indigo-rqt-robot-dashboard
  ros-indigo-rqt-robot-monitor ros-indigo-rqt-robot-plugins
  ros-indigo-rqt-robot-steering ros-indigo-rqt-runtime-monitor
  ros-indigo-rqt-rviz ros-indigo-rqt-service-caller ros-indigo-rqt-shell
  ros-indigo-rqt-srv ros-indigo-rqt-tf-tree ros-indigo-rqt-top
  ros-indigo-rqt-topic ros-indigo-rqt-web ros-indigo-rviz
  ros-indigo-rviz-plugin-tutorials ros-indigo-rviz-python-tutorial
  ros-indigo-self-test ros-indigo-sensor-msgs ros-indigo-settlerlib
  ros-indigo-shape-msgs ros-indigo-shape-tools ros-indigo-simulators
  ros-indigo-slam-gmapping ros-indigo-smach ros-indigo-smach-msgs
  ros-indigo-smach-ros ros-indigo-smart-battery-msgs ros-indigo-smclib
  ros-indigo-sound-play ros-indigo-spacenav-node ros-indigo-stage
  ros-indigo-stage-ros ros-indigo-std-capabilities ros-indigo-std-srvs
  ros-indigo-stdr-gui ros-indigo-stdr-msgs ros-indigo-stdr-parser
  ros-indigo-stdr-resources ros-indigo-stdr-robot ros-indigo-stdr-server
  ros-indigo-stereo-image-proc ros-indigo-stereo-msgs ros-indigo-tf
  ros-indigo-tf-conversions ros-indigo-tf2 ros-indigo-tf2-geometry-msgs
  ros-indigo-tf2-msgs ros-indigo-tf2-py ros-indigo-tf2-ros
  ros-indigo-tf2-sensor-msgs ros-indigo-theora-image-transport
  ros-indigo-topic-tools ros-indigo-trajectory-msgs
  ros-indigo-turtle-actionlib ros-indigo-turtle-tf ros-indigo-turtle-tf2
  ros-indigo-turtlebot ros-indigo-turtlebot-actions ros-indigo-turtlebot-apps
  ros-indigo-turtlebot-bringup ros-indigo-turtlebot-calibration
  ros-indigo-turtlebot-capabilities ros-indigo-turtlebot-create-desktop
  ros-indigo-turtlebot-dashboard ros-indigo-turtlebot-description
  ros-indigo-turtlebot-follower ros-indigo-turtlebot-gazebo
  ros-indigo-turtlebot-interactions ros-indigo-turtlebot-interactive-markers
  ros-indigo-turtlebot-msgs ros-indigo-turtlebot-navigation
  ros-indigo-turtlebot-panorama ros-indigo-turtlebot-rapps
  ros-indigo-turtlebot-rviz-launchers ros-indigo-turtlebot-simulator
  ros-indigo-turtlebot-stage ros-indigo-turtlebot-stdr
  ros-indigo-turtlebot-teleop ros-indigo-turtlesim ros-indigo-unique-id
  ros-indigo-urdf ros-indigo-urdf-parser-plugin ros-indigo-urdf-tutorial
  ros-indigo-usb-cam ros-indigo-uuid-msgs ros-indigo-vision-opencv
  ros-indigo-visualization-marker-tutorials ros-indigo-visualization-msgs
  ros-indigo-visualization-tutorials ros-indigo-viz ros-indigo-voxel-grid
  ros-indigo-warehouse-ros ros-indigo-wiimote
  ros-indigo-world-canvas-client-py ros-indigo-world-canvas-msgs
  ros-indigo-world-canvas-server ros-indigo-world-canvas-utils
  ros-indigo-xacro ros-indigo-xmlrpcpp ros-indigo-yocs-cmd-vel-mux
  ros-indigo-yocs-controllers ros-indigo-yocs-math-toolkit
  ros-indigo-yocs-msgs ros-indigo-yocs-velocity-smoother
  ros-indigo-yocs-virtual-sensor ros-indigo-zeroconf-avahi
  ros-indigo-zeroconf-msgs sbcl shiboken signon-plugin-password sip-dev
  spacenavd tango-icon-theme tcl-vtk unity-webapps-qml uuid-dev v4l-utils
  webapp-container webbrowser-app
下列【新】软件包将被安装:
  python-catkin-pkg-modules python-rospkg-modules
下列软件包将被升级:
  python-catkin-lint python-catkin-pkg python-rospkg
升级了 3 个软件包,新安装了 2 个软件包,要卸载 642 个软件包,有 780 个软件包未被升级。

 

 

安装cmake之后再次编译cere库:

znkz@znkz:~/下载/ceres-solver-master/build$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detected Ceres version: 2.0.0 from /home/znkz/下载/ceres-solver-master/include/ceres/version.h
-- Detected available Ceres threading models: [CXX11_THREADS, OPENMP, NO_THREADS]
-- Building with C++11
-- No preference for use of exported Eigen CMake configuration set, and no hints for include directory provided. Defaulting to preferring an installed/exported Eigen CMake configuration if available.
-- Failed to find installed Eigen CMake configuration, searching for Eigen build directories exported with CMake.
-- Failed to find an installed/exported CMake configuration for Eigen, will perform search for installed Eigen components.
-- Found Eigen version 3.2.0: /usr/include/eigen3
-- Enabling use of Eigen as a sparse linear algebra library.
   WARNING:

   Your version of Eigen (3.2.0) is older than 
   version 3.2.2.  The performance of SPARSE_NORMAL_CHOLESKY 
   and SPARSE_SCHUR linear solvers will suffer.
-- A library with BLAS API found.
-- Found LAPACK library: /usr/lib/liblapack.so;/usr/lib/libblas.so
-- A library with BLAS API found.
-- Found AMD headers in: /usr/include/suitesparse
-- Found AMD library: /usr/lib/x86_64-linux-gnu/libamd.so
-- Found CAMD headers in: /usr/include/suitesparse
-- Found CAMD library: /usr/lib/x86_64-linux-gnu/libcamd.so
-- Found COLAMD headers in: /usr/include/suitesparse
-- Found COLAMD library: /usr/lib/x86_64-linux-gnu/libcolamd.so
-- Found CCOLAMD headers in: /usr/include/suitesparse
-- Found CCOLAMD library: /usr/lib/x86_64-linux-gnu/libccolamd.so
-- Found CHOLMOD headers in: /usr/include/suitesparse
-- Found CHOLMOD library: /usr/lib/x86_64-linux-gnu/libcholmod.so
-- Found SUITESPARSEQR headers in: /usr/include/suitesparse
-- Found SUITESPARSEQR library: /usr/lib/x86_64-linux-gnu/libspqr.so
-- Found Intel Thread Building Blocks (TBB) library (4.2) assuming SuiteSparseQR was compiled with TBB.
-- Found SUITESPARSE_CONFIG headers in: /usr/include/suitesparse
-- Found SUITESPARSE_CONFIG library: /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.a
-- Found LIBRT library: /usr/lib/x86_64-linux-gnu/librt.so
-- Adding librt: /usr/lib/x86_64-linux-gnu/librt.so to SuiteSparse_config libraries (required on Linux & Unix [not OSX] if SuiteSparse is compiled with timing).
-- Did not find METIS library (optional SuiteSparse dependency)
-- Found SuiteSparse 4.2.1, building with SuiteSparse.
-- Found CXSparse version: 3.1.2, building with CXSparse.
-- Building without Apple's Accelerate sparse support.
-- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
-- Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
-- Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
-- Found Google Flags header in: /usr/include, in namespace: google
-- No preference for use of exported glog CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported glog CMake configuration if available.
-- Failed to find installed glog CMake configuration, searching for glog build directories exported with CMake.
-- Failed to find an installed/exported CMake configuration for glog, will perform search for installed glog components.
-- Found Google Log (glog). Assuming glog was built with gflags support as gflags was found. This will make gflags a public dependency of Ceres.
-- Using Ceres threading model: CXX11_THREADS
-- Building Ceres as a static library.
-- Enabling CERES_USE_EIGEN_SPARSE in Ceres config.h
-- Enabling CERES_NO_ACCELERATE_SPARSE in Ceres config.h
-- Enabling CERES_USE_CXX11_THREADS in Ceres config.h
-- Build the examples.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/znkz/下载/ceres-solver-master/build

安装3.2.2以上的Eigen:

http://eigen.tuxfamily.org/index.php?title=Main_Page

下载eigen-eigen-5a0156e40feb.tar.bz2,解压,修改文件夹名字为eigen3

移除旧版本:

znkz@znkz:/usr/include$ sudo rm -rf Eigen/

将新版本复制过去:

znkz@znkz:/usr/include$ sudo mv /home/znkz/下载/eigen3 /usr/include/

查看Eigen版本:https://stackoverflow.com/questions/49082293/error-related-to-eigen-while-installing-caffe2

znkz@znkz:~/下载/eigen-eigen-5a0156e40feb/Eigen/build$ cat /usr/include/Eigen/src/Core/util/Macros.h | grep VERSION
#define EIGEN_WORLD_VERSION 3
#define EIGEN_MAJOR_VERSION 3
#define EIGEN_MINOR_VERSION 4

测试安装Eigen3.3.4成功

 

安装最稳定的Ceres版本1.14.0

Ubuntu16.04编译安装Ceres-Solver

用cmake编译

秀一下结果,嘻嘻:

[100%] Building CXX object examples/CMakeFiles/robot_pose_mle.dir/robot_pose_mle.cc.o
Linking CXX executable ../bin/robot_pose_mle
[100%] Built target robot_pose_mle
Scanning dependencies of target robust_curve_fitting
[100%] Building CXX object examples/CMakeFiles/robust_curve_fitting.dir/robust_curve_fitting.cc.o
Linking CXX executable ../bin/robust_curve_fitting
[100%] Built target robust_curve_fitting
Scanning dependencies of target rosenbrock
[100%] Building CXX object examples/CMakeFiles/rosenbrock.dir/rosenbrock.cc.o
Linking CXX executable ../bin/rosenbrock
[100%] Built target rosenbrock
Scanning dependencies of target simple_bundle_adjuster
[100%] Building CXX object examples/CMakeFiles/simple_bundle_adjuster.dir/simple_bundle_adjuster.cc.o
Linking CXX executable ../bin/simple_bundle_adjuster
[100%] Built target simple_bundle_adjuster
Scanning dependencies of target sampled_function
[100%] Building CXX object examples/sampled_function/CMakeFiles/sampled_function.dir/sampled_function.cc.o
Linking CXX executable ../../bin/sampled_function
[100%] Built target sampled_function
Scanning dependencies of target pose_graph_2d
[100%] Building CXX object examples/slam/pose_graph_2d/CMakeFiles/pose_graph_2d.dir/pose_graph_2d.cc.o
Linking CXX executable ../../../bin/pose_graph_2d
[100%] Built target pose_graph_2d
Scanning dependencies of target pose_graph_3d
[100%] Building CXX object examples/slam/pose_graph_3d/CMakeFiles/pose_graph_3d.dir/pose_graph_3d.cc.o
Linking CXX executable ../../../bin/pose_graph_3d
[100%] Built target pose_graph_3d

安装:

znkz@znkz:~/下载/ceres-solver-1.14.0/build$ sudo make install

头文件安装在/usr/local/include中,库文件安装在/usr/include

-- Up-to-date: /usr/local/include/ceres/types.h
-- Up-to-date: /usr/local/include/ceres/dynamic_cost_function.h
-- Up-to-date: /usr/local/include/ceres/tiny_solver_autodiff_function.h
-- Up-to-date: /usr/local/include/ceres/sized_cost_function.h
-- Up-to-date: /usr/local/include/ceres/evaluation_callback.h
-- Up-to-date: /usr/local/include/ceres/ceres.h
-- Up-to-date: /usr/local/include/ceres/conditioned_cost_function.h
-- Up-to-date: /usr/local/include/ceres/crs_matrix.h
-- Up-to-date: /usr/local/include/ceres/dynamic_cost_function_to_functor.h
-- Up-to-date: /usr/local/include/ceres/numeric_diff_options.h
-- Up-to-date: /usr/local/include/ceres/iteration_callback.h
-- Up-to-date: /usr/local/include/ceres/version.h
-- Up-to-date: /usr/local/include/ceres/autodiff_cost_function.h
-- Up-to-date: /usr/local/include/ceres/internal/numeric_diff.h
-- Up-to-date: /usr/local/include/ceres/internal/scoped_ptr.h
-- Up-to-date: /usr/local/include/ceres/internal/variadic_evaluate.h
-- Up-to-date: /usr/local/include/ceres/internal/manual_constructor.h
-- Up-to-date: /usr/local/include/ceres/internal/port.h
-- Up-to-date: /usr/local/include/ceres/internal/disable_warnings.h
-- Up-to-date: /usr/local/include/ceres/internal/reenable_warnings.h
-- Up-to-date: /usr/local/include/ceres/internal/eigen.h
-- Up-to-date: /usr/local/include/ceres/internal/macros.h
-- Up-to-date: /usr/local/include/ceres/internal/autodiff.h
-- Up-to-date: /usr/local/include/ceres/internal/fixed_array.h
-- Up-to-date: /usr/local/include/ceres/internal/config.h
-- Installing: /usr/local/lib/cmake/Ceres/CeresTargets.cmake
-- Installing: /usr/local/lib/cmake/Ceres/CeresTargets-release.cmake
-- Installing: /usr/local/lib/cmake/Ceres/CeresConfig.cmake
-- Installing: /usr/local/lib/cmake/Ceres/CeresConfigVersion.cmake
-- Installing: /usr/local/lib/cmake/Ceres/FindEigen.cmake
-- Installing: /usr/local/lib/cmake/Ceres/FindGlog.cmake
-- Installing: /usr/local/lib/cmake/Ceres/FindGflags.cmake
-- Installing: /usr/local/lib/libceres.a
//main.cpp
#include 
#include 
#include 
#include 

using namespace std;

struct CURVE_FITTING_CONST
{
    CURVE_FITTING_CONST (double x,  double y): _x( x ), _y( y ) {};
    
    template 
    bool operator() (
    const T* const abc, 
    T* residual ) const
    {
	residual[0] = 	T(_y) -ceres::exp( abc[0]*T(_x)*T(_x) + abc[1]*T(_x) + abc[2] );
	return true;
    }
    const double _x, _y;
    


};

int main(int argc, char** argv)
{
    double a = 1.0, b = 2.0, c = 1.0;
    int N = 100;
    double w_sigma = 1.0;
    cv::RNG rng;
    double abc[3] = {0, 0, 0};
    
    vector x_data, y_data;
    cout << "generating data: " << endl;
    
    for (int i = 0; i < N; i++)
    {
	double x = i/100.0;
	x_data.push_back(x);
	y_data.push_back(
	    exp(a * x * x + b * x + c) + rng.gaussian( w_sigma)
	);
	cout << x_data[i] << " " <(
	    new CURVE_FITTING_CONST ( x_data[i], y_data[i])
	),
	nullptr,
	abc);
    }

    
    
    ceres::Solver::Options options;
    options.linear_solver_type = ceres::DENSE_QR;
    options.minimizer_progress_to_stdout = true;
    
    ceres::Solver::Summary summary;
    chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
    ceres::Solve (options, &problem, &summary);
    chrono::steady_clock::time_point t2 = chrono::steady_clock::now();
    chrono::duration time_used = chrono::duration_cast> (t2 - t1);
    
    cout << summary.BriefReport() <
//CmakeList.txt
project(ceres_curve_fitting)
set ( CMAKE_CXX_FLAGS "-std=c++11")
cmake_minimum_required(VERSION 3.2)

#opencv
find_package(OpenCV REQUIRED)
include_directories( ${Opencv_INCLUDE_DIRS} )

#EIGEN
find_package(Ceres REQUIRED)
#include_directories("/usr/local/include/ceres")    #添加头文件目录
include_directories( ${CERES_INCLUDE_DIRS} )

add_executable(ceres_curve_fitting main.cpp)  #添加可执行文件
target_link_libraries(ceres_curve_fitting ${CERES_LIBRARIES} ${OpenCV_LIBS})   #添加库文件目录
generating data: 
0 2.71828
0.01 2.93161
0.02 2.12942
0.03 2.46037
0.04 4.18814
0.05 2.73368
0.06 2.42751
0.07 3.44729
0.08 3.72543
0.09 2.1358
0.1 4.12333
0.11 3.38199
0.12 4.81164
0.13 1.62582
0.14 1.76862
0.15 3.21555
0.16 3.0922
0.17 5.82752
0.18 4.29855
0.19 2.74081
0.2 5.75724
0.21 3.53729
0.22 1.95514
0.23 2.99195
0.24 3.28739
0.25 4.70749
0.26 6.24365
0.27 5.81645
0.28 4.88402
0.29 4.75991
0.3 7.25246
0.31 5.92933
0.32 7.00306
0.33 5.22286
0.34 5.16179
0.35 7.26191
0.36 6.40545
0.37 6.25549
0.38 6.56094
0.39 6.53523
0.4 8.14891
0.41 7.77616
0.42 7.40141
0.43 8.75638
0.44 7.20606
0.45 7.57795
0.46 8.21564
0.47 9.84032
0.48 6.96725
0.49 9.90619
0.5 9.27125
0.51 9.87567
0.52 10.3412
0.53 9.55315
0.54 11.3635
0.55 10.8815
0.56 13.0648
0.57 11.4756
0.58 11.337
0.59 13.2393
0.6 13.5299
0.61 14.0441
0.62 13.31
0.63 13.672
0.64 14.8504
0.65 14.2599
0.66 14.7724
0.67 17.4339
0.68 17.4632
0.69 17.7598
0.7 16.8223
0.71 19.9468
0.72 20.5446
0.73 21.3767
0.74 20.1435
0.75 20.3088
0.76 23.2543
0.77 23.4349
0.78 22.8706
0.79 24.094
0.8 25.4183
0.81 25.5237
0.82 27.9738
0.83 28.5861
0.84 29.5703
0.85 29.6744
0.86 32.667
0.87 34.2698
0.88 33.5124
0.89 36.1479
0.9 39.2485
0.91 40.988
0.92 41.5716
0.93 41.3686
0.94 44.285
0.95 42.8312
0.96 47.7941
0.97 48.5931
0.98 51.8487
0.99 51.0258
iter      cost      cost_change  |gradient|   |step|    tr_ratio  tr_radius  ls_iter  iter_time  total_time
   0  1.824887e+04    0.00e+00    1.38e+03   0.00e+00   0.00e+00  1.00e+04        0    1.20e-03    1.24e-03
   1  2.748700e+39   -2.75e+39    0.00e+00   7.67e+01  -1.52e+35  5.00e+03        1    5.15e-05    1.32e-03
   2  2.429783e+39   -2.43e+39    0.00e+00   7.62e+01  -1.35e+35  1.25e+03        1    2.25e-05    1.35e-03
   3  1.213227e+39   -1.21e+39    0.00e+00   7.30e+01  -6.73e+34  1.56e+02        1    2.04e-05    1.38e-03
   4  1.852387e+37   -1.85e+37    0.00e+00   5.56e+01  -1.03e+33  9.77e+00        1    1.96e-05    1.41e-03
   5  6.714689e+31   -6.71e+31    0.00e+00   2.96e+01  -3.85e+27  3.05e-01        1    1.96e-05    1.43e-03
   6  9.500531e+12   -9.50e+12    0.00e+00   9.50e+00  -8.39e+08  4.77e-03        1    1.94e-05    1.46e-03
   7  1.776982e+04    4.79e+02    1.83e+03   2.58e-01   1.18e+00  1.43e-02        1    1.20e-03    2.66e-03
   8  1.599969e+04    1.77e+03    3.45e+03   5.53e-01   1.46e+00  4.29e-02        1    1.20e-03    3.87e-03
   9  1.060557e+04    5.39e+03    7.62e+03   7.33e-01   1.68e+00  1.29e-01        1    1.20e-03    5.10e-03
  10  3.669783e+03    6.94e+03    9.60e+03   5.25e-01   1.39e+00  3.86e-01        1    1.20e-03    6.30e-03
  11  5.397541e+02    3.13e+03    5.00e+03   2.66e-01   1.12e+00  1.16e+00        1    1.18e-03    7.49e-03
  12  1.484444e+02    3.91e+02    1.22e+03   8.46e-02   1.02e+00  3.48e+00        1    1.18e-03    8.68e-03
  13  1.216815e+02    2.68e+01    3.76e+02   4.17e-02   1.01e+00  1.04e+01        1    1.22e-03    9.91e-03
  14  9.290109e+01    2.88e+01    2.42e+02   9.10e-02   1.01e+00  3.13e+01        1    1.20e-03    1.11e-02
  15  6.674330e+01    2.62e+01    1.09e+02   1.33e-01   1.00e+00  9.39e+01        1    1.19e-03    1.23e-02
  16  5.936574e+01    7.38e+00    2.14e+01   1.08e-01   9.94e-01  2.82e+02        1    1.21e-03    1.35e-02
  17  5.653118e+01    2.83e+00    1.36e+01   1.57e-01   9.98e-01  8.45e+02        1    1.20e-03    1.48e-02
  18  5.310764e+01    3.42e+00    8.50e+00   2.81e-01   9.89e-01  2.53e+03        1    1.19e-03    1.60e-02
  19  5.125939e+01    1.85e+00    2.84e+00   2.98e-01   9.90e-01  7.60e+03        1    1.20e-03    1.72e-02
  20  5.097693e+01    2.82e-01    4.34e-01   1.48e-01   9.95e-01  2.28e+04        1    1.19e-03    1.84e-02
  21  5.096854e+01    8.39e-03    3.24e-02   2.87e-02   9.96e-01  6.84e+04        1    1.19e-03    1.96e-02
Ceres Solver Report: Iterations: 22, Initial cost: 1.824887e+04, Final cost: 5.096854e+01, Termination: CONVERGENCE
*** 正常退出 ***

 

你可能感兴趣的:(ROS)