Ask Your Question
0

How to run cv_bridge?

asked 2015-12-25 21:47:31 -0500

fatima gravatar image

updated 2015-12-29 01:48:39 -0500

hi , i want to run cv_bridge, so i refer to Converting between ROS images and OpenCV images (C++) i did every thing were told at" An example ROS node" at the end i added the commad below to the end of CMakelist.txt and after that run catkin_make

add_executable(image_converter src/image_converter.cpp)
target_link_libraries(image_converter ${catkin_LIBRARIES})
add_dependencies(image_converter beginner_tutorials_generate_messages_cpp)

but i have 2 problems : 1. when i run catkin_make i receive this error :

CMake Error: Error in cmake code at
/home/fatima/catkin_ws3/src/beginner_tutorials/CMakeLists.txt:135:
Parse error.  Expected a command name, got unquoted argument with text "/add_executable".
  1. and if it can be run , how to run image_converter file and how to see the result of cv_bridge ?

hi thnks for reply , this is my CMakelists: i dont know is it true for cv_bridge or not?

cmake_minimum_required(VERSION 2.8.3)
project(beginner_tutorials)


find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  roscpp
  rospy
  sensor_msgs
  std_msgs
genmsg message_generation
)

add_message_files(FILES Num.msg )
add_service_files(FILES AddTwoInts.srv)



 generate_messages(
   DEPENDENCIES
sensor_msgs
cv_bridge
roscpp
std_msgs
image_transport
 )
generate_messages(DEPENDENCIES std_msgs)
catkin_package( INCLUDE_DIRS include
 LIBRARIES ${beginner_tutorials} CATKIN_DEPENDS message_runtime roscpp nodelet)
catkin_package(  )


include_directories(
  ${catkin_INCLUDE_DIRS}
)
catkin_package()
add_library()/add_executable()/target_link_libraries(
add_library(beginner_tutorials
  src/${PROJECT_NAME}/beginner_tutorials.cpp
 )


add_dependencies(beginner_tutorials ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})


add_dependencies(beginner_tutorials_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})


 target_link_libraries(beginner_tutorials_node
   ${catkin_LIBRARIES}
 )

add_executable(image_converter src/image_converter.cpp)
target_link_libraries(image_converter ${catkin_LIBRARIES})
add_dependencies(image_converter beginner_tutorials_generate_messages_cpp)

And now after fixing the last problem i have again another problem with generate_messages : CMakeLists :

cmake_minimum_required(VERSION 2.8.3)
project(beginner_tutorials)


find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  image_transport
  roscpp
  rospy
  sensor_msgs
  std_msgs
genmsg message_generation
)

################################################
## Declare ROS messages, services and actions ##
################################################


## Generate messages in the 'msg' folder

add_message_files(FILES Num.msg )
add_service_files(FILES AddTwoInts.srv)


## 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
sensor_msgs
cv_bridge
roscpp
std_msgs
image_transport
#  sensor_msgs#   std_msgs
 )
##generate_messages(DEPENDENCIES std_msgs)
catkin_package( INCLUDE_DIRS include
 LIBRARIES ${beginner_tutorials} CATKIN_DEPENDS message_runtime roscpp nodelet)

# include_directories(include)
include_directories(
  ${catkin_INCLUDE_DIRS}
)
catkin_package()
##add_library()/add_executable()/target_link_libraries()
## Declare a C++ library
add_library(beginner_tutorials
  src/${PROJECT_NAME}/beginner_tutorials.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(beginner_tutorials ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Declare a C++ executable
# add_executable(beginner_tutorials_node src/beginner_tutorials_node.cpp)

## Add cmake target dependencies of the executable
## same as for the library above
add_dependencies(beginner_tutorials_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
 target_link_libraries(beginner_tutorials_node
   ${catkin_LIBRARIES}
 )

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_beginner_tutorials.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)
add_executable(image_converter src/image_converter.cpp)
target_link_libraries(image_converter ${catkin_LIBRARIES})
add_dependencies(image_converter beginner_tutorials_generate_messages_cpp)

and this is my catkin_make Error :

Base path: /home/fatima/catkin_ws3
Source space: /home/fatima/catkin_ws3/src
Build space: /home/fatima/catkin_ws3/build
Devel space: /home/fatima/catkin_ws3/devel
Install space: /home/fatima/catkin_ws3/install
####
#### Running command: "make ...
(more)
edit retag flag offensive close merge delete

Comments

Is the code you are trying to compile in the beginner_tutorials package or in another? Because it seems to me that the problem is with the beginner_tutorials package... Just a thought...

luketheduke gravatar imageluketheduke ( 2015-12-27 10:11:29 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-12-25 21:59:08 -0500

ahendrix gravatar image

updated 2015-12-29 14:11:39 -0500

It looks like you have a syntax error in your CMakeLists.txt file, in part of the file that you haven't included in your answer.

Without the rest of your CMakeLists.txt it's hard to say what is wrong, but perhaps one of the previous cmake commands is missing a closing parenthesis.

UPDATE

You should remove or comment this line:

add_library()/add_executable()/target_link_libraries()

It doesn't do anything, and the / characters are a syntax error.

UPDATE

The error Could not find 'share/cv_bridge/cmake/cv_bridge-msg-paths.cmake' suggests that there's something wrong with your message dependencies; I think it can't find messages for cv_bridge

Do your messages depend on any messages from cv_bridge? Otherwise, I would suggest you remove cv_bridge as a dependency in generate_messages()

edit flag offensive delete link more

Comments

thank you so much , i did it and now i have another problem i edited my question above and put my error and cmakelists again please help thank you

fatima gravatar imagefatima ( 2015-12-29 01:37:34 -0500 )edit

hi , thanks so much , i have done every thing as told in this link , and i want to Convert between ROS images and OpenCV images (C++) is there ant thing i should do for finding messages for cv_bridge ?

fatima gravatar imagefatima ( 2015-12-29 20:44:35 -0500 )edit

I'm going to ask again: "Do your messages depend on any messages from cv_bridge?"

ahendrix gravatar imageahendrix ( 2015-12-29 21:42:23 -0500 )edit

I don't think there are any messages in cv_bridge. Perhaps it should be removed from the generate_messages() call?

joq gravatar imagejoq ( 2015-12-31 11:30:37 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-12-25 21:47:31 -0500

Seen: 998 times

Last updated: Dec 29 '15