Attribute error on callback of custom service

I have created a custom service
MyCustomServiceMessage.srv
int32 duration

bool success

The server runs
my_service = rospy.Service(’/move_bb8_in_circle_custom’,MyCustomServiceMessage, my_callback)

In the callback I create dataResponse = MyCustomServiceMessageResponse()
And then try to assign tDur = dataResponse.duration

The input this tries to read is from terminal 2: rosservice call /move_bb8_in_circle_custom “duration: 5”

Error in terminal 1:[ERROR] [1600098359.901894, 1212.051000]: Error processing request: ‘MyCustomServiceMessageResponse’ object has no attribute ‘duration’
[‘Traceback (most recent call last):\n’, ’ File “/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py”, line 625, in _handle_request\n response = convert_return_to_response(self.handler(request), self.response_class)\n’, ’ File “/home/user/catkin_ws/src/my_custom_srv_msg_pkg/src/bb8_move_custom_service_server.py”, line 11, in my_callback\n tDur = dataResponse.duration\n’, “AttributeError: ‘MyCustomServiceMessageResponse’ object has no attribute ‘duration’\n”]

Error message in terminal 2: ERROR: service [/move_bb8_in_circle_custom] responded with an error: error processing request: ‘MyCustomServiceMessageResponse’ object has no attribute ‘duration’

Before people ask, yes I have sourced devel/setup.bash in all terminals. I have also attempted to build multiple times, cleaning out build and devel a few times so I know catkin_make didn’t crash. Yes, I have gone over the makefile and package.xml file. They are to specification of unit 4 part 2.
I have error checked them a lot, and when I couldn’t trust me eyes anymore I tried to paste over a clean solution.

Please note this is not part of an exorcise, the unit just suggest you attempt to call it like we did previously to check if it was working after setup.

So my question is, is there a fundamental step I have missed here?

Hello @s325927,

Your message definition is like this:

int32 duration
---
bool success

So, the duration attribute is not in the response of the message, but in the request. Therefore, if you try to use this duration variable in the response, it’s not going to find it. For the response you only have the attribute success defined.

Best,

Thank you Alberto, I had completely missed that part.