0
$\begingroup$

Rosanswers logo

Hi,

i have a msg package with a custom message like this:

MyStruct.msg
...
/* Content of MyStruct*/
HeaderStruct header
DataStruct data

using this msg type in different Nodes

Now i want to implement a srv using MyStruct.msg I modified my CmakeLists.txt of my service package with:

find_package(my_msgs REQUIRED)

and added to the package.xml

 <build_depend>my_msgs</build_depend>
 <exec_depend>my_msgs</exec_depend>

In the srv file i added

my_msgs/MyStruct data
---
float64 result
int64 calculation_time

but when building i always get the error

AttributeError: 'ServiceSpecification' object has no attribute 'base_type'

as soon as switching to this

float64 data
---
float64 result
int64 calculation_time

it works ... am i missing something ? Thanks!


Originally posted by bhmth on ROS Answers with karma: 13 on 2018-07-03

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

My guess is that you are missing the dependency in the rosidl_generate_interfaces call.

it should look like:

rosidl_generate_interfaces(<MY_MESSAGE_TARGET>
  "srv/MySrv.srv"
  DEPENDENCIES my_msgs
)

You can refer to sensor_msgs for an example,

HTH

Edit:

should definitely be mentioned here https://github.com/ros2/ros2/wiki/About-ROS-Interfaces

I agree that this should be documented. Though, that wiki page is about the structure of the msg/srv files and doesn't make reference to the cmake code to generate them so I don't think this is the right place for it. A rosidl tutorial would be more appropriate. I started a draft at https://github.com/ros2/ros2/wiki/Rosidl-Tutorial but didnt get to finishing it and submitting the corresponding code yet.


Originally posted by marguedas with karma: 3606 on 2018-07-03

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by bhmth on 2018-07-04:
That was the deal. Thank you very much ! should definitely be mentioned here

https://github.com/ros2/ros2/wiki/About-ROS-Interfaces

Comment by marguedas on 2018-07-04:
If this answer solves your problem, please mark it as accepted (using the checkmark) so that community members know the question has been answered successfully

Comment by Dirk Thomas on 2018-07-05:
@bhmth the page you referenced in your comment is a publically editable wiki. Please feel free to contribute to it by adding additional information where you think it would be helpful.

Comment by lucasw on 2018-10-26:
Misspelling a type in a srv like int64 produces an error like rosidl_parser.InvalidResourceName: int364, misspelling std_msgs/Header results in the AttributeError, but look a few lines below for the fatal error: std_msg/msg/header__struct.h: No such file or directory (std_msg -> std_msgs)

Comment by lucasw on 2018-10-26:
Making same error in a .msg produces more helfpul message like 'Message interface ... contains an unknown field type: std_msg/Header header' (both of these are for bouncy)

Comment by lucasw on 2018-10-26:
In Ubuntu a 'Crash report' dialog pops up for every failed build with this type of error 'Sorry, the application rosidl_generator_c has stopped unexpectedly'.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.