Add --message field to the creation of ROS2 packages.#1202
Add --message field to the creation of ROS2 packages.#1202leander-dsouza wants to merge 4 commits intoros2:rollingfrom
--message field to the creation of ROS2 packages.#1202Conversation
Signed-off-by: Leander Stephen D'Souza <leanderdsouza1234@gmail.com>
Signed-off-by: Leander Stephen D'Souza <leanderdsouza1234@gmail.com>
peci1
left a comment
There was a problem hiding this comment.
Thanks, I have a few small comments, but nothing important.
| @@ -0,0 +1,5 @@ | |||
| # TODO: Define the message fields here. | |||
There was a problem hiding this comment.
License text is missing. However, the other template files also don't have it, so maybe let's leave it to another PR.
There was a problem hiding this comment.
Yes, sure.
We can add the license texts to all the template files in a future PR.
… types. Signed-off-by: Leander Stephen D'Souza <leanderdsouza1234@gmail.com>
|
Friendly ping to @fujitatomoya for a review :) |
| if args.message: | ||
| if args.build_type != 'ament_cmake': | ||
| return "Aborted: --message is only supported with 'ament_cmake' build type." | ||
|
|
||
| invalid = [ | ||
| name for name in args.message | ||
| if not re.match(r'^[A-Z][A-Za-z0-9]*$', name) | ||
| ] | ||
| if invalid: | ||
| return 'Aborted: invalid message name(s): ' + ', '.join(invalid) + \ | ||
| '. Message names must be CamelCase and alphanumeric (e.g. MyMsg).' |
There was a problem hiding this comment.
should we check the message duplication check here? e.g --message MyMsg MyMsg.
There was a problem hiding this comment.
I have added a check to prevent duplicate messages :)
ros2pkg/ros2pkg/verb/create.py
Outdated
|
|
||
| invalid = [ | ||
| name for name in args.message | ||
| if not re.match(r'^[A-Z][A-Za-z0-9]*$', name) |
There was a problem hiding this comment.
this allows single-character names like M. while technically this is CamelCase, this might be unintentional?
There was a problem hiding this comment.
I have expanded the regex to now allow a minimum of two-letter messages.
So now M.msg is disallowed, whereas My.msg is permitted.
…g field. Signed-off-by: Leander Stephen D'Souza <leanderdsouza1234@gmail.com>
Basic Info
Description
--messagefield to theros2 pkg createcommand.MyMsg.msgament_cmakebuild type.MyMsgandOtherMsg.Usage
You can include the
--messagefield followed by an indefinite number of messages as follows:If you include an invalid message name, it would fail the creation step:
The creation step would also fail if the build type is not
ament_cmake:$ ros2 pkg create tutorial_interfaces --build-type ament_python --license Apache-2.0 --message MyMsg Aborted: --message is only supported with 'ament_cmake' build type.Is this user-facing behaviour change?
Yes, please refer to the
Usagesection for more details on how the implementation affects the user's creation of the ROS2 package.Did you use Generative AI?
No
Additional Information
Future work can include adding fields for actions and services.