rosservice can't find type, and yes I've sourced

asked 2021-12-12 15:51:14 -0500

Joshua Kordani gravatar image

updated 2022-03-13 09:48:52 -0500

Mike Scheutzow gravatar image

I have a package with two nodes. One hosts a service that takes throttle and steer, and publishes a drive command. The other makes use of this service. The the client node can use the service just fine, but rosservice can't find the service type. I promise I've sourced the environment.

The node hosting the service,

bool handle_drive_request(ball_chaser::DriveToTarget::Request &mreq, ball_chaser::DriveToTarget::Response &mresp ) {
geometry_msgs::Twist motor_command;
...    
auto service = n.advertiseService("/ball_chaser/command_robot", &handle_drive_request);

The client node

client = n.serviceClient<ball_chaser::DriveToTarget>("/ball_chaser/command_robot");

CMakeLists.txt

cmake_minimum_required(VERSION 3.0.2)
project(ball_chaser)
add_compile_options(-std=c++14)
find_package(catkin REQUIRED COMPONENTS
  message_generation
  message_runtime
  roscpp
  rosconsole
  std_msgs
)

add_service_files(
   FILES
   DriveToTarget.srv
)

 generate_messages(
   DEPENDENCIES
   std_msgs
 )

catkin_package(
)


include_directories(
  ${catkin_INCLUDE_DIRS}
)

include_directories(include ${catkin_INCLUDE_DIRS})
add_executable(drive_bot src/drive_bot.cpp)
target_link_libraries(drive_bot ${catkin_LIBRARIES})
add_dependencies(drive_bot ball_chaser_generate_messages_cpp)

add_executable(process_image src/process_image.cpp)
target_link_libraries(process_image ${catkin_LIBRARIES})
add_dependencies(process_image ball_chaser_generate_messages_cpp)

Code is here

build and source the workspace, then run roslaunch src/my_robot/launch/ball-chase.launch (it wouldn't tab complete this, not sure why), in another tab, run rosservice call /ball_chaser/command_robot <tab complete=""> error is "invalid type, did you forget to run make?"

After blowing away devel and build and reissuing catkin_make it still doesn't work, output of env ros is here

ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/home/jkordani/path/to/Ball-Chaser/catkin_ws/src:/opt/ros/kinetic/share
ROS_MASTER_URI=http://localhost:11311
ROS_PYTHON_VERSION=2
ROS_VERSION=1
ROSLISP_PACKAGE_DIRECTORIES=/home/jkordani/pathtp/Ball-Chaser/catkin_ws/devel/share/common-lisp
ROS_DISTRO=kinetic
ROS_LANG_DISABLE=genlisp:geneus:genpy:gennodejs
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros
edit retag flag offensive close merge delete

Comments

Please post your full source, and the full error output.

Geoff gravatar image Geoff  ( 2021-12-12 17:22:31 -0500 )edit

updated per your instructions

Joshua Kordani gravatar image Joshua Kordani  ( 2021-12-15 16:51:30 -0500 )edit

You did not indicate that you have started the node that provides the service. source only sets up the bash environment. What does rosservice list tell you?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-12-16 12:21:55 -0500 )edit

yes, I run the launch file and /ball_chaster/command robot is listed. output is

rosservice call /ball_chaser/command_robot 
ERROR: Unable to load type [ball_chaser/DriveToTarget].
Have you typed 'make' in [ball_chaser]?
Joshua Kordani gravatar image Joshua Kordani  ( 2022-02-25 13:29:34 -0500 )edit

Your git repo compiles and the service runs as expected for me on melodic. rosservice works from the command line.

I would try doing a clean build: remove your top-level devel and build directories, and run catkin_make again. If that doesn't work, show us the output from:

env | grep ROS

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-02-25 19:38:15 -0500 )edit

Updated per your instructions

Joshua Kordani gravatar image Joshua Kordani  ( 2022-03-11 14:26:35 -0500 )edit

From what you showed, your ROS environment vars look OK, assuming you have no non-ascii characters or space characters in the portion of the directory names you redacted.

I already told you the src files seem ok since the repository works on my machine. So that indicates the issue is some difference in the build environment.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-03-13 09:57:35 -0500 )edit