ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

I think you can use constants in ROS messages:

http://www.ros.org/wiki/msg#Constants

They don't map explicitly to higher-level enum types in programming languages, but they generally let you deal with the same issues. E.g.

string eStop            # Enum {autoAck, manual, remote, none} Acknowledge-Type of eStop: 
                        # autoAck: autoacknowledgeable e-stop is activated e.g. by bumper or protective field
                        # manual: e-stop has to be acknowledged manually at the vehicle 
                        # remote: facility estop has to be acknowledged remotely 
                        # none: no e-stop activated
bool fieldViolation     # Protective field violation. True: field is violated False: field is not violated 

# Enums for eStop
string AUTO_ACK=autoAck
string MANUAL=manual
string REMOTE=remote
string NONE=none

In your case, there is also a naming error - fields cannot just have numbers as their name:

Field names must be translated by message generators to several target languages, so we restrict field names to be an alphabetical character followed by any mixture of alphanumeric and underscores, i.e. [a-zA-Z][a-zA-Z1-9_]*. It is recommended that you avoid using field names that correspond to keywords in common languages -- although those names are legal, they create confusion as to how a field name is translated.

from 2.1.2 there: https://wiki.ros.org/msg

I think you can use constants in ROS messages:

http://www.ros.org/wiki/msg#Constants

They don't map explicitly to higher-level enum types in programming languages, but they generally let you deal with the same issues. E.g.

string eStop            # Enum {autoAck, manual, remote, none} Acknowledge-Type of eStop: 
                        # autoAck: autoacknowledgeable e-stop is activated e.g. by bumper or protective field
                        # manual: e-stop has to be acknowledged manually at the vehicle 
                        # remote: facility estop has to be acknowledged remotely 
                        # none: no e-stop activated
bool fieldViolation     # Protective field violation. True: field is violated False: field is not violated 

# Enums for eStop
string AUTO_ACK=autoAck
string MANUAL=manual
string REMOTE=remote
string NONE=none

In your case, there is also a naming error - fields cannot just have numbers as their name:

Field names must be translated by message generators to several target languages, so we restrict field names to be an alphabetical character followed by any mixture of alphanumeric and underscores, i.e. [a-zA-Z][a-zA-Z1-9_]*. It is recommended that you avoid using field names that correspond to keywords in common languages -- although those names are legal, they create confusion as to how a field name is translated.

from 2.1.2 there: https://wiki.ros.org/msg

I want to use only the numbers from 0 to 100 at the end. In the example above there was only a section from 0 to 10.

If you want to filter published messages by a range of accepted values, this should be done on the publisher side, e.g. in the callback. AFAIK there is no mechanism for this in ROS1 by message definition (and even in ROS2 it's only for the size of a bounded dynamic array: a bounded dynamic array is described by the suffix [<=N] where N is the maximum size of the array, not its values).

I think you can use constants in ROS messages:

http://www.ros.org/wiki/msg#Constants

They don't map explicitly to higher-level enum types in programming languages, but they generally let you deal with the same issues. E.g.

string eStop            # Enum {autoAck, manual, remote, none} Acknowledge-Type of eStop: 
                        # autoAck: autoacknowledgeable e-stop is activated e.g. by bumper or protective field
                        # manual: e-stop has to be acknowledged manually at the vehicle 
                        # remote: facility estop has to be acknowledged remotely 
                        # none: no e-stop activated
bool fieldViolation     # Protective field violation. True: field is violated False: field is not violated 

# Enums for eStop
string AUTO_ACK=autoAck
string MANUAL=manual
string REMOTE=remote
string NONE=none

In your case, there is also a naming error - fields cannot just have numbers as their name:

Field names must be translated by message generators to several target languages, so we restrict field names to be an alphabetical character followed by any mixture of alphanumeric and underscores, i.e. [a-zA-Z][a-zA-Z1-9_]*. It is recommended that you avoid using field names that correspond to keywords in common languages -- although those names are legal, they create confusion as to how a field name is translated.

from 2.1.2 there: https://wiki.ros.org/msg

I want to use only the numbers from 0 to 100 at the end. In the example above there was only a section from 0 to 10.

If you want to filter published messages by a range of accepted values, this should be done on the publisher publisher/subscriber side, e.g. in the callback. AFAIK there is no filtering mechanism for this in ROS1 by message definition (and even in ROS2 it's only for the size of a bounded dynamic array: a bounded dynamic array is described by the suffix [<=N] where N is the maximum size of the array, not its values).