Constants
Overview
Robot Raconteur defines two types of constants: enum and const. An enum is a set of named integer
constants, while a const is a named constant of a specific type.
Constants are made available to clients when they connect to a service, or are generated
as part of “thunk” code for statically typed languages.
Enum Types
Enums are defined using the enum keyword.
The following is an example of an enum definition from com.robotraconteur.robotics.robot service definition:
enum RobotCommandMode
invalid_state = -1,
halt = 0,
jog,
trajectory,
position_command,
velocity_command,
homing
end
Example code excerpts demonstrating the use of enums:
Constants
Constants are declared using the const keyword. Constants can be numbers, numeric arrays, or strings.
Strings can use JSON encoding to represent special characters. const can be defined at the service level or within
an object.
Constants are accessed the same way as enums, but there is a single value.
The following is an example of a constant definition from the experimental.create3.Create object:
Example code excerpts demonstrating the use of constants: