ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
robotics.h
Go to the documentation of this file.
1// ProtoCore v1.0.16 - Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4#ifndef PROTOCORE_ROBOTICS_H
5#define PROTOCORE_ROBOTICS_H
6
7#include "protocore_config.h" // the entry point: protocore_types.h for the widths
8
10
11/**
12 * @file robotics.h
13 * @brief OPC UA for Robotics (OPC 40010-1) MotionDevice information model (PROTOCORE_ENABLE_ROBOTICS).
14 *
15 * OPC 40010-1 "OPC UA for Robotics - Part 1: Vertical Integration" (VDMA / OPC Foundation, namespace
16 * `http://opcfoundation.org/UA/Robotics/`) standardizes how an industrial robot / motion device exposes
17 * its identity and live motion state so any OPC UA client (UaExpert, python `asyncua`, open62541, ...)
18 * reads the same MotionDeviceSystem structure across vendors.
19 *
20 * This module builds the MotionDeviceSystem address space on top of the OPC UA Binary server
21 * (`services/opcua`, PROTOCORE_ENABLE_OPCUA): it registers a Browse + Read resolver that answers for the
22 * MotionDeviceSystem node hierarchy and serves live values out of a caller-owned @ref
23 * RoboticsMotionDeviceSystem struct you refresh in your loop. Same pattern as `services/umati`
24 * (OPC 40501-1); no heap, no stdlib - the model is a fixed node table, the values are pointers/scalars
25 * in your struct.
26 *
27 * Model exposed (BrowseNames per OPC 40010-1), under the Objects folder:
28 *
29 * MotionDeviceSystem
30 * MotionDevices (Folder)
31 * MotionDevice Manufacturer, Model, ProductCode, SerialNumber, MotionDeviceCategory
32 * ParameterSet OnPath, InControl, SpeedOverride
33 * Axes (Folder)
34 * Axis_1..N ActualPosition, ActualSpeed, ActualAcceleration, MotionProfile
35 * Controllers (Folder)
36 * Controller Manufacturer, Model, ProductCode, SerialNumber
37 * Software Manufacturer, Model, SoftwareRevision
38 * SafetyStates (Folder)
39 * SafetyState
40 * ParameterSet OperationalMode, EmergencyStop, ProtectiveStop
41 *
42 * The model is read-only (a monitoring model - the robot reports, the client observes). Scope note: one
43 * MotionDevice / Controller / SafetyState and PROTOCORE_ROBOTICS_AXES parametric axes are exposed (the common
44 * embedded robot); the values carry faithful BrowseNames, but the companion-spec TypeDefinitions,
45 * PowerTrains, and the NamespaceArray entry for the Robotics URI (which needs array-Variant support in
46 * the base server) are a documented follow-on - a generic OPC UA client still browses the structure and
47 * reads every value by BrowseName today.
48 *
49 * @c work is PROTOCORE_ROBOTICS_BORROW bytes the CALLER took, at an address it knows. It is not held past the call, so
50 * nothing here aliases it. How those bytes are carved is this module's and is never named here.
51 *
52 * @author Douglas Quigg (dstroy0)
53 * @date 2026
54 */
55
56/** @brief The OPC UA for Robotics companion-spec namespace URI (OPC 40010-1). */
57#define ROBOTICS_NS_URI "http://opcfoundation.org/UA/Robotics/"
58
59/**
60 * @brief MotionDeviceCategory (OPC 40010-1 MotionDeviceCategoryEnumeration). Exposed as Int32; the
61 * numeric values follow the companion-spec enumeration.
62 */
64{
65 ROBOTICS_CAT_OTHER = 0, ///< a category outside the ones below.
66 ROBOTICS_CAT_ARTICULATED_ROBOT = 1, ///< articulated (jointed-arm) robot.
67 ROBOTICS_CAT_SCARA_ROBOT = 2, ///< SCARA robot.
68 ROBOTICS_CAT_CARTESIAN_ROBOT = 3, ///< cartesian / gantry robot.
69 ROBOTICS_CAT_SPHERICAL_ROBOT = 4, ///< spherical / polar robot.
70 ROBOTICS_CAT_PARALLEL_ROBOT = 5, ///< parallel (delta) robot.
71 ROBOTICS_CAT_CYLINDRICAL_ROBOT = 6, ///< cylindrical robot.
73
74/**
75 * @brief Axis MotionProfile (OPC 40010-1 AxisMotionProfileEnumeration). Exposed as Int32; the numeric
76 * values follow the companion-spec enumeration.
77 */
79{
80 ROBOTICS_PROFILE_OTHER = 0, ///< a profile outside the ones below.
81 ROBOTICS_PROFILE_ROTARY = 1, ///< rotary axis (bounded travel).
82 ROBOTICS_PROFILE_ROTARY_ENDLESS = 2, ///< rotary axis with endless rotation.
83 ROBOTICS_PROFILE_LINEAR = 3, ///< linear axis (bounded travel).
84 ROBOTICS_PROFILE_LINEAR_ENDLESS = 4, ///< linear axis with endless travel.
86
87/**
88 * @brief SafetyState OperationalMode (OPC 40010-1 OperationalModeEnumeration). Exposed as Int32; the
89 * numeric values follow the companion-spec enumeration.
90 */
92{
93 ROBOTICS_MODE_OTHER = 0, ///< a mode outside the ones below.
94 ROBOTICS_MODE_MANUAL_REDUCED_SPEED = 1, ///< manual jog, reduced speed (T1).
95 ROBOTICS_MODE_MANUAL_HIGH_SPEED = 2, ///< manual, high speed (T2).
96 ROBOTICS_MODE_AUTOMATIC = 3, ///< automatic program execution.
97 ROBOTICS_MODE_AUTOMATIC_EXTERNAL = 4, ///< automatic, externally commanded.
99
100/** @brief One axis' live monitoring values (OPC 40010-1 AxisType, common subset). */
101typedef struct
102{
103 double actual_position; ///< ActualPosition (mm or deg).
104 double actual_speed; ///< ActualSpeed.
105 double actual_acceleration; ///< ActualAcceleration.
108
109/** @brief The Controller identity + software (OPC 40010-1 ControllerType + SoftwareType). */
110typedef struct
111{
112 const char *manufacturer; ///< Manufacturer (LocalizedText -> String).
113 const char *model; ///< Model (LocalizedText -> String).
114 const char *product_code; ///< ProductCode (String).
115 const char *serial_number; ///< SerialNumber (String).
116 const char *sw_manufacturer; ///< Software.Manufacturer (String).
117 const char *sw_model; ///< Software.Model (String).
118 const char *sw_revision; ///< Software.SoftwareRevision (String).
120
121/** @brief The SafetyState (OPC 40010-1 SafetyStateType, common subset). */
122typedef struct
123{
124 RoboticsOperationalMode operational_mode; ///< ParameterSet.OperationalMode.
125 proto_bool emergency_stop; ///< ParameterSet.EmergencyStop.
126 proto_bool protective_stop; ///< ParameterSet.ProtectiveStop.
128
129/** @brief One MotionDevice: identity + live motion state (OPC 40010-1 MotionDeviceType, common subset). */
130typedef struct
131{
132 const char *manufacturer; ///< Manufacturer (LocalizedText -> String).
133 const char *model; ///< Model (LocalizedText -> String).
134 const char *product_code; ///< ProductCode (String).
135 const char *serial_number; ///< SerialNumber (String).
136 RoboticsMotionDeviceCategory category; ///< MotionDeviceCategory.
137 proto_bool on_path; ///< ParameterSet.OnPath.
138 proto_bool in_control; ///< ParameterSet.InControl.
139 double speed_override; ///< ParameterSet.SpeedOverride (%).
140 uint32_t axis_count; ///< number of Axes exposed (<= PROTOCORE_ROBOTICS_AXES).
141 RoboticsAxis axes[PROTOCORE_ROBOTICS_AXES]; ///< the axes (axes[0..axis_count-1] are live).
143
144/**
145 * @brief The whole MotionDeviceSystem the server exposes. Own it in your sketch and refresh its fields
146 * each loop from your robot I/O; the robotics resolvers read straight out of it (no copy). String
147 * fields may be null (served as an empty String).
148 */
149typedef struct
150{
151 const char *name; ///< MotionDeviceSystem BrowseName / DisplayName.
152 RoboticsMotionDevice device; ///< the MotionDevice.
153 RoboticsController controller; ///< the Controller.
154 RoboticsSafetyState safety; ///< the SafetyState.
156
157/** @brief Dispatch table. Addressed by offset, so the layout is asserted below. */
158typedef struct
159{
160 void (*bind)(uint8_t *, const RoboticsMotionDeviceSystem *);
161 void (*install)(uint8_t *, const RoboticsMotionDeviceSystem *);
162} RoboticsNs;
164
165/**
166 * @brief Bind the MotionDeviceSystem the resolvers serve. mds must outlive .
167 * @param work PROTOCORE_ROBOTICS_BORROW bytes the caller took. Not held past the call.
168 * @param mds Mds
169 */
171/**
172 * @brief Convenience: bind mds and register both resolvers on the OPC UA .
173 * @param work PROTOCORE_ROBOTICS_BORROW bytes the caller took. Not held past the call.
174 * @param mds Mds
175 */
177
178/**
179 * @brief The PROTOCORE_ROBOTICS_BORROW bytes this module's state lives in.
180 *
181 * Stated beside the namespace rather than on it: an entry takes a borrow, and this is where
182 * that borrow comes from. Taken once from the end of the pool, which no mark and no release
183 * walks, so the state lasts the life of the program.
184 *
185 * @return the span.
186 */
188
189/** @brief Module namespace. */
192
194
195#endif // PROTOCORE_ROBOTICS_H
#define PROTOCORE_ROBOTICS_AXES
Number of Axes the robotics MotionDevice exposes (default 6; must fit PROTOCORE_OPCUA_REF_MAX).
PROTO_ENUM_PACKED
Application protocol spoken on a listener port or connection slot.
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
enum PROTO_ENUM_PACKED RoboticsOperationalMode
SafetyState OperationalMode (OPC 40010-1 OperationalModeEnumeration). Exposed as Int32; the numeric v...
PROTOCORE_NS RoboticsNs Robotics PROTOCORE_UNUSED
Module namespace.
Definition robotics.h:190
enum PROTO_ENUM_PACKED RoboticsMotionDeviceCategory
MotionDeviceCategory (OPC 40010-1 MotionDeviceCategoryEnumeration). Exposed as Int32; the numeric val...
void protocore_robotics_install(uint8_t *work, const RoboticsMotionDeviceSystem *mds)
Convenience: bind mds and register both resolvers on the OPC UA .
enum PROTO_ENUM_PACKED RoboticsMotionProfile
Axis MotionProfile (OPC 40010-1 AxisMotionProfileEnumeration). Exposed as Int32; the numeric values f...
@ ROBOTICS_MODE_AUTOMATIC_EXTERNAL
automatic, externally commanded.
Definition robotics.h:97
@ ROBOTICS_CAT_SCARA_ROBOT
SCARA robot.
Definition robotics.h:67
@ ROBOTICS_CAT_SPHERICAL_ROBOT
spherical / polar robot.
Definition robotics.h:69
@ ROBOTICS_PROFILE_ROTARY_ENDLESS
rotary axis with endless rotation.
Definition robotics.h:82
@ ROBOTICS_MODE_MANUAL_HIGH_SPEED
manual, high speed (T2).
Definition robotics.h:95
@ ROBOTICS_CAT_CYLINDRICAL_ROBOT
cylindrical robot.
Definition robotics.h:71
@ ROBOTICS_PROFILE_ROTARY
rotary axis (bounded travel).
Definition robotics.h:81
@ ROBOTICS_PROFILE_LINEAR_ENDLESS
linear axis with endless travel.
Definition robotics.h:84
@ ROBOTICS_CAT_PARALLEL_ROBOT
parallel (delta) robot.
Definition robotics.h:70
@ ROBOTICS_MODE_OTHER
a mode outside the ones below.
Definition robotics.h:93
@ ROBOTICS_CAT_ARTICULATED_ROBOT
articulated (jointed-arm) robot.
Definition robotics.h:66
@ ROBOTICS_MODE_AUTOMATIC
automatic program execution.
Definition robotics.h:96
@ ROBOTICS_PROFILE_LINEAR
linear axis (bounded travel).
Definition robotics.h:83
@ ROBOTICS_CAT_OTHER
a category outside the ones below.
Definition robotics.h:65
@ ROBOTICS_PROFILE_OTHER
a profile outside the ones below.
Definition robotics.h:80
@ ROBOTICS_MODE_MANUAL_REDUCED_SPEED
manual jog, reduced speed (T1).
Definition robotics.h:94
@ ROBOTICS_CAT_CARTESIAN_ROBOT
cartesian / gantry robot.
Definition robotics.h:68
void protocore_robotics_bind(uint8_t *work, const RoboticsMotionDeviceSystem *mds)
Bind the MotionDeviceSystem the resolvers serve. mds must outlive .
uint8_t * protocore_robotics_span(void)
The PROTOCORE_ROBOTICS_BORROW bytes this module's state lives in.
One axis' live monitoring values (OPC 40010-1 AxisType, common subset).
Definition robotics.h:102
double actual_position
ActualPosition (mm or deg).
Definition robotics.h:103
RoboticsMotionProfile motion_profile
MotionProfile.
Definition robotics.h:106
double actual_acceleration
ActualAcceleration.
Definition robotics.h:105
double actual_speed
ActualSpeed.
Definition robotics.h:104
The Controller identity + software (OPC 40010-1 ControllerType + SoftwareType).
Definition robotics.h:111
const char * serial_number
SerialNumber (String).
Definition robotics.h:115
const char * sw_manufacturer
Software.Manufacturer (String).
Definition robotics.h:116
const char * sw_model
Software.Model (String).
Definition robotics.h:117
const char * manufacturer
Manufacturer (LocalizedText -> String).
Definition robotics.h:112
const char * product_code
ProductCode (String).
Definition robotics.h:114
const char * sw_revision
Software.SoftwareRevision (String).
Definition robotics.h:118
const char * model
Model (LocalizedText -> String).
Definition robotics.h:113
The whole MotionDeviceSystem the server exposes. Own it in your sketch and refresh its fields each lo...
Definition robotics.h:150
const char * name
MotionDeviceSystem BrowseName / DisplayName.
Definition robotics.h:151
RoboticsSafetyState safety
the SafetyState.
Definition robotics.h:154
RoboticsMotionDevice device
the MotionDevice.
Definition robotics.h:152
RoboticsController controller
the Controller.
Definition robotics.h:153
One MotionDevice: identity + live motion state (OPC 40010-1 MotionDeviceType, common subset).
Definition robotics.h:131
const char * manufacturer
Manufacturer (LocalizedText -> String).
Definition robotics.h:132
double speed_override
ParameterSet.SpeedOverride (%).
Definition robotics.h:139
RoboticsMotionDeviceCategory category
MotionDeviceCategory.
Definition robotics.h:136
proto_bool on_path
ParameterSet.OnPath.
Definition robotics.h:137
proto_bool in_control
ParameterSet.InControl.
Definition robotics.h:138
uint32_t axis_count
number of Axes exposed (<= PROTOCORE_ROBOTICS_AXES).
Definition robotics.h:140
const char * product_code
ProductCode (String).
Definition robotics.h:134
const char * model
Model (LocalizedText -> String).
Definition robotics.h:133
const char * serial_number
SerialNumber (String).
Definition robotics.h:135
Dispatch table. Addressed by offset, so the layout is asserted below.
Definition robotics.h:159
void(* bind)(uint8_t *, const RoboticsMotionDeviceSystem *)
Definition robotics.h:160
The SafetyState (OPC 40010-1 SafetyStateType, common subset).
Definition robotics.h:123
RoboticsOperationalMode operational_mode
ParameterSet.OperationalMode.
Definition robotics.h:124
proto_bool protective_stop
ParameterSet.ProtectiveStop.
Definition robotics.h:126
proto_bool emergency_stop
ParameterSet.EmergencyStop.
Definition robotics.h:125
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition types.h:96
_Bool proto_bool
The truth value.
Definition types.h:64
#define PROTOCORE_END_DECLS
Definition types.h:97