Hy everybody,
I am currently writing a function for a ros node. During this calculation I am trying to use the pseudo inverse of the QR Module of Eigen. But unfortunately it is not able to find the include and by that not the function. I think I need to alter my Cmake file. I did already use normal functions so this is not the problem.
I found a stack overflow post in which it seems very easy to use the function. Just for clarity I add the link here: [stack overflow post](https://stackoverflow.com/questions/44465197/eigen-library-pseudo-inverse-of-matrix-matlab-pinv)
Thank you very much for your help. Since I am not posting very often just tell me when I need to change anything. I will add all the information as soon as possible.
The code I am trying to make run:
#include
#include "ros/ros.h"
#include
#include
#include
#include
#include //<- can't find this import
void calc_delta_p(Eigen::Matrix &delta_p,Eigen::Matrix &hessian){
hessian.completeOrthogonalDecomposition().pseudoInverse(); //<-cant find this function
delta_p=hessian*delta_p;
}
The compiler throws this error:
/home/catkin_ws/src/image_publisher/src/function_file.cpp:120:13: error: ‘class Eigen::Matrix’ has no member named ‘completeOrthogonalDecomposition’
hessian.completeOrthogonalDecomposition().pseudoInverse();
Here is my cmake file:
cmake_minimum_required(VERSION 2.8.3)
project(image_publisher)
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
cv_bridge
#opencv2
roscpp
sensor_msgs
std_msgs
cmake_modules #eigen
dynamic_reconfigure
message_generation
)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
## Generate messages in the 'msg' folder
add_message_files(
FILES
sixDOF.msg
)
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
sensor_msgs
std_msgs
)
## Generate dynamic reconfigure parameters in the 'cfg' folder
generate_dynamic_reconfigure_options(
cfg/dynamic_reconfigure_file.cfg
)
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need catkin_package( INCLUDE_DIRS include
# LIBRARIES image_publisher CATKIN_DEPENDS cv_bridge roscpp sensor_msgs std_msgs dynamic_reconfigure message_runtime
#opencv2
# DEPENDS system_lib DEPENDS Eigen #Eigen library )
###########
## Build ##
###########
find_package(OpenCV) find_package(Eigen REQUIRED)
#eigenlibrary
set( PROPRIETARY_FUNCTIONS_H include/image_publisher/function_file.h )
set( PROPRIETARY_FUNCTIONS_CPP src/function_file.cpp )
## Specify additional locations of header files
## Your package locations should be listed before other locations include_directories( include ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${Eigen_INCLUDE_DIRS}
# ${PROPRIETARY_FUNCTIONS_CPP}
# ${PROPRIETARY_FUNCTIONS_H} )
## Declare a C++ library
# add_library(${PROJECT_NAME}
# src/${PROJECT_NAME}/image_publisher.cpp
# )
#always before add dependencies
## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide add_executable(image_publisher_node src/image_publisher_node.cpp ${PROPRIETARY_FUNCTIONS_CPP} ${PROPRIETARY_FUNCTIONS_H} ) add_executable(image_subscriber_node src/image_subscriber_node.cpp ${PROPRIETARY_FUNCTIONS_H} ${PROPRIETARY_FUNCTIONS_CPP}) add_executable(test_node src/test_node.cpp ${PROPRIETARY_FUNCTIONS_H} ${PROPRIETARY_FUNCTIONS_CPP})
## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure add_dependencies(image_publisher_node ${catkin_EXPORTED_TARGETS} ${${PROJECT_NAME}_EXPORTED_TARGETS}) add_dependencies(image_subscriber_node ${catkin_EXPORTED_TARGETS} ${${PROJECT_NAME}_EXPORTED_TARGETS}) add_dependencies(test_node ${catkin_EXPORTED_TARGETS} ${${PROJECT_NAME}_EXPORTED_TARGETS}) add_dependencies(image_publisher_node ${PROJECT_NAME}_gencfg)
## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Specify libraries to link a library or executable target against target_link_libraries(image_publisher_node ${catkin_LIBRARIES} ${OpenCV_LIBRARIES}) target_link_libraries(image_subscriber_node ${catkin_LIBRARIES} ${OpenCV_LIBRARIES}) target_link_libraries(test_node
${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
↧