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
9EMBED_BEGIN_DECLS
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 */
63EMBED_ENUM_BYTE(RoboticsMotionDeviceCategory,
64 ROBOTICS_CAT_OTHER = 0, ///< a category outside the ones below.
65 ROBOTICS_CAT_ARTICULATED_ROBOT = 1, ///< articulated (jointed-arm) robot.
66 ROBOTICS_CAT_SCARA_ROBOT = 2, ///< SCARA robot.
67 ROBOTICS_CAT_CARTESIAN_ROBOT = 3, ///< cartesian / gantry robot.
68 ROBOTICS_CAT_SPHERICAL_ROBOT = 4, ///< spherical / polar robot.
69 ROBOTICS_CAT_PARALLEL_ROBOT = 5, ///< parallel (delta) robot.
70 ROBOTICS_CAT_CYLINDRICAL_ROBOT = 6, ///< cylindrical robot.
71);
72
73/**
74 * @brief Axis MotionProfile (OPC 40010-1 AxisMotionProfileEnumeration). Exposed as Int32; the numeric
75 * values follow the companion-spec enumeration.
76 */
77EMBED_ENUM_BYTE(RoboticsMotionProfile,
78 ROBOTICS_PROFILE_OTHER = 0, ///< a profile outside the ones below.
79 ROBOTICS_PROFILE_ROTARY = 1, ///< rotary axis (bounded travel).
80 ROBOTICS_PROFILE_ROTARY_ENDLESS = 2, ///< rotary axis with endless rotation.
81 ROBOTICS_PROFILE_LINEAR = 3, ///< linear axis (bounded travel).
82 ROBOTICS_PROFILE_LINEAR_ENDLESS = 4, ///< linear axis with endless travel.
83);
84
85/**
86 * @brief SafetyState OperationalMode (OPC 40010-1 OperationalModeEnumeration). Exposed as Int32; the
87 * numeric values follow the companion-spec enumeration.
88 */
89EMBED_ENUM_BYTE(RoboticsOperationalMode,
90 ROBOTICS_MODE_OTHER = 0, ///< a mode outside the ones below.
91 ROBOTICS_MODE_MANUAL_REDUCED_SPEED = 1, ///< manual jog, reduced speed (T1).
92 ROBOTICS_MODE_MANUAL_HIGH_SPEED = 2, ///< manual, high speed (T2).
93 ROBOTICS_MODE_AUTOMATIC = 3, ///< automatic program execution.
94 ROBOTICS_MODE_AUTOMATIC_EXTERNAL = 4, ///< automatic, externally commanded.
95);
96
97/** @brief One axis' live monitoring values (OPC 40010-1 AxisType, common subset). */
98typedef struct
99{
100 double actual_position; ///< ActualPosition (mm or deg).
101 double actual_speed; ///< ActualSpeed.
102 double actual_acceleration; ///< ActualAcceleration.
103 RoboticsMotionProfile motion_profile; ///< MotionProfile.
105
106/** @brief The Controller identity + software (OPC 40010-1 ControllerType + SoftwareType). */
107typedef struct
108{
109 const char *manufacturer; ///< Manufacturer (LocalizedText -> String).
110 const char *model; ///< Model (LocalizedText -> String).
111 const char *product_code; ///< ProductCode (String).
112 const char *serial_number; ///< SerialNumber (String).
113 const char *sw_manufacturer; ///< Software.Manufacturer (String).
114 const char *sw_model; ///< Software.Model (String).
115 const char *sw_revision; ///< Software.SoftwareRevision (String).
117
118/** @brief The SafetyState (OPC 40010-1 SafetyStateType, common subset). */
119typedef struct
120{
121 RoboticsOperationalMode operational_mode; ///< ParameterSet.OperationalMode.
122 embed_bool emergency_stop; ///< ParameterSet.EmergencyStop.
123 embed_bool protective_stop; ///< ParameterSet.ProtectiveStop.
125
126/** @brief One MotionDevice: identity + live motion state (OPC 40010-1 MotionDeviceType, common subset). */
127typedef struct
128{
129 const char *manufacturer; ///< Manufacturer (LocalizedText -> String).
130 const char *model; ///< Model (LocalizedText -> String).
131 const char *product_code; ///< ProductCode (String).
132 const char *serial_number; ///< SerialNumber (String).
133 RoboticsMotionDeviceCategory category; ///< MotionDeviceCategory.
134 embed_bool on_path; ///< ParameterSet.OnPath.
135 embed_bool in_control; ///< ParameterSet.InControl.
136 double speed_override; ///< ParameterSet.SpeedOverride (%).
137 uint32_t axis_count; ///< number of Axes exposed (<= PROTOCORE_ROBOTICS_AXES).
138 RoboticsAxis axes[PROTOCORE_ROBOTICS_AXES]; ///< the axes (axes[0..axis_count-1] are live).
140
141/**
142 * @brief The whole MotionDeviceSystem the server exposes. Own it in your sketch and refresh its fields
143 * each loop from your robot I/O. The robotics resolvers read straight out of it (no copy). String
144 * fields may be null (served as an empty String).
145 */
146typedef struct
147{
148 const char *name; ///< MotionDeviceSystem BrowseName / DisplayName.
149 RoboticsMotionDevice device; ///< the MotionDevice.
150 RoboticsController controller; ///< the Controller.
151 RoboticsSafetyState safety; ///< the SafetyState.
153
154/** @brief Dispatch table. Addressed by offset, so the layout is asserted below. */
155typedef struct
156{
157 void (*bind)(uint8_t *, const RoboticsMotionDeviceSystem *);
158 void (*install)(uint8_t *, const RoboticsMotionDeviceSystem *);
159} RoboticsNs;
161
162/**
163 * @brief Bind the MotionDeviceSystem the resolvers serve. mds must outlive .
164 * @param work PROTOCORE_ROBOTICS_BORROW bytes the caller took. Not held past the call.
165 * @param mds Mds
166 */
168/**
169 * @brief Convenience: bind mds and register both resolvers on the OPC UA .
170 * @param work PROTOCORE_ROBOTICS_BORROW bytes the caller took. Not held past the call.
171 * @param mds Mds
172 */
174
175/**
176 * @brief The PROTOCORE_ROBOTICS_BORROW bytes this module's state lives in.
177 *
178 * Stated beside the namespace rather than on it: an entry takes a borrow, and this is where
179 * that borrow comes from. Taken once from the end of the pool, which no mark and no release
180 * walks, so the state lasts the life of the program.
181 *
182 * @return the span.
183 */
185
186/** @brief Module namespace. */
189
190EMBED_END_DECLS
191
192#endif // PROTOCORE_ROBOTICS_H
#define PROTOCORE_ROBOTICS_AXES
Number of Axes the robotics MotionDevice exposes (default 6; must fit PROTOCORE_OPCUA_REF_MAX).
#define PROTOCORE_UNUSED
Suppress the unused warning. Every module ends in a namespace most callers only partly use.
Definition ns_contract.h:36
#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.
void protocore_robotics_install(uint8_t *work, const RoboticsMotionDeviceSystem *mds)
Convenience: bind mds and register both resolvers on the OPC UA .
EMBED_ENUM_BYTE(RoboticsMotionDeviceCategory, ROBOTICS_CAT_OTHER=0, ROBOTICS_CAT_ARTICULATED_ROBOT=1, ROBOTICS_CAT_SCARA_ROBOT=2, ROBOTICS_CAT_CARTESIAN_ROBOT=3, ROBOTICS_CAT_SPHERICAL_ROBOT=4, ROBOTICS_CAT_PARALLEL_ROBOT=5, ROBOTICS_CAT_CYLINDRICAL_ROBOT=6,)
MotionDeviceCategory (OPC 40010-1 MotionDeviceCategoryEnumeration). Exposed as Int32; the numeric val...
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:99
double actual_position
ActualPosition (mm or deg).
Definition robotics.h:100
RoboticsMotionProfile motion_profile
MotionProfile.
Definition robotics.h:103
double actual_acceleration
ActualAcceleration.
Definition robotics.h:102
double actual_speed
ActualSpeed.
Definition robotics.h:101
The Controller identity + software (OPC 40010-1 ControllerType + SoftwareType).
Definition robotics.h:108
const char * serial_number
SerialNumber (String).
Definition robotics.h:112
const char * sw_manufacturer
Software.Manufacturer (String).
Definition robotics.h:113
const char * sw_model
Software.Model (String).
Definition robotics.h:114
const char * manufacturer
Manufacturer (LocalizedText -> String).
Definition robotics.h:109
const char * product_code
ProductCode (String).
Definition robotics.h:111
const char * sw_revision
Software.SoftwareRevision (String).
Definition robotics.h:115
const char * model
Model (LocalizedText -> String).
Definition robotics.h:110
The whole MotionDeviceSystem the server exposes. Own it in your sketch and refresh its fields each lo...
Definition robotics.h:147
const char * name
MotionDeviceSystem BrowseName / DisplayName.
Definition robotics.h:148
RoboticsSafetyState safety
the SafetyState.
Definition robotics.h:151
RoboticsMotionDevice device
the MotionDevice.
Definition robotics.h:149
RoboticsController controller
the Controller.
Definition robotics.h:150
One MotionDevice: identity + live motion state (OPC 40010-1 MotionDeviceType, common subset).
Definition robotics.h:128
embed_bool in_control
ParameterSet.InControl.
Definition robotics.h:135
const char * manufacturer
Manufacturer (LocalizedText -> String).
Definition robotics.h:129
embed_bool on_path
ParameterSet.OnPath.
Definition robotics.h:134
double speed_override
ParameterSet.SpeedOverride (%).
Definition robotics.h:136
RoboticsAxis axes[PROTOCORE_ROBOTICS_AXES]
the axes (axes[0..axis_count-1] are live).
Definition robotics.h:138
RoboticsMotionDeviceCategory category
MotionDeviceCategory.
Definition robotics.h:133
uint32_t axis_count
number of Axes exposed (<= PROTOCORE_ROBOTICS_AXES).
Definition robotics.h:137
const char * product_code
ProductCode (String).
Definition robotics.h:131
const char * model
Model (LocalizedText -> String).
Definition robotics.h:130
const char * serial_number
SerialNumber (String).
Definition robotics.h:132
Dispatch table. Addressed by offset, so the layout is asserted below.
Definition robotics.h:156
void(* install)(uint8_t *, const RoboticsMotionDeviceSystem *)
Definition robotics.h:158
void(* bind)(uint8_t *, const RoboticsMotionDeviceSystem *)
Definition robotics.h:157
The SafetyState (OPC 40010-1 SafetyStateType, common subset).
Definition robotics.h:120
RoboticsOperationalMode operational_mode
ParameterSet.OperationalMode.
Definition robotics.h:121
embed_bool emergency_stop
ParameterSet.EmergencyStop.
Definition robotics.h:122
embed_bool protective_stop
ParameterSet.ProtectiveStop.
Definition robotics.h:123