Yes you can:
# MyAction.action
# Goal constants
uint8 AAAAAAAAAAAAAAAAAAAAAAAAAA = 42
---
# Result constants
uint8 BBBBBBBBBBBBBBBBBBBBBBBBBB = 42
---
# Feedback constants
uint8 CCCCCCCCCCCCCCCCCCCCCCCCCC = 42
Build it
To access each one :
# my_script.py
from my_robot.msg import MyActionGoal, MyActionFeedback, MyActionResult
print(MyActionGoal.AAAAAAAAAAAAAAAAAAAAAAAAAA)
print(MyActionFeedback.CCCCCCCCCCCCCCCCCCCCCCCCCC)
print(MyActionResult.BBBBBBBBBBBBBBBBBBBBBBBBBB)
EXTRA tip to check if it's defined:
# my_script.py
from my_robot.msg import MyActionGoal, MyActionFeedback, MyActionResult
print(MyActionGoal.__dict__.keys())
print(MyActionFeedback.__dict__.keys())
print(MyActionResult.__dict__.keys())
You'll get something like this:
['AAAAAAAAAAAAAAAAAAAAAAAAAA', 'deserialize_numpy', '_type', 'deserialize', '_has_header', '_slot_types', 'serialize', '_full_text',
'__module__', '_md5sum', '_get_types', '__slots__', '__doc__', 'serialize_numpy', '__init__']
['deserialize_numpy', '_type', 'deserialize', '_has_header', '_slot_types', 'serialize', '_full_text', '__module__', '_md5sum', '_get
_types', '__slots__', '__doc__', 'CCCCCCCCCCCCCCCCCCCCCCCCCC', 'serialize_numpy', '__init__']
['deserialize_numpy', '_type', 'deserialize', '_has_header', '_slot_types', 'serialize', '_full_text', '__module__', 'BBBBBBBBBBBBBBB
BBBBBBBBBBB', '_md5sum', '_get_types', '__slots__', '__doc__', 'serialize_numpy', '__init__']
In what way does it not work? At first glance it seems correct.
Well, as you told in the wiki, you can declare and assign constant in msgs types so I assume that can be done in action msgs too. This is because when catkin generate their bindings it is generating the necessary msgs types for the action.