From 4cc32311284a190fd4a18e8e3dd1e00c4528f7e1 Mon Sep 17 00:00:00 2001 From: Laki Dantanarayana Date: Wed, 21 Oct 2015 20:34:45 +1100 Subject: [PATCH] Converted package to ROS Indigo. Build system changed (rosbuild -> catkin). --- CMakeLists.txt | 225 +++++++++++++++++++++++++++++----- Makefile | 1 - README.md | 2 +- bin/oldFiles.zip | Bin 4657 -> 0 bytes mainpage.dox | 26 ---- manifest.xml | 35 ------ package.xml | 66 ++++++++++ setup.py | 13 ++ {bin => src}/extract_all.py | 4 +- {bin => src}/extract_topic.py | 8 +- 10 files changed, 281 insertions(+), 99 deletions(-) delete mode 100644 Makefile delete mode 100644 bin/oldFiles.zip delete mode 100644 mainpage.dox delete mode 100644 manifest.xml create mode 100644 package.xml create mode 100755 setup.py rename {bin => src}/extract_all.py (94%) rename {bin => src}/extract_topic.py (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8f1c9c..983af73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,30 +1,195 @@ -cmake_minimum_required(VERSION 2.4.6) -include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) - -# Set the build type. Options are: -# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage -# Debug : w/ debug symbols, w/o optimization -# Release : w/o debug symbols, w/ optimization -# RelWithDebInfo : w/ debug symbols, w/ optimization -# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries -#set(ROS_BUILD_TYPE RelWithDebInfo) - -rosbuild_init() - -#set the default path for built executables to the "bin" directory -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) -#set the default path for built libraries to the "lib" directory -set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) - -#uncomment if you have defined messages -#rosbuild_genmsg() -#uncomment if you have defined services -#rosbuild_gensrv() - -#common commands for building c++ executables and libraries -#rosbuild_add_library(${PROJECT_NAME} src/example.cpp) -#target_link_libraries(${PROJECT_NAME} another_library) -#rosbuild_add_boost_directories() -#rosbuild_link_boost(${PROJECT_NAME} thread) -#rosbuild_add_executable(example examples/example.cpp) -#target_link_libraries(example ${PROJECT_NAME}) +cmake_minimum_required(VERSION 2.8.3) +project(ros_csv_extraction) + +## Find catkin macros and libraries +## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) +## is used, also find other catkin packages +find_package(catkin REQUIRED COMPONENTS + rospy + geometry_msgs + sensor_msgs + std_msgs + nav_msgs + cv_bridge + opencv2 +) + +## System dependencies are found with CMake's conventions +# find_package(Boost REQUIRED COMPONENTS system) + + +## Uncomment this if the package has a setup.py. This macro ensures +## modules and global scripts declared therein get installed +## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html +catkin_python_setup() + +################################################ +## Declare ROS messages, services and actions ## +################################################ + +## To declare and build messages, services or actions from within this +## package, follow these steps: +## * Let MSG_DEP_SET be the set of packages whose message types you use in +## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). +## * In the file package.xml: +## * add a build_depend tag for "message_generation" +## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET +## * If MSG_DEP_SET isn't empty the following dependency has been pulled in +## but can be declared for certainty nonetheless: +## * add a run_depend tag for "message_runtime" +## * In this file (CMakeLists.txt): +## * add "message_generation" and every package in MSG_DEP_SET to +## find_package(catkin REQUIRED COMPONENTS ...) +## * add "message_runtime" and every package in MSG_DEP_SET to +## catkin_package(CATKIN_DEPENDS ...) +## * uncomment the add_*_files sections below as needed +## and list every .msg/.srv/.action file to be processed +## * uncomment the generate_messages entry below +## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) + +## Generate messages in the 'msg' folder +# add_message_files( +# FILES +# Message1.msg +# Message2.msg +# ) + +## Generate services in the 'srv' folder +# add_service_files( +# FILES +# Service1.srv +# Service2.srv +# ) + +## Generate actions in the 'action' folder +# add_action_files( +# FILES +# Action1.action +# Action2.action +# ) + +## Generate added messages and services with any dependencies listed here +# generate_messages( +# DEPENDENCIES +# std_msgs # Or other packages containing msgs +# ) + +################################################ +## Declare ROS dynamic reconfigure parameters ## +################################################ + +## To declare and build dynamic reconfigure parameters within this +## package, follow these steps: +## * In the file package.xml: +## * add a build_depend and a run_depend tag for "dynamic_reconfigure" +## * In this file (CMakeLists.txt): +## * add "dynamic_reconfigure" to +## find_package(catkin REQUIRED COMPONENTS ...) +## * uncomment the "generate_dynamic_reconfigure_options" section below +## and list every .cfg file to be processed + +## Generate dynamic reconfigure parameters in the 'cfg' folder +# generate_dynamic_reconfigure_options( +# cfg/DynReconf1.cfg +# cfg/DynReconf2.cfg +# ) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## INCLUDE_DIRS: uncomment this if you package contains header files +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( +# INCLUDE_DIRS include +# LIBRARIES ros_csv_extraction +# CATKIN_DEPENDS rospy +# DEPENDS system_lib +) + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +# include_directories(include) +include_directories( + ${catkin_INCLUDE_DIRS} +) + +## Declare a C++ library +# add_library(ros_csv_extraction +# src/${PROJECT_NAME}/ros_csv_extraction.cpp +# ) + +## Add cmake target dependencies of the library +## as an example, code may need to be generated before libraries +## either from message generation or dynamic reconfigure +# add_dependencies(ros_csv_extraction ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Declare a C++ executable +# add_executable(ros_csv_extraction_node src/ros_csv_extraction_node.cpp) + +## Add cmake target dependencies of the executable +## same as for the library above +# add_dependencies(ros_csv_extraction_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Specify libraries to link a library or executable target against +# target_link_libraries(ros_csv_extraction_node +# ${catkin_LIBRARIES} +# ) + +############# +## Install ## +############# + +# all install targets should use catkin DESTINATION variables +# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html + +## Mark executable scripts (Python etc.) for installation +## in contrast to setup.py, you can choose the destination +install(PROGRAMS + src/extract_all.py + src/extract_topic.py + DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +## Mark executables and/or libraries for installation +# install(TARGETS ros_csv_extraction ros_csv_extraction_node +# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark cpp header files for installation +# install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +# FILES_MATCHING PATTERN "*.h" +# PATTERN ".svn" EXCLUDE +# ) + +## Mark other files for installation (e.g. launch and bag files, etc.) +# install(FILES +# # myfile1 +# # myfile2 +# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +# ) + + + +############# +## Testing ## +############# + +## Add gtest based cpp test target and link libraries +# catkin_add_gtest(${PROJECT_NAME}-test test/test_ros_csv_extraction.cpp) +# if(TARGET ${PROJECT_NAME}-test) +# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) +# endif() + +## Add folders to be run by python nosetests +# catkin_add_nosetests(test) diff --git a/Makefile b/Makefile deleted file mode 100644 index b75b928..0000000 --- a/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(shell rospack find mk)/cmake.mk \ No newline at end of file diff --git a/README.md b/README.md index f346482..30b0df7 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ To install the data extraction tool, download the zip file, extract it somewhere # Usage * Extract all compatible topics in a bag file: - + `rosrun data_extract extract_all.py -b -o ` * Extract a single topic: diff --git a/bin/oldFiles.zip b/bin/oldFiles.zip deleted file mode 100644 index 3a44e9013cad46fccec6f58ff47e9eb13d36986b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4657 zc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zY8tliJ~6_enIXh&1ieL|U;syXRU1}Ub#U_*u~UFG6)bNi2BTDp@L%8OKKXe&E&^%K~1Jt0_Ao5tcmH3&5e7{j_D6uUE8lEgY&(Ni$ z%i9d_1l7J;hie#$O@8Yk@I3}NkjuEAO1Lc*U-*e!-X z`IX|4S6>Yty6+KQGO2^`;H#og@VAaq^0{?I#XvgOFxSYTz3KXdBL#nc8p*YM)V+UC zK}7pKl@}&q%CEoxeFM+(e~1V0Jt171kVuvI|6h_^6YctNhy4owqyC?j$=~JwG=Kde`cuAgotv)Z z|2>WUUH(r2>o2+b_0s0Q - - -\section codeapi Code API - - - - -*/ diff --git a/manifest.xml b/manifest.xml deleted file mode 100644 index 93841ca..0000000 --- a/manifest.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - A data extraction tool has been created to extract information from ROS "bag" files and convert them into more user-friendly comman-separated-value (CSV) files for use in Excel / Matlab / etc. - - The tool is written in the form of a ROS package "data_extract". Thus far, the data extraction tool is compatible with the following ROS message types: - * sensor_msgs/Image - * sensor_msgs/Imu - * sensor_msgs/LaserScan - * sensor_msgs/NavSatFix - * gps_common/gpsVel - * umrr_driver/radar_msg - - 1.) Extract all compatible topics in a bag file - rosrun data_extract extract_all.py -b path_to_bag_file -o path_to_output_dir - 2.) Extract a single topic - rosrun data_extraction extract_topic.py -b path_to_bag_file -o path_to_output_csv_file -t topic_name - - The extraction tool will only extract topics of the types listed above. - - Version 1.0 - Shane Lynn - 7th May 2012 - - Shane Lynn - BSD - - http://ros.org/wiki/data_extraction - - - - - - - - - diff --git a/package.xml b/package.xml new file mode 100644 index 0000000..7fefa55 --- /dev/null +++ b/package.xml @@ -0,0 +1,66 @@ + + + ros_csv_extraction + 1.5.0 + + A data extraction tool has been created to extract information from ROS "bag" files and convert them into more user-friendly comman-separated-value (CSV) files for use in Excel / Matlab / etc. + + The tool is written in the form of a ROS package "data_extract". Thus far, the data extraction tool is compatible with the following ROS message types: + * sensor_msgs/Image + * sensor_msgs/Imu + * sensor_msgs/LaserScan + * sensor_msgs/NavSatFix + * sensor_msgs/NavSatFix + * gps_common/gpsVel + * umrr_driver/radar_msg + * nav_msgs/Odometry + + 1.) Extract all compatible topics in a bag file + rosrun data_extract extract_all.py -b path_to_bag_file -o path_to_output_dir + 2.) Extract a single topic + rosrun data_extraction extract_topic.py -b path_to_bag_file -o path_to_output_csv_file -t topic_name + + The extraction tool will only extract topics of the types listed above. + + Version 1.0 - Shane Lynn - 7th May 2012 + Version 1.1 - Laki Dantanarayana - 31th July 2012, New Topic added + Version 1.2 - Gibson Hu - 2012, Changed image file structure, automatic folder creation. + Version 1.3 - Laki Dantanarayana, ROS Indigo support + + + + + + Shane Lynn + + + + + + BSD + + + catkin + rospy + opencv2 + rosbag + cv_bridge + std_msgs + sensor_msgs + geometry_msgs + nav_msgs + + rospy + opencv2 + rosbag + cv_bridge + std_msgs + sensor_msgs + geometry_msgs + nav_msgs + + + + + + \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..7417f9b --- /dev/null +++ b/setup.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +from distutils.core import setup +from catkin_pkg.python_setup import generate_distutils_setup + +d = generate_distutils_setup( + # # don't do this unless you want a globally visible script + # scripts=['bin/myscript'], + packages=['PYTHON_PACKAGE_NAME'], + package_dir={'': 'src'} +) + +setup(**d) \ No newline at end of file diff --git a/bin/extract_all.py b/src/extract_all.py similarity index 94% rename from bin/extract_all.py rename to src/extract_all.py index 0461af3..0efc9dc 100755 --- a/bin/extract_all.py +++ b/src/extract_all.py @@ -1,7 +1,6 @@ #!/usr/bin/env python import roslib -roslib.load_manifest('data_extraction') import rospy import rosbag import os #used to get directory for image topics @@ -37,6 +36,7 @@ def usage(): 'gps_common/GPSFix', 'umrr_driver/radar_msg' , 'nav_msgs/Odometry' , 'geometry_msgs/PoseWithCovarianceStamped'] def main(): + rospy.init_node('extract_all', log_level=rospy.DEBUG) rospy.loginfo("Processing input arguments:") try: opts, extraparams = getopt.getopt(sys.argv[1:], "o:b:t:") #start at the second argument. @@ -92,7 +92,7 @@ def main(): rospy.loginfo("----------------------- Starting TOPIC_EXTRACT.PY for %s --------------------------"%topicName) fileName = topicName.replace("/", "-") fileName=fileName[1:] - commandLine = "rosrun data_extraction extract_topic.py -b " + rosbagFile + " -o " + outDir + "/" + fileName + ".csv" + " -t " + topicName + commandLine = "rosrun ros_csv_extraction extract_topic.py -b " + rosbagFile + " -o " + outDir + "/" + fileName + ".csv" + " -t " + topicName os.system(commandLine) rospy.loginfo("----------------------- Finished TOPIC_EXTRACT.PY for %s --------------------------"%topicName) else: diff --git a/bin/extract_topic.py b/src/extract_topic.py similarity index 98% rename from bin/extract_topic.py rename to src/extract_topic.py index 50465f5..2367569 100755 --- a/bin/extract_topic.py +++ b/src/extract_topic.py @@ -1,10 +1,9 @@ #!/usr/bin/env python import roslib -roslib.load_manifest('data_extraction') import rospy import rosbag -import cv +import cv2 from cv_bridge import CvBridge, CvBridgeError #from sensor_msgs.msg import Image import csv #writing CV files. @@ -174,6 +173,7 @@ def getColumns(t, msg, imageFile = ""): def main(): + rospy.init_node('extract_topic', log_level=rospy.DEBUG) rospy.loginfo("Processing input arguments:") try: opts, extraparams = getopt.getopt(sys.argv[1:], "o:b:t:") #start at the second argument. @@ -251,14 +251,14 @@ def main(): try: #switchs between image encoding types #print _img_encoding - cvImage = bridge.imgmsg_to_cv(msg) + cvImage = bridge.imgmsg_to_cv2(msg) except CvBridgeError, err: print err imfileName = topic.replace("/", "-") imfileName = imfileName[1:] imageFile = imfileName+'-Image_%.4d'%count saveFileName = str(outDir)+"/"+imageFile+".png" - cv.SaveImage(saveFileName, cvImage) + cv2.imwrite(saveFileName, cvImage) #write the columns or image to the file/folder.