Ask Your Question
0

How to use ros srv in different pkg

asked 2016-07-06 10:09:43 -0500

sailor91 gravatar image

http://answers.ros.org/question/18898... http://answers.ros.org/question/20231... (these answers didn't help me)

Here is the problem:

1) ros pkg serial_interface is providing the service SerialWriteMsg.srv. A test client inside this package can use the service.

2) ros pgk conversions wants to use this service. Here the CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(conversions)

set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wno-write-strings -g ${CMAKE_CXX_FLAGS}")

find_package(catkin REQUIRED COMPONENTS
  message_generation
  serial_interface
  ackermann_msgs
  roscpp
  rospy
  std_msgs
  tf
  tf2
  tf2_ros
)

add_message_files(
   FILES
   SteeringMsgStamped.msg
)

generate_messages(
   DEPENDENCIES
   std_msgs
)

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS message_generation roscpp rospy std_msgs
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

add_executable(velocity_conversion src/velocity_conversion.cpp)
target_link_libraries(velocity_conversion ${catkin_LIBRARIES})
add_dependencies(velocity_conversion serial_interface_generate_messages_cpp)
...

Here part of the package.xml

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>serial_interface</build_depend>
  <build_depend>ackermann_msgs</build_depend>
  <build_depend>message_generation</build_depend>

  <run_depend>roscpp</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>std_msgs</run_depend>
  <run_depend>serial_interface</run_depend>
  <run_depend>ackermann_msgs</run_depend>
  <run_depend>message_runtime</run_depend>
  <run_depend>message_generation</run_depend>

Here is the srv file

Header header
uint8 type
int32 data
---
bool done

But this error occurs

catkin_ws/src/conversions/src/velocity_conversion.cpp:28:13: error: ‘struct serial_interface::SerialWriteMsg’ has no member named ‘header’
   serialMsg.header.frame_id = frame_id_;

Would you please help me?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-07-06 11:57:44 -0500

ahendrix gravatar image

serial_interface::SerialWriteMsg is the service type, and includes both the request and the response.

Try using the request portion of the message instead:

serialMsg.request.header.frame_id = frame_id_;
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2016-07-06 10:09:43 -0500

Seen: 79 times

Last updated: Jul 06 '16