Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action file support #311

Merged
merged 13 commits into from
Nov 7, 2018
Merged

Action file support #311

merged 13 commits into from
Nov 7, 2018

Conversation

sservulo
Copy link
Contributor

This PR closes #305. Added .action file parsing to rosidl_parser.
CMake preprocessing of .action files into services and messages is coming to this branch from sloretz/speficication-to-str.

@tfoote tfoote added the in progress Actively being worked on (Kanban column) label Oct 31, 2018
Copy link
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sservulo I left some comments, nice work!

lines[separator_indices[1] + 1:] + implicit_output)
feedback_msg = parse_message_string(
pkg_name, action_name + ACTION_FEEDBACK_MESSAGE_SUFFIX, message_string)
#----------------------------------------------------------------------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sservulo Hmm, implicit fields may clash with explicitly given ones. Action generation in ROS1 would nest message definition as a field of a completely implicit message, see genaction.py sources. Alternatively, we could check for the presence of duplicate entries. @sloretz @jacobperron thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. +1 to nesting the user defined message

Copy link
Contributor Author

@sservulo sservulo Nov 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other issues were already addressed. @sloretz, this one will probably delay a bit cmake header typesupport on #302 and #303 due to the need to update location assumptions of nested msgs.

@sservulo
Copy link
Contributor Author

sservulo commented Nov 1, 2018

Addressed review comments.

action_name + ACTION_GOAL_MESSAGE_SUFFIX + SERVICE_REQUEST_MESSAGE_SUFFIX,
request_message_string)

implicit_output = ["bool accepted", "builtin_interfaces/Time stamp"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobperron @hidmic Will rcl_actions associate the service response by mapping goal ID to the request sequence number, or by having the higher level client library get the goal ID out of the message? If the former then these fields should be OK, if the latter then the stamp field should be action_msgs/GoalInfo so it includes a goal id too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that'd be currently the case (using goal IDs I mean).

action_name + ACTION_RESULT_MESSAGE_SUFFIX + SERVICE_REQUEST_MESSAGE_SUFFIX,
request_message_string)

implicit_output = ["int8 status"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the status field for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the goal status as defined in the proposal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I completely forgot about that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobperron same question about rcl_actions using the sequence number vs goal id. If the latter then using action_msgs/GoalStatus here would get that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@sloretz
Copy link
Contributor

sloretz commented Nov 1, 2018

Besides a couple questions about the implicit fields, I think with a couple unit tests for parsing actions I think this could be merged, and then #310 could be re-targeted at master.

@sservulo
Copy link
Contributor Author

sservulo commented Nov 6, 2018

Added tests to Action parser and included some fixes in implicit field collision logic. Note that the Action messages suffixes were changed in 3c4df0a to be compliant with message name regex.

@hidmic
Copy link
Contributor

hidmic commented Nov 6, 2018

@sloretz @jacobperron I'd say we get this one in to unblock the rest. If the current set of implicit fields is later unfit (which I'm inclined to think but we may find out that it's not), we can change them.

Copy link
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review.

I think the current set of implicit fields are okay, although we might consider using types defined in action_msgs so then any changes there are automatically reflected in the generated services/topics. I'm okay with merging this as is pending the one comment regarding the check for implicit field collisions.

# check for field name collision with action implicit parameters
# (e.g. 2 or more occurrences of a field_name contained in ACTION_IMPLICIT_FIELDS,
# including the implicit one)
if field_name in ACTION_IMPLICIT_FIELDS and action_fields[field_name] >= 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that .msg or .srv specs containing an implicit action field will also raise a collision exception?
If so, maybe it would be better to pass in a list of invalid fields to the function instead of using ACTION_IMPLICIT_FIELDS directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobperron It will trigger only if a field named with the same name as one implicit field is in the spec and there are at least two of them (replacing a ValueType error in this case), to make sure it triggers only when there's duplication, so if you have a field named uuid used in your msg definition it will not trigger. Should I go with the invalid fields route, then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification. I think it is fine to leave it as-is.


import pytest

# from rosidl_parser import InvalidServiceSpecification
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove comment

@jacobperron
Copy link
Member

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@hidmic hidmic added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Nov 7, 2018
@hidmic
Copy link
Contributor

hidmic commented Nov 7, 2018

@jacobperron @sservulo looks like this one's ready to go!



def parse_action_string(pkg_name, action_name, action_string):
action_blocks = action_string.split(ACTION_REQUEST_RESPONSE_SEPARATOR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is incorrect. It e.g. even matches a --- in a comment. Please use the same logic as for splitting the request and response in a service.

Copy link
Contributor

@hidmic hidmic Nov 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I had not considered the possibility of a separator in comments. So it's either above's logic using slices or re.split('^---$', action_string, flags=re.MULTILINE).

Copy link
Contributor Author

@sservulo sservulo Nov 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed using re w/ multiline. @dirk-thomas Is this approach OK for you or do you have a strong preference for the slice logic?

@sservulo sservulo merged commit 82a6a5f into master Nov 7, 2018
@tfoote tfoote removed the in review Waiting for review (Kanban column) label Nov 7, 2018
@sservulo sservulo deleted the sservulo/305-parse_action_file branch November 8, 2018 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse .action files
6 participants