ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

RayROS's profile - activity

2022-09-19 18:10:18 -0500 marked best answer Converting CvImage to a ROS image not working on Ubuntu 18.04 - Melodic

Hello, I am trying to convert a CvImage to a ROS image. I followed the tutorial present on this source but I don't understand the error that is keeping me from compiling and running the example. Below the code I am using from the same tutorial:

UPDATE CMake Code:

cmake_minimum_required(VERSION 2.8.3)
project(map_ros)

add_compile_options(-std=c++11)
find_package(octomap REQUIRED)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})

find_package(catkin REQUIRED COMPONENTS
    roscpp
    sensor_msgs
    std_msgs
    message_generation
    pcl_ros
    pcl_conversions
    geometry_msgs
    nav_msgs
    grid_map_core
    grid_map_ros
    grid_map_cv
    grid_map_filters
    grid_map_loader
    grid_map_msgs
    grid_map_octomap
    grid_map_rviz_plugin
    grid_map_visualization
    cv_bridge
    octomap_msgs
    filters
    image_transport
    )

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES ${PROJECT_NAME}
  CATKIN_DEPENDS
      roscpp
      sensor_msgs
      std_msgs
      message_generation
      pcl_ros
      pcl_conversions
      geometry_msgs
      nav_msgs
      grid_map_core
      grid_map_ros
      grid_map_cv
      grid_map_filters
      grid_map_loader
      grid_map_msgs
      grid_map_octomap
      grid_map_rviz_plugin
      grid_map_visualization
      cv_bridge
      octomap_msgs
      filters
      DEPENDS EIGEN3
)

###########
## Build ##
###########

include_directories(${catkin_INCLUDE_DIRS})
add_executable(imageConverter src/imageConverter.cpp ${SRCS})
target_link_libraries(imageConverter ${catkin_LIBRARIES})

And the C++ code I am using:

#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

static const std::string OPENCV_WINDOW = "Image window";

class ImageConverter
{
  ros::NodeHandle nh_;
  image_transport::ImageTransport it_;
  image_transport::Subscriber image_sub_;
  image_transport::Publisher image_pub_;

public:
  ImageConverter()
    : it_(nh_)
  {
    // Subscrive to input video feed and publish output video feed
    image_sub_ = it_.subscribe("/camera/image_raw", 1,
      &ImageConverter::imageCb, this);
    image_pub_ = it_.advertise("/image_converter/output_video", 1);

    cv::namedWindow(OPENCV_WINDOW);
  }

  ~ImageConverter()
  {
    cv::destroyWindow(OPENCV_WINDOW);
  }

  void imageCb(const sensor_msgs::ImageConstPtr& msg)
  {
    cv_bridge::CvImagePtr cv_ptr;
    try
    {
      cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);
    }
    catch (cv_bridge::Exception& e)
    {
      ROS_ERROR("cv_bridge exception: %s", e.what());
      return;
    }

    // Draw an example circle on the video stream
    if (cv_ptr->image.rows > 60 && cv_ptr->image.cols > 60)
      cv::circle(cv_ptr->image, cv::Point(50, 50), 10, CV_RGB(255,0,0));

    // Update GUI Window
    cv::imshow(OPENCV_WINDOW, cv_ptr->image);
    cv::waitKey(3);

    // Output modified video stream
    image_pub_.publish(cv_ptr->toImageMsg());
  }
};

int main(int argc, char** argv)
{
  ros::init(argc, argv, "image_converter");
  ImageConverter ic;
  ros::spin();
  return 0;
}

Here the errors which states that a bunch of undefined references are found:

[100%] Built target rviz_imu_plugin
CMakeFiles/imageConverter.dir/src/imageConverter.cpp.o: In function `ImageConverter::ImageConverter()':
/home/emanuele/catkin_ws/src/map_ros/src/imageConverter.cpp:89: undefined reference to `cv::namedWindow(cv::String const&, int)'
CMakeFiles/imageConverter.dir/src/imageConverter.cpp.o: In function `ImageConverter::~ImageConverter()':
/home/emanuele/catkin_ws/src/map_ros/src/imageConverter.cpp:94: undefined reference to `cv::destroyWindow(cv::String const&)'
CMakeFiles/imageConverter.dir/src/imageConverter.cpp.o: In function `ImageConverter::imageCb(boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&)':
/home/emanuele/catkin_ws/src/map_ros/src/imageConverter.cpp:115: undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
/home/emanuele/catkin_ws/src/map_ros/src/imageConverter.cpp:116: undefined reference to `cv::waitKey(int)'
collect2: error: ld returned 1 exit status
map_ros/CMakeFiles/imageConverter.dir/build.make:334: recipe for target '/home/emanuele/catkin_ws/devel/lib/map_ros/imageConverter' failed
make[2]: *** [/home/emanuele/catkin_ws/devel/lib/map_ros/imageConverter] Error 1
CMakeFiles/Makefile2:9236: recipe for target 'map_ros/CMakeFiles/imageConverter.dir/all' failed
make[1]: *** [map_ros/CMakeFiles/imageConverter.dir ...
(more)
2022-06-24 02:22:53 -0500 received badge  Famous Question (source)
2022-04-14 13:50:58 -0500 received badge  Famous Question (source)
2022-04-14 13:50:58 -0500 received badge  Notable Question (source)
2022-03-23 14:41:14 -0500 asked a question CMake - C++ : undefined reference to (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)

CMake - C++ : undefined reference to (std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocato

2022-02-11 14:01:22 -0500 received badge  Notable Question (source)
2022-02-11 14:01:22 -0500 received badge  Famous Question (source)
2021-11-11 15:57:45 -0500 received badge  Notable Question (source)
2021-11-11 15:32:04 -0500 commented answer Possible to record a specific time window (from T1 to T2) of a rosbag?

@santK, what do you mean?

2021-10-28 21:04:15 -0500 marked best answer Possible to record a specific time window (from T1 to T2) of a rosbag?

Hello, I am trying to understand if it is possible to record only a specific time window (from Time T1 to time T2) in a rosbag. The reason for this is that I need to print the result of specific topics into 2 different .csv files. According to the rosbag official documentation is possible to start recording from a specific point in time in the bag, and in fact that is what I am doing, but don't know how to set an end time:

<node pkg="rosbag" type="play" name="player" output="screen" args="--clock -q -s 2340 /home/toMyBag/test.bag"/>
<node pkg="rosbag" type="record" name="record" output="screen" args="-O filter_second_order_bis /estimate "/>
<node pkg="rosbag" type="record" name="record" output="screen" args="-O filter_second_order_bis /particle_cloud "/>

But is it possible to set a limit in the time recording?

From the example below, I need to record from approximately minute 39 to minute 224 (4h 4' 0" )approximately so:

Beginning of the recording : 39*60 = 2340 seconds

End of the recording: 224*60 = 13440 second

1

Thank for pointing in the right direction on this matter.

2021-09-25 22:09:22 -0500 received badge  Famous Question (source)
2021-08-25 00:19:21 -0500 received badge  Notable Question (source)
2021-08-25 00:19:21 -0500 received badge  Famous Question (source)
2021-08-11 04:53:55 -0500 received badge  Notable Question (source)
2021-08-11 04:53:55 -0500 received badge  Famous Question (source)
2021-08-11 04:53:55 -0500 received badge  Popular Question (source)
2021-07-18 01:21:39 -0500 marked best answer roscore fails at the start : error while loading shared libraries: libboost_thread.so.1.71.0: cannot open shared object file

Does anyone have any idea why the roscore fails at the start because of a strange library error? This never happened to me and it is a very strange error:

emanuele@emanuele-pc:~/catkin_ws$ roscore
... logging to /home/emanuele/.ros/log/314803bc-e693-11eb-8045-e7251890027b/roslaunch-emanuele-pc-37486.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://emanuele-pc:37381/
ros_comm version 1.15.11


SUMMARY
========

PARAMETERS
 * /rosdistro: noetic
 * /rosversion: 1.15.11

NODES

auto-starting new master
process[master]: started with pid [37496]
ROS_MASTER_URI=http://emanuele-pc:11311/

setting /run_id to 314803bc-e693-11eb-8045-e7251890027b
process[rosout-1]: started with pid [37506]
/opt/ros/noetic/lib/rosout/rosout: error while loading shared libraries: libboost_thread.so.1.71.0: cannot open shared object file: No such file or directory
started core service [/rosout]
[rosout-1] process has died [pid 37506, exit code 127, cmd /opt/ros/noetic/lib/rosout/rosout __name:=rosout __log:=/home/emanuele/.ros/log/314803bc-e693-11eb-8045-e7251890027b/rosout-1.log].
log file: /home/emanuele/.ros/log/314803bc-e693-11eb-8045-e7251890027b/rosout-1*.log

Thanks for shedding light on what is happening here.

2021-07-17 15:13:25 -0500 received badge  Popular Question (source)
2021-07-17 14:55:46 -0500 commented answer ‘boost::placeholders’ has not been declared : boost::placeholders::_1

Yes I did try that too yesterday but didn't work too.

2021-07-17 14:25:15 -0500 commented answer ‘boost::placeholders’ has not been declared : boost::placeholders::_1

See video with that option commented.

2021-07-17 14:18:39 -0500 commented answer ‘boost::placeholders’ has not been declared : boost::placeholders::_1

Thanks for looking. Unfortunately it is not working. I get the same error...

2021-07-17 12:58:54 -0500 commented question ‘boost::placeholders’ has not been declared : boost::placeholders::_1

Ok Mike I understand. In order to make the problem even narrower I created a minimal verifiable ros node that exactly re

2021-07-17 10:54:29 -0500 received badge  Popular Question (source)
2021-07-17 10:21:35 -0500 commented question ‘boost::placeholders’ has not been declared : boost::placeholders::_1

Now with all my heart I wouldn't want to modify a ROS library, but it seems to me that this is the only way to hopefully

2021-07-17 10:21:02 -0500 commented question ‘boost::placeholders’ has not been declared : boost::placeholders::_1

Now with all my heart I wouldn't want to modify a ROS library, but it seems to me that this is the only way to hopefully

2021-07-17 10:20:36 -0500 commented question ‘boost::placeholders’ has not been declared : boost::placeholders::_1

Now with all my heart I wouldn't want to modify a ROS library, but it seems to me that this is the only way to hopefully

2021-07-17 10:17:47 -0500 commented question ‘boost::placeholders’ has not been declared : boost::placeholders::_1

Hello Mike, I am only trying to launch here catkin_make but that is not working. The error is coming from the ROS Librar

2021-07-17 08:17:23 -0500 received badge  Notable Question (source)
2021-07-17 07:37:27 -0500 commented question roscore fails at the start : error while loading shared libraries: libboost_thread.so.1.71.0: cannot open shared object file

Now the big problem is that, despite Noetic comes with the proper version of boost 1.71 (I checked this with dpkg -s lib

2021-07-17 07:35:35 -0500 commented question roscore fails at the start : error while loading shared libraries: libboost_thread.so.1.71.0: cannot open shared object file

Now the big problem is that, despite Noetic comes with the proper version of boost 1.71 (I checked this with dpkg -s lib

2021-07-17 07:32:03 -0500 commented question roscore fails at the start : error while loading shared libraries: libboost_thread.so.1.71.0: cannot open shared object file

Thanks problem is solved: I have Noetic installed on Ubuntu 20.04 and installed boost libraries from source. I uninstall

2021-07-17 07:30:39 -0500 commented question roscore fails at the start : error while loading shared libraries: libboost_thread.so.1.71.0: cannot open shared object file

Thanks problem is solved: I have Noetic installed on Ubuntu 20.04 and installed boost libraries from source. I uninstall

2021-07-16 19:19:49 -0500 asked a question roscore fails at the start : error while loading shared libraries: libboost_thread.so.1.71.0: cannot open shared object file

roscore fails at the start : error while loading shared libraries: libboost_thread.so.1.71.0: cannot open shared object

2021-07-16 14:46:38 -0500 commented question Velodyne VLP-16 is not properly connected to ROS and not showing anythig on RViz despite followed official installation procedure

Also those instructions on the official ROS webpage should be corrected as there is no more CD-ROM in the package of the

2021-07-16 14:44:27 -0500 commented question Velodyne VLP-16 is not properly connected to ROS and not showing anythig on RViz despite followed official installation procedure

Yes I fond the solution by modifying the velodyne_interface modifying the address to 192.168.1.202

2021-07-16 14:41:11 -0500 edited question ‘boost::placeholders’ has not been declared : boost::placeholders::_1

‘boost::placeholders’ has not been declared : boost::placeholders::_1 I am trying to launch a ROS project but I receive

2021-07-16 14:02:25 -0500 edited question ‘boost::placeholders’ has not been declared : boost::placeholders::_1

‘boost::placeholders’ has not been declared : boost::placeholders::_1 I am trying to launch a ROS project but I receive

2021-07-16 13:58:05 -0500 asked a question ‘boost::placeholders’ has not been declared : boost::placeholders::_1

‘boost::placeholders’ has not been declared : boost::placeholders::_1 I am trying to launch a ROS project but I receive

2021-06-30 02:01:41 -0500 received badge  Popular Question (source)
2021-06-30 02:01:41 -0500 received badge  Notable Question (source)
2021-06-30 02:01:41 -0500 received badge  Famous Question (source)
2021-03-26 05:40:57 -0500 received badge  Famous Question (source)
2021-03-03 03:58:11 -0500 received badge  Popular Question (source)
2021-03-03 03:58:11 -0500 received badge  Famous Question (source)
2021-03-03 03:58:11 -0500 received badge  Notable Question (source)
2021-02-15 11:00:52 -0500 received badge  Famous Question (source)
2021-02-04 06:45:02 -0500 received badge  Famous Question (source)