Getting an error while creating a service message

I receive this error message when I run

catkin_make

This is the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.0.2)
project(rosject)

find_package(catkin REQUIRED COMPONENTS
rospy
std_msgs
message_generation
)

#Generate services in the ‘srv’ folder

add_service_files(
FILES
FindWall.srv
)

generate_messages(
DEPENDENCIES
std_msgs
)

catkin_package(

CATKIN_DEPENDS
rospy
)

include_directories(

${catkin_INCLUDE_DIRS}
)

Blockquote

It is complaining at the line where generate_messages() is, right below where you added your service. Assuming you have everything correct there and that you have added

  <build_depend>message_generation</build_depend>
  <exec_depend>message_runtime</exec_depend>

to package.xml, then maybe try creating the whole package again

@roalgoal I believe I did as you suggested but the error still shows.

import rospy
from geometry_msgs.msg import Twist
from sensor_msgs.msg import LaserScan
from rosject.srv import Findwall, FindwallResponse

and under generate_msgs:

generate_messages(
   DEPENDENCIES
   std_msgs
   geometry_msgs
   sensor_msgs
 )
type or paste code here

I recreated the entire package again and I still get the same error

@roalgoal I somehow fixed it. Everything seemed alright in the CMakelists.text and package.xml files. I had an issue in the service_message.srv file. I dont know what exactly was my mistake, but I hope you can help me understand.

---
bool wallfound

This was the original .srv message I had typed.
I replaced it with another message from a tutorial with

int32 duration    # The time (in seconds) during which BB-8 will keep moving in circles
---
bool success      # Did it achieve it?

After running catkin_make it worked. Can you please explain why?
Thank you for your help

@mamojiz97 ,

I think I understand your problem exactly!. I believe you copy-pasted the service message as-is from the instructions/notebook? That is where the problem is…

In the notebook the message is typed as

FindWall.srv

---
bool wallfound

But instead, it should actually read: REPLACE YOUR SRV FILE CONTENTS WITH THIS

   # blank line here representing Empty service message request
---
bool wallfound

I believe you included the line FindWall.srv in your srv file which the CMake could not understand the data type of the variable. Therefore, you got that error.

Please change your service message to the modified lines above. This should fix the issue.
Let me know if this helped!

Regards,
Girish

2 Likes

@girishkumar.kannan
I did not actually, copy-pasted the message exactly. I did not include FindWall.srv in my srv file. Just like you said I left a blank space and then wrote the the response message of the srv file.
I received the same error message for this as well. I think it was something to do with the way I typed maybe in the indentations etc. Honestly I don’t think that was the case though.
Thank You

Hey @mamojiz97 ,

I think I found the issue…

The message imports in Python are CASE–SENSITIVE.

To Summarize:

  1. Replace from rosject.srv import Findwall, FindwallResponse with from rosject.srv import FindWall, FindWallResponse
  2. Change contents of FindWall.srv file as below:

---
bool wallfound
  1. Make sure your file formatting is set to ASCII / UTF-8 in your computer and does not use any fancy unicode characters.
  2. Last resort - if all above fails, re-create the package from scratch.

Let me know if this worked!

Regards,
Girish

1 Like

This topic was automatically closed after 3 days. New replies are no longer allowed.