我正在阅读ROS的代码。
在文件中ros_comm/roscpp/include/ros/subscriber.h,我看到了这样的一段代码:
operator void*() const { return (impl_ && impl_->isValid()) ? (void*)1 : (void*)0; }
Run Code Online (Sandbox Code Playgroud)
好吧,(void *)0可以看作是NULLC语言,但这(void *)1意味着什么呢?
如果一个类Foo包含此函数,则意味着我们可以这样编写代码:
Foo foo;
void *ptr = foo;
Run Code Online (Sandbox Code Playgroud)
对?那么这是否意味着void *ptr = (void *)1可能?这是什么意思?
我首先使用此脚本从源代码安装openCV .当我测试它运行良好.
安装ROS动能后,打开python3并运行import cv2,出现以下错误:
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type
Run Code Online (Sandbox Code Playgroud) 总之,我试图用CMake交叉编译CMake,我认为我没有正确地链接库.我想做的可能是不可能的,但我至少想知道为什么不可能,如果是这样的话.
系统:主机是带有Cavium ARM9 CPU 的Linux机箱.它目前正在运行Linux内核版本2.6.24.4和Debian 5.0(Lenny).我的工作站是运行Ubuntu 12.04 LTS(精确穿山甲)的Core i5.
我的总体目标是在Linux机器上运行ROS.我必须从源代码编译而不是使用apt,因为Debian 6.0(Squeeze)二进制文件需要Cavium不提供的拇指支持,并且Debian 5.0(Lenny)不需要很多所需的软件包.我在安装所需的各种库方面取得了进展,但是当我进入步骤1.3.1并尝试运行CMake时,我收到了错误
需要CMake 2.8或更高版本.您正在运行2.6.0版
接下来我尝试在Linux机器上下载并构建CMake 2.8.8,但这对系统来说太过分了.当失败时,我下载了制造商网站上建议的工具链,并使用[www.cmake.org/Wiki/CMake_Cross_Compiling]上的交叉编译指南来构建CMake可执行文件.这是我的工具链文件:
# This one is important
SET(CMAKE_SYSTEM_NAME Linux)
# Specify the cross compiler
SET(CMAKE_C_COMPILER /pathto/crosstool-linux-gcc-4.5.2-gclibc-2.9-oabi/arm-unknown-linux-gnu/bin/arm-unknown-linux-gnu-gcc)
SET(CMAKE_CXX_COMPILER /pathto/crosstool-linux-gcc-4.5.2-gclibc-2.9-oabi/arm-unknown-linux-gnu/bin/arm-unknown-linux-gnu-g++)
# Where is the target environment
SET(CMAKE_FIND_ROOT_PATH /pathto/crosstool-linux-gcc-4.5.2-gclibc-2.9-oabi/arm-unknown-linux-gnu /pathto/crosstool-linux-gcc-4.5.2-gclibc-2.9-oabi/arm-unknown-linux-gnu/arm-unknown-linux-gnu)
# Search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# For libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Run Code Online (Sandbox Code Playgroud)
但是,在Linux机器上使用二进制文件会产生错误
cmake:/usr/lib/libstdc++.so.6:找不到版本`GLIBCXX_3.4.14'(cmake要求)
果然,图书馆不在那里:
prompt# strings /usr/lib/libstdc++.so.6 | …Run Code Online (Sandbox Code Playgroud) 我正在努力使用 ROS 配置 VSCode 以具有自动完成功能。我习惯于在 Qt 和 OpenCV 中使用 VSCode,一切正常。例如,对于 OpenCV,我只是这样编辑c_cpp_propreties.json:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/include/opencv4/opencv2"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
Run Code Online (Sandbox Code Playgroud)
}
OpenCV 的自动完成工作正常(我有C++ IntelliSense 扩展)。但后来,当我试图指定include从ROS在文件夹中c_cpp_propreties.json,没有什么作品了,甚至没有OpenCV的自动完成:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/include/opencv4/opencv2",
"/opt/ros/melodic/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
Run Code Online (Sandbox Code Playgroud)
}
就像 ROS 正在阻止一切。我究竟做错了什么?我指定在 VSCode …
我正在尝试在Ubuntu 上安装ROS。我收到此错误:
sudo apt-get update
Hit:1 http://pk.archive.ubuntu.com/ubuntu cosmic InRelease
Hit:2 http://pk.archive.ubuntu.com/ubuntu cosmic-updates InRelease
Hit:3 http://pk.archive.ubuntu.com/ubuntu cosmic-backports InRelease
Get:4 http://security.ubuntu.com/ubuntu cosmic-security InRelease [83.2 kB]
Ign:5 http://packages.ros.org/ros/ubuntu cosmic InRelease Err:6 http://packages.ros.org/ros/ubuntu cosmic Release 404 Not Found [IP: 64.50.236.52 80] Reading package lists... Done
E: The repository 'http://packages.ros.org/ros/ubuntu cosmic Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user …Run Code Online (Sandbox Code Playgroud) 我正在使用 ROS 和 C++,并且 ROS 包中有一个CMakeLists.txt。我想在 Visual Studio 代码中突出显示 CMakeLists.txt 的语法。
不幸的是,我在互联网上搜索,但我找不到如何做到这一点。
你可以帮帮我吗?
我正在与 ROS 合作。例如,在运行任何 python 程序之前,ROS 需要获取一些脚本/opt/ros/noetic/setup.sh。否则我无法导入roslib或类似的东西。
当我使用 vscode 进行调试时,有什么方法可以让 vscode 在启动调试器之前自动获取此脚本吗?
以下CMakeList会产生以下列出的错误:
cmake_minimum_required(VERSION 2.8.12)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
project(draw_on_images)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
find_package(OpenCV 2.4.8 REQUIRED)
find_package(Qt5 COMPONENTS Core Qml Quick REQUIRED)
qt5_add_resources(RESOURCES qml.qrc)
catkin_package(
CATKIN_DEPENDS roscpp rospy std_msgs
)
include_directories(
${catkin_INCLUDE_DIRS}
)
add_executable(${PROJECT_NAME} ${RESOURCES} src/main.cpp src/draw_on_qimage.cpp src/provide_qpixmap_to_qml.cpp )
qt5_use_modules(${PROJECT_NAME} Core Qml Quick)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Qml Qt5::Quick ${OpenCV_LIBS})
Run Code Online (Sandbox Code Playgroud)
我运行它的方式:
catkin_make -DCMAKE_PREFIX_PATH="/opt/Qt5.9.1/5.9.1/gcc_64/lib/" -DWITH_QT:BOOL=ON
Run Code Online (Sandbox Code Playgroud)
是的我已经采购了它.
错误:
Base path: /home/.../ros_workspace_test
Source space: /home/.../ros_workspace_test/src
Build space: /home/.../ros_workspace_test/build
Devel space: /home/.../ros_workspace_test/devel
Install space: /home/.../ros_workspace_test/install
####
#### Running command: …Run Code Online (Sandbox Code Playgroud) 我正在使用C++和OpenCV与ROS的组合.我使用来自相机的实时图像(intel realsense R200).我从相机中获取深度和RGB图像.在我的c ++代码中,我想使用这些图像来获取odometry数据并从中获取轨迹.
我试图使用"cv :: rgbd :: Odometry :: compute"函数进行测距,但我总是得到假,因为返回值(代码中的"isSuccess"值始终为0).但我不知道哪个部分我做错了.
我使用ROS从相机读取我的图像,然后在回调函数中,首先我将所有图像转换为灰度,然后使用Surf功能检测功能.然后我想使用"compute"来获得当前帧和前一帧之间的转换.
据我所知,"Rt"和"inintRt"是函数的输出,所以它足以用正确的大小来构造它们.
有谁能看到这个问题?我错过了什么吗?
boost::shared_ptr<rgbd::Odometry> odom;
Mat Rt = Mat(4,4, CV_64FC1);
Mat initRt = Mat(4,4, CV_64FC1);
Mat prevFtrM; //mask Matrix of previous image
Mat currFtrM; //mask Matrix of current image
Mat tempFtrM;
Mat imgprev;// previous depth image
Mat imgcurr;// current depth image
Mat imgprevC;// previous colored image
Mat imgcurrC;// current colored image
void Surf(Mat img) // detect features of the img and fill currFtrM
{
int minHessian = 400;
Ptr<SURF> …Run Code Online (Sandbox Code Playgroud) ros ×10
c++ ×3
cmake ×3
opencv ×3
autocomplete ×1
casting ×1
glibc ×1
installation ×1
intellisense ×1
python ×1
python-3.x ×1
qt5 ×1
qt5.9 ×1
ubuntu ×1
ubuntu-12.04 ×1
ubuntu-14.04 ×1