Linking the PCL library with ROS - linker

i had installed ROS and PCL in ubuntu...
The import in my code are:
#include <pcl/io/pcd_io.h>
#include <pcl/point_cloud.h>
#include <pcl/correspondence.h>
#include <pcl/features/normal_3d_omp.h>
#include <pcl/features/shot_omp.h>
#include <pcl/features/board.h>
#include <pcl/keypoints/uniform_sampling.h>
#include <pcl/recognition/cg/hough_3d.h>
#include <pcl/recognition/cg/geometric_consistency.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/kdtree/impl/kdtree_flann.hpp>
#include <pcl/common/transforms.h>
#include <pcl/console/parse.h>
When i compile the program with this CMakeLists:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(correspondence_grouping)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(correspondence_grouping correspondence_grouping.cpp)
target_link_libraries(correspondence_grouping ${PCL_COMMON_LIBRARIES}${PCL_IO_LIBRARIES})
appears this error:
In file included from /opt/ros/fuerte/include/pcl-1.5/pcl/io/pcd_io.h:43:0,
from /home/user/Desktop/PCL/Grouping/correspondence_grouping.cpp:1:
/opt/ros/fuerte/include/pcl-1.5/pcl/point_cloud.h:46:29: fatal error: std_msgs/Header.h: No such file or directory
I'm new in Linux and ROS+PCL (i'm using them for an university project..) and i can't understand which is the problem.
P.S. Similary error appear with other cpp files with PCL.
I don't know how to do to fix it...
Thanks

I think you will be better off using the ROS build system, which is either rosbuild or catkin depending on the version of ROS you are using. catkin is AFAIK a set of CMake macros that pull in ROS dependencies etc.
See:
http://wiki.ros.org/pcl/Tutorials

You should use the rosbuild environment to create a package (See: [Creating a ros package]) and then put this into your CMakelist.txt to use PCL:
...
find_package(PCL 1.3 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
...
The dependencie to std_msgs is handled by the manifest.xml (automatically generate with the package) with the following standard dependecies:
<package>
...
<depend package="std_msgs"/>
<depend package="rospy"/>
<depend package="roscpp"/>
...
</package>

Related

Include ext4.h in C program

I'm trying to create a little program that can read the ext4 filesystem, and for that i need to use all the structures that are defined in the ext4.h file.
Problem is, that this file includes a set of kernel headers such as
#include <linux/blkdev.h>
#include <linux/magic.h>
#include <linux/jbd2.h>
#include <linux/quota.h>
#include <linux/rwsem.h>
#include <linux/rbtree.h>
#include <linux/seqlock.h>
#include <linux/mutex.h>
#include <linux/timer.h>
#include <linux/version.h>
... and more
I've installed the kernel headers using:
$ apt search linux-headers-$(uname -r)
So now i have them in /usr/src/linux-headers-5.4.../include and i try to compile my program with -I /path/to/kernel-headers but now it seems that there're headers included in those headers that it can't find such as asm/current.h which in my filesystem is asm-generic/current.h
Do someone that ever did something like this can help me?
I suggest you take a look at e2fsprogs. This is the user-space toolset for manipulating ext2/3/4 filesystems, and it contains a userspace implementation of the filesystem you can adapt.

Is there any way that I can include my own function file under any file? [duplicate]

I have the following code in a sample file:
#include "SkCanvas.h"
#include "SkDevice.h"
#include "SkGLCanvas.h"
#include "SkGraphics.h"
#include "SkImageEncoder.h"
#include "SkPaint.h"
#include "SkPicture.h"
#include "SkStream.h"
#include "SkWindow.h"
However, this code is located in various folders within /home/me/development/skia (which includes core/ animator/ images/ ports/ svg/ and a lot more.)
How can I make GCC recognize this path?
Try gcc -c -I/home/me/development/skia sample.c.
The -I directive does the job:
gcc -Icore -Ianimator -Iimages -Ianother_dir -Iyet_another_dir my_file.c
Using environment variable is sometimes more convenient when you do not control the build scripts / process.
For C includes use C_INCLUDE_PATH.
For C++ includes use CPLUS_INCLUDE_PATH.
See this link for other gcc environment variables.
Example usage in MacOS / Linux
# `pip install` will automatically run `gcc` using parameters
# specified in the `asyncpg` package (that I do not control)
C_INCLUDE_PATH=/home/scott/.pyenv/versions/3.7.9/include/python3.7m pip install asyncpg
Example usage in Windows
set C_INCLUDE_PATH="C:\Users\Scott\.pyenv\versions\3.7.9\include\python3.7m"
pip install asyncpg
# clear the environment variable so it doesn't affect other builds
set C_INCLUDE_PATH=

How do you include FreeRTOS header files in different source files in an Espressif IDF Eclipse project

Upon creating an ESPRESSIF project in Eclipse, I see the following includes already exists in main.
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_syst"
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "lwip/sockets.h"
I guess the included files are referenced by the path defined in IDF_PATH. But how do you go about using these files in any other source file? The same include won't work.
// file1.c
#include "lwip/sockets.h" // Unresolved inclusion: "lwip/sockets.h"
Below is the snapshot of the properties. I don't see a C/C++ build section for some reason otherwise I know there's an option to put the file paths in there which could then just be used by any source file without specifying the relative path.
For reference: I followed this tutorial -> https://github.com/espressif/idf-eclipse-plugin/blob/master/README.md#create-a-new-project until Compiling the Project

Unable to use SurfFeatureDetector in OpenCV 3.0.0

System-
Windows 8.1 64 bit machine
OpenCV 3.0.0
Visual Studio 12 2013
I have built the openCV 3.0.0 with the contrib modules. However, when I compile this code I get errors.
#include <OpenNI.h> //used for taking in input from xtion pro live
#include <iostream>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\core\core.hpp>
#include <opencv2\features2d\features2d.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/xfeatures2d.hpp> // these are the libraries in the new location (they contain SURF implementation)
#include <opencv2/xfeatures2d/nonfree.hpp>
using namespace std;
//using namespace openni;
using namespace cv;
int main(void)
{
//from sample code
int minHessian = 400;
SurfFeatureDetector detector(minHessian);
return 0;
}
The error is-
error C2065: 'SurfFeatureDetector' : undeclared identifier
The syntax to construct a Surf feature detector in OpenCV 3.0 is different from 2.x versions.
Ptr<SURF> surf=SURF::create(minHessian);
std::vector<KeyPoint> keypts;
Mat desc;
surf->detectAndCompute(img,noArray(),keypts,desc);
Apologies if the above example would still throw any errors, I don't have a working version to field test it.
I think for SURF you must use 'extra' modules. Have a look on that: https://github.com/itseez/opencv_contrib/
Basically what you need to do is download the code (opencv_contrib). Add it to the list of modules in the opencv source folder. Then, in cmake you must add the path < opencv_contrib >/modules into EXTRA_MODULES_PATH. Finally, after generate the project via cmake, you will find the xfeatured2d (I think is the one you need) on your opencv solution and you will be able to build it and use them.
In opencv3.0, it combined all library in opencv_world300d.lib (debug) and opencv_world300.lib (release).
For this, you can use #include to instead other include.
On the other hand, they are opencv_world310d.lib (debug) and opencv_world310.lib (release) in opencv3.1.

Importing CUnit sources

i'm having a problem to use Unit test in C, i've tried to install CUnit in my computer and after include the lib.
i've followed steeps to install the CUnit:
1 - download the sources
2 - configure it using "./configure --prefix='/lib' "
3 - make (only make)
4 - sudo make install
and this is my test source file, it's not making tests, but i can't compile this, i got this error before "CUnit.h: No such file or directory":
#include "CUnit.h"
#include <stdlib.h>
#include <stdio.h>
int main(){
print("Hello");
return 0;
}
I want to know, how can i install CUnit to use in my test source files!
Thanks in advance.
EDIT
HAHA, i got this!
i just run configure without parameters, like that:
"./configure"
As shown in the code example you should use something like this :
#include <CUnit/CUnit.h>
because every CUnit includes are located in a CUnit subdirectory (in general in /usr/local/include/CUnit)
What about adding -I/lib/include flag to include header files installed in /lib/include/CUnit and -lcunit -L/lib/CUnit/lib for linking with the installed libraries?
gcc test_file_source.c -I/lib/include -lcunit -L/lib/CUnit/lib -o testing

Resources