我正在开发一个需要使用Eigen库的ROS Indigo项目.根据ROS Wiki上的indigo/Migration页面,FindEigen.cmake模块现在位于cmake_modules包中.
按照以下步骤将cmake_modules包添加到项目的CMake.txt(通过find_package)并将构建依赖项添加到package.xml(< build_depend >cmake_modules< /build_depend >)之后,我仍然遇到编译项目的问题.我已经看过各种来源,引用上述步骤应该解决ROS Indigo中的问题,但似乎无法使其正常工作.这是CMake文件,这是package.xml.另外,我在项目文件夹中添加了FindEigen.cmake文件.任何帮助将不胜感激!错误如下:
CMake Error at /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:75 (find_package):
Could not find a package configuration file provided by "Eigen" with any of the
following names:
EigenConfig.cmake
eigen-config.cmake
Add the installation prefix of "Eigen" to CMAKE_PREFIX_PATH or set
"Eigen_DIR" to a directory containing one of the above files. If "Eigen"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
lidar_point_cloud/CMakeLists.txt:9 …Run Code Online (Sandbox Code Playgroud) 看看C++编译器支持,似乎std::shared_mutexGCC 5.0+中提供了不定时版本.但是,即使使用gcc version 5.3.0 20151204 (Ubuntu 5.3.0-3ubuntu1~14.04)和编译-std=c++1z,共享互斥锁的简单初始化最终会:
error: ‘shared_mutex’ in namespace ‘std’ does not name a type
std::shared_mutex mutex_;
Run Code Online (Sandbox Code Playgroud)
不,我已经包含了正确的标题:#include <shared_mutex>.
它找不到合适的标题,因为它似乎不存在.实际上,链接器使用的是locate at /usr/include/c++/5/shared_mutex,它只包含了实现std::shared_timed_mutex(如C++ 14标准).
我已经安装了gcc-5和g ++ - 5,通过添加存储库ppa:ubuntu-toolchain-r/test并使用它update-alternatives来正确设置它们的垃圾箱.
有没有什么可以使用最新的C++ 17标准正确编译我的代码?并且可能是一个要提出的愚蠢问题,但是-std=c++1z即使应该已经支持它,现在开始使用还为时过早吗?因为它受到支持,对吗?
在任何语言(无关紧要)中,是否有可能使用一个使用字符串数组作为键的哈希函数?
我的意思是这样的:
hash(["word1", "word2", ...]) = "element"
Run Code Online (Sandbox Code Playgroud)
而不是经典:
hash("word") = "element"
Run Code Online (Sandbox Code Playgroud)
我需要类似的东西,因为我想用作键的每个单词都可以改变函数的输出元素.我有一系列的单词,我希望该序列的特定输出(顺序也可能改变结果).
我有一个自定义的 .msg 文件 MyImage.msg
sensor_msgs/Image im
float32 age
string name
Run Code Online (Sandbox Code Playgroud)
我已经配置了自定义 .msg 文件,如链接所示:CreatingMsgAndSrv
此外,我正在尝试使用此 msg 编写一个简单的发布者。
#include <ros/ros.h>
#include <custom_msg/MyImage.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <cv_bridge/cv_bridge.h>
int main( int argc, char ** argv )
{
ros::init(argc, argv, "publish_custom");
ros::NodeHandle nh;
ros::Publisher pub2 = nh.advertise<custom_msg::MyImage>("custom_image", 2 );
cv::Mat image = cv::imread( "Lenna.png", CV_LOAD_IMAGE_COLOR );
sensor_msgs::ImagePtr im_msg = cv_bridge::CvImage(std_msgs::Header(), "bgr8", image).toImageMsg();
ros::Rate rate( 2 );
while( ros::ok() )
{
ROS_INFO_STREAM_ONCE( "IN main loop");
custom_msg::MyImage msg2;
msg2.age=54.3;
msg2.im = im_msg; …Run Code Online (Sandbox Code Playgroud)