How to make another package node get BoundingBox msgs frome darknet_ros

asked 2019-02-22 05:02:55 -0500

七小丘人 gravatar image

updated 2019-02-22 07:22:56 -0500

I try to write a node to receive and show data of Bounding Box like below.

#include "ros/ros.h"
#include "darknet_ros_msgs/BoundingBoxes.h"
#include "darknet_ros_msgs/BoundingBox.h"
using namespace std;
void msgCallback(const darknet_ros_msgs::BoundingBoxes::ConstPtr& msg)
{
    cout<<"Bouding Boxes (header):" << msg->header <<endl;
    cout<<"Bouding Boxes (image_header):" << msg->image_header <<endl;
    cout<<"Bouding Boxes (Class):" << msg->bounding_boxes[0].Class <<endl;
    cout<<"Bouding Boxes (xmin):" << msg->bounding_boxes[0].xmin <<endl;
    cout<<"Bouding Boxes (xmax):" << msg->bounding_boxes[0].xmax <<endl;
    cout<<"Bouding Boxes (ymin):" << msg->bounding_boxes[0].ymin <<endl;
    cout<<"Bouding Boxes (ymax):" << msg->bounding_boxes[0].ymax <<endl;
    cout << "\033[2J\033[1;1H";     // clear terminal
}
int main(int argc, char **argv)
{
    ros::init(argc,argv,"cood_subscriber");
    ros::NodeHandle nh;
    ros::Subscriber cood_sub = nh.subscribe("/darknet_ros/bounding_boxes",100,msgCallback);
    ros::spin();
    return 0;
}

I have modify the cmakelist.txt and package.xml

cmakelist.txt

cmake_minimum_required(VERSION 2.8.3)
project(cood_tran)

find_package(catkin REQUIRED COMPONENTS  roscpp  darknet_ros  darknet_ros_msgs)

catkin_package(
#INCLUDE_DIRS include
  LIBRARIES cood_tran

)

include_directories(
  include 
  ${catkin_INCLUDE_DIRS}
)

add_executable(cood_tran src/cood_tran.cpp)
add_dependencies(cood_tran ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(cood_tran ${catkin_LIBRARIES} )

package.xml:

<?xml version="1.0"?>
<package format="2">
  <name>cood_tran</name>
  <version>0.0.0</version>
  <description>The cood_tran package</description>

  <maintainer email="qiuyilin@qq.com">qiuyilin</maintainer>  <!-- One license tag required, multiple allowed, one license per tag -->
  <license>TODO</license>  <!-- Url tags are optional, but multiple are allowed, one per tag -->
  <buildtool_depend>catkin</buildtool_depend>  <!-- The export tag contains other, unspecified, tags -->
  <export>

  </export>
<build_depend>roscpp</build_depend>
<build_depend>darknet_ros</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>darknet_ros_msgs</build_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>darknet_ros</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>darknet_ros_msgs</exec_depend>
</package>

but when I run catkin_make, these mistakes happen

Packages "coord_tran, realsense-2.1.1" not found in the workspace - ignoring them
-- Using CATKIN_DEVEL_PREFIX: /home/qiuyilin/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/kinetic
-- This workspace overlays: /opt/ros/kinetic
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/qiuyilin/catkin_ws/build/test_results
-- Found gmock sources under '/usr/src/gmock': gmock will be built
-- Found gtest sources under '/usr/src/gmock': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.14
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 39 packages in topological order:
-- ~~  - image_pipeline (metapackage)
-- ~~  - moveit_dobot
-- ~~  - panda_moveit_config
-- ~~  - universal_robot (metapackage)
-- ~~  - ur_description
-- ~~  - ur_msgs
-- ~~  - dobot
-- ~~  - my_first_ros_pkg
-- ~~  - my_second_ros_pkg
-- ~~  - ros_tutorials_param
-- ~~  - ros_tutorials_service
-- ~~  - ros_tutorials_topic
-- ~~  - camera_calibration
-- ~~  - magician
-- ~~  - ros_tutorials_action
-- ~~  - darknet_ros_msgs
-- ~~  - darknet_ros
-- ~~  - cood_tran
-- ~~  - image_proc
-- ~~  - image_publisher
-- ~~  - image_view
-- ~~  - stereo_image_proc
-- ~~  - depth_image_proc
-- ~~  - realsense2_camera
-- ~~  - image_rotate
-- ~~  - ur_bringup
-- ~~  - ur_driver
-- ~~  - ur_gazebo
-- ~~  - mimic_parallel_link_description
-- ~~  - ur_kinematics
-- ~~  - video_stream_opencv
-- ~~  - moveit_tutorials
-- ~~  - seven_dof_arm_test
-- ~~  - mastering_ros_robot_description_pkg
-- ~~  - seven_dof_arm_config
-- ~~  - seven_dof_arm_gazebo
-- ~~  - ur10_moveit_config
-- ~~  - ur3_moveit_config
-- ~~  - ur5_moveit_config
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin metapackage: 'image_pipeline'
-- ==> add_subdirectory(image_pipeline-indigo/image_pipeline)
-- +++ processing catkin package: 'moveit_dobot'
-- ==> add_subdirectory(moveit_dobot)
-- +++ processing catkin package: 'panda_moveit_config'
-- ==> add_subdirectory(panda_moveit_config)
-- +++ processing catkin metapackage: 'universal_robot'
-- ==> add_subdirectory(universal_robot/universal_robot)
-- +++ processing catkin package: 'ur_description'
-- ==> add_subdirectory(universal_robot/ur_description)
-- +++ processing catkin package: 'ur_msgs'
-- ==> add_subdirectory(universal_robot/ur_msgs)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- ur_msgs: 6 messages, 2 services
-- +++ processing catkin package: 'dobot'
-- ==> add_subdirectory(dobot)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- dobot: 0 messages, 60 services
-- +++ processing catkin package: 'my_first_ros_pkg'
-- ==> add_subdirectory(my_first_ros_pkg)
-- +++ processing catkin package: 'my_second_ros_pkg'
-- ==> add_subdirectory ...
(more)
edit retag flag offensive close merge delete

Comments

Please don't use screenshots: you can copy-paste text into your question and use the Preformatted Text button (the one with 101010) to format it properly. You seem to have lots of unneeded dependencies and you miss one on package darknet_ros_msgs. It might help if you also post the full error.

aPonza gravatar image aPonza  ( 2019-02-22 05:30:31 -0500 )edit

Thank you. I have replaced the picture and added darknet_ros_msgs, but the mistake is still there. Then I delete darknet_ros and it works though I don't know why. I thought darknet_ros was a package and darknet_ros_msgs was just a directory.

七小丘人 gravatar image 七小丘人  ( 2019-02-22 07:26:04 -0500 )edit

Yep, as it is right now, your package should compile just fine with only roscpp and darknet_ros_msgs dependencies. It's a bit complicated to figure out dependencies, this helped me a lot.

aPonza gravatar image aPonza  ( 2019-02-22 08:01:25 -0500 )edit
1

Thank you.

七小丘人 gravatar image 七小丘人  ( 2019-02-24 21:14:24 -0500 )edit

I have the same problem. How did you solve it?

Astronaut gravatar image Astronaut  ( 2020-03-03 22:22:22 -0500 )edit