# Getting an error while creating a service message

**URL:** <https://get-help.theconstruct.ai/t/getting-an-error-while-creating-a-service-message/19644>\
**Category:** ROSDS Support\
**Created:** [October 3, 2022, 12:54am UTC](https://get-help.theconstruct.ai/t/getting-an-error-while-creating-a-service-message/19644 "2022-10-03T00:54:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mamojiz97](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/m/2acd7d/32.png) [@mamojiz97](https://get-help.theconstruct.ai/u/mamojiz97)\
**Post date:** [October 3, 2022, 12:54am UTC](https://get-help.theconstruct.ai/t/getting-an-error-while-creating-a-service-message/19644/1 "2022-10-03T00:54:12Z")

</div>

![image](https://get-help.robotigniteacademy.com/uploads/default/original/2X/5/53fd61909f32a78771345a3d77107171a7d9731b.png)

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

---

<div class="post-metadata">

**Author:** ![roalgoal](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/roalgoal/32/7280_2.png) [@roalgoal](https://get-help.theconstruct.ai/u/roalgoal)\
**Post date:** [October 3, 2022, 8:01am UTC](https://get-help.theconstruct.ai/t/getting-an-error-while-creating-a-service-message/19644/2 "2022-10-03T08:01:44Z")

</div>

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

```auto
  <build_depend>message_generation</build_depend>
  <exec_depend>message_runtime</exec_depend>

```

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

---

<div class="post-metadata">

**Author:** ![mamojiz97](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/m/2acd7d/32.png) [@mamojiz97](https://get-help.theconstruct.ai/u/mamojiz97)\
**Post date:** [October 3, 2022, 7:11pm UTC](https://get-help.theconstruct.ai/t/getting-an-error-while-creating-a-service-message/19644/3 "2022-10-03T19:11:46Z")

</div>

@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:

```auto
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

---

<div class="post-metadata">

**Author:** ![mamojiz97](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/m/2acd7d/32.png) [@mamojiz97](https://get-help.theconstruct.ai/u/mamojiz97)\
**Post date:** [October 3, 2022, 8:34pm UTC](https://get-help.theconstruct.ai/t/getting-an-error-while-creating-a-service-message/19644/4 "2022-10-03T20:34:13Z")

</div>

@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.

```auto
---
bool wallfound

```

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

```auto
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

---

<div class="post-metadata">

**Author:** ![girishkumar.kannan](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/girishkumar.kannan/32/6994_2.png) [@girishkumar.kannan](https://get-help.theconstruct.ai/u/girishkumar.kannan)\
**Post date:** [October 4, 2022, 4:57am UTC](https://get-help.theconstruct.ai/t/getting-an-error-while-creating-a-service-message/19644/5 "2022-10-04T04:57:00Z")

</div>

@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

```auto
FindWall.srv

---
bool wallfound

```

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

```auto
   # 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

---

<div class="post-metadata">

**Author:** ![mamojiz97](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/m/2acd7d/32.png) [@mamojiz97](https://get-help.theconstruct.ai/u/mamojiz97)\
**Post date:** [October 4, 2022, 5:48pm UTC](https://get-help.theconstruct.ai/t/getting-an-error-while-creating-a-service-message/19644/6 "2022-10-04T17:48:43Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![girishkumar.kannan](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/girishkumar.kannan/32/6994_2.png) [@girishkumar.kannan](https://get-help.theconstruct.ai/u/girishkumar.kannan)\
**Post date:** [October 4, 2022, 8:02pm UTC](https://get-help.theconstruct.ai/t/getting-an-error-while-creating-a-service-message/19644/7 "2022-10-04T20:02:12Z")

</div>

Hey @mamojiz97 ,

I think I found the issue…

> [@mamojiz97](#):
>
> import rospy  
> from geometry\_msgs.msg import Twist  
> from sensor\_msgs.msg import LaserScan  
> from rosject.srv import Findwall, FindwallResponse \<— replace with FindWall, FindWallResponse

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:

```auto

---
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

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [October 8, 2022, 7:00am UTC](https://get-help.theconstruct.ai/t/getting-an-error-while-creating-a-service-message/19644/8 "2022-10-08T07:00:29Z")

</div>

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