2022-08-20 10:53:23 -0500 | received badge | ● Guru
(source)
|
2022-08-20 10:53:23 -0500 | received badge | ● Great Answer
(source)
|
2020-05-16 12:09:18 -0500 | received badge | ● Enlightened
(source)
|
2020-05-16 12:09:18 -0500 | received badge | ● Good Answer
(source)
|
2020-05-16 07:32:37 -0500 | received badge | ● Good Question
(source)
|
2019-08-29 10:29:06 -0500 | received badge | ● Nice Answer
(source)
|
2019-06-02 18:35:44 -0500 | received badge | ● Self-Learner
(source)
|
2019-06-02 18:35:39 -0500 | received badge | ● Nice Question
(source)
|
2017-07-19 13:51:04 -0500 | received badge | ● Student
(source)
|
2017-01-24 02:31:33 -0500 | received badge | ● Famous Question
(source)
|
2017-01-09 01:58:44 -0500 | received badge | ● Famous Question
(source)
|
2017-01-07 11:14:13 -0500 | received badge | ● Notable Question
(source)
|
2016-11-05 20:19:02 -0500 | received badge | ● Notable Question
(source)
|
2016-08-31 08:32:14 -0500 | received badge | ● Popular Question
(source)
|
2016-08-31 03:15:39 -0500 | received badge | ● Scholar
(source)
|
2016-08-31 03:15:31 -0500 | answered a question | How to use a service defined in another package ? Hi all, After some research, I have found one solution to my problem.
I have added add_dependencies(my_nodes ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) to the rosfond's CMakeLists.txt (only for the nodes that use my_service ) as well as in the hmi's one (my_nodes changed into my_other_nodes obviously). I have also find_package-d rosfond in hmi's CMakeLists.txt .
In the rosfond's package.xml , I have added the lines <export>
<cpp cflags="-I${prefix}/srv/cpp"/>
</export>
And the the hmi's one : <run_depend>rosfond</run_depend>
<build_depend>rosfond</build_depend>
Thanks to these changes, I could include rosfond/my_service.h in my_other_nodes.cpp . I hope this solution will work for you if you have the same problem. |
2016-08-25 09:37:19 -0500 | asked a question | How to use a service defined in another package ? Hi all, I am facing a compilation problem when I try to include a service.h file in a node located in another package.
Here is the architecture : rosfond/
src/
my_nodes.cpp
include/
...
srv/
my_service.srv
hmi/
src/
my_other_nodes.cpp
include/
...
I want to use my_service in the hmi package, and especially include my_service.h in my_other_nodes.cpp . For that,
I wrote at the beginning of my_other_nodes.cpp #include "rosfond/my_service.h" .
I also use my_service in my_nodes . When I try to compile my whole workspace, it fails. However, if I compile only rosfond , it works. So the problem seems to be related to how I include/link my_service in my_other_nodes and in the hmi's CMakeLists.txt . Here are the CMakeLists.txt and the package.xml file of each package : cmake_minimum_required(VERSION 2.8.3)
project(rosfond)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)
add_service_files(DIRECTORY srv FILES my_service.srv)
generate_messages(DEPENDENCIES std_msgs)
catkin_package(
INCLUDE_DIRS include
# LIBRARIES rosfond
CATKIN_DEPENDS roscpp rospy std_msgs
# DEPENDS system_lib
)
include_directories(
${catkin_INCLUDE_DIRS}
include
)
add_executable(my_nodes src/my_nodes.cpp)
target_link_libraries(my_nodes
${catkin_LIBRARIES}
)
+++++++++++++++++++++++++++++++++++++++++++++++ <?xml version="1.0"?>
<package>
<name>rosfond</name>
<version>0.0.0</version>
<description>The rosfond package</description>
<maintainer email="ghost@todo.todo">ghost</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
</package>
+++++++++++++++++++++++++++++++++++++++++++++++ cmake_minimum_required(VERSION 2.8.3)
project(hmi)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)
generate_messages(DEPENDENCIES std_msgs)
catkin_package(
INCLUDE_DIRS include
# LIBRARIES hmi
CATKIN_DEPENDS roscpp rospy std_msgs
# DEPENDS system_lib
)
include_directories(
${catkin_INCLUDE_DIRS}
include
)
add_executable(my_other_nodes src/my_other_nodes.cpp)
target_link_libraries(my_other_nodes
${catkin_LIBRARIES}
)
+++++++++++++++++++++++++++++++++++++++++++++++ <?xml version="1.0"?>
<package>
<name>hmi</name>
<version>0.0.0</version>
<description>The hmi package</description>
<maintainer email="ghost@todo.todo">ghost</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>rosfond</build_depend>
<run_depend>rosfond</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
</package>
++++++++++++++++++++++++++++++++++++++++++++++++ The error message is : my_other_nodes.cpp : rosfond/my_service.h: No such file or directory . Thanking you in advance for your answers, roach |
2016-08-25 09:07:44 -0500 | received badge | ● Popular Question
(source)
|
2016-08-21 09:20:14 -0500 | received badge | ● Teacher
(source)
|
2016-08-21 09:20:14 -0500 | received badge | ● Necromancer
(source)
|
2016-08-18 10:13:05 -0500 | answered a question | cv_bridge/OpenCV segmentation fault Hi, it may be because the image is empty.
Before sending the image, you should check if it is not empty, and recheck its size before using it. This callback works for me (Ubuntu 16.04, ROS kinetic, OpenCV 3) : cv::Mat cameraFeed;
// Callback function. Serves to receive images from ROS camera's images topic
void imageCallback(const sensor_msgs::ImageConstPtr& msg)
{
try
{
cameraFeed = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8)->image;
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("Could not convert from '%s' to 'bgr8'.", msg->encoding.c_str());
return;
}
cv::waitKey(1);
}
|
2016-08-18 09:58:24 -0500 | commented answer | Strange segfault when running node on raspberry pi 3 I have tried with Ubuntu Mate, and it works very well, using exactly the same codes. |
2016-08-11 10:25:48 -0500 | commented answer | Strange segfault when running node on raspberry pi 3 Thank you very much for your answer ! Segfault happens when running the node, and I think while loading libraries in memory. I have tried to print something before doing anything else, but it also segfaults. I'll try Ubuntu Mate right now and keep you informed. |
2016-08-10 12:59:19 -0500 | asked a question | Strange segfault when running node on raspberry pi 3 Hi all, I have recently installed ROS kinetic on a raspberry pi 3 (raspbian jessie), as explained in this tutorial. Everything worked fine (except rviz, but I don't need it). However, when I wanted to test some C++ nodes I wrote on my laptop, it didn't worked. I just copied my packages in the raspi's catkin_ws, then catkin_maked it. I didn't meet any problem when compiling. The python-coded nodes worked fine, but not the C++ ones. Then I tried to make a very simple C++ node saying hello world, and I build it the same way. And it didn't work (Segmentation Fault). Then I discovered, that if, in the CMakeLists, I did not link the catkin/opencv libraries (with target_link_libraries , which worked on my laptop), the program worked well, but it obviously couldn't interact with ROS/opencv. Would you have any suggestion, feel free to answer ;) Thanking you in advance EDIT I have included the codes below. The nodes aims at reading a webcam and sending OpenCV images. It works on my laptop (Ubuntu 16.04, ROS kinetic). Here is the code : #include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <cv_bridge/cv_bridge.h>
#include <sstream>
int main(int argc, char** argv)
{
// Initialization of ROS node and ROS topic
ros::init(argc, argv, "i_Camera");
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
image_transport::Publisher pub = it.advertise("/sensors/camera", 1);
int cam = 0;
nh.param<int>("camera_id",cam,0);
cv::VideoCapture cap(cam);
// Check if video device can be opened with the given index
if(!cap.isOpened()) return 1;
cv::Mat frame;
sensor_msgs::ImagePtr msg;
ros::Rate loop_rate(60);
// Main loop, grab frames and publish them on the topic
while (nh.ok()) {
cap >> frame;
// Check if grabbed frame is not empty
if(!frame.empty()) {
msg = cv_bridge::CvImage(std_msgs::Header(), sensor_msgs::image_encodings::BGR8, frame).toImageMsg();
pub.publish(msg);
cv::waitKey(1);
}
ros::spinOnce();
loop_rate.sleep();
}
}
And the CMakeLists.txt: cmake_minimum_required(VERSION 2.8.3)
project(vision)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
roscpp
rospy
std_msgs
visualization_msgs
image_transport
cv_bridge
)
find_package(OpenCV)
catkin_package(
INCLUDE_DIRS include
# LIBRARIES vision
CATKIN_DEPENDS geometry_msgs roscpp rospy std_msgs visualization_msgs image_transport cv_bridge
# DEPENDS system_lib
)
include_directories(
include
${OpenCV_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)
add_executable(i_Camera src/i_Camera.cpp)
target_link_libraries(i_Camera
${OpenCV_LIBS}
${catkin_LIBRARIES}
)
|