copp.Robot

Native robot model and station-indexed constraint buffer.

Syntax

OBJ = copp.Robot(DIM)
OBJ = copp.Robot(DIM, CAPACITY)
OBJ = copp.Robot(DIM, Capacity=CAPACITY)

Description

Robot owns a native CoppRobot handle. The handle stores station samples, sampled path derivatives, and constraints used by TOPP/COPP solvers. This MATLAB class exposes the workflow-oriented surface used by TOPP and COPP solvers: station append, path derivative input, limit helpers, raw constraints, inverse dynamics callbacks, and solver metadata.

Matrix convention: MATLAB inputs use \(\mathrm{dim} \times N\) column-major matrices for robot/path data. Here dim is robot.dim and N is the number of station samples covered by the call. Each column corresponds to one station sample. One-dimensional station/profile inputs may be row or column vectors, but solver/profile outputs are returned as double column vectors.

Constraint convention: Per-axis limit vectors have shape \(\mathrm{dim} \times 1\) or 1-by-dim and are broadcast over the selected station interval. Per-axis station-varying limit matrices have shape \(\mathrm{dim} \times N\). Raw constraint matrices have shape R-by-N, where R is the number of inequality rows per station.

Input Arguments

dim

Positive integer path or robot dimension.

capacity

Input value for copp.Robot. See Description for accepted shape and constraints. Default: 0

Name-Value Arguments

Capacity

Name-value option for copp.Robot. Default: capacity

Properties

len

Number of logical station samples currently stored.

capacity

Allocated native station-buffer capacity.

Methods

Robot

Construct a native robot and empty constraint buffer.

delete

Release the native robot handle during MATLAB cleanup.

release

Explicitly release the native CoppRobot handle.

is_valid

Return whether this object still owns a live native robot.

append_s

Append strictly increasing path station samples.

set_q_2nd

Store q, dq/ds, and d2q/ds2 over a station interval.

set_q_3rd

Store q and derivatives through third order.

pop_back_n

Remove N logical stations from the back.

exceed_topp2

Maximum TOPP2 constraint violations of an a profile.

exceed_topp3

Maximum TOPP3 constraint violations of a third-order profile.

Method Details

Robot

Syntax

OBJ = copp.Robot(DIM)
OBJ = copp.Robot(DIM, CAPACITY)
OBJ = copp.Robot(DIM, Capacity=CAPACITY)

creates an empty DIM-dimensional robot. OBJ = copp.Robot(DIM, CAPACITY) also gives the native station buffer an initial capacity hint. CAPACITY may be zero. OBJ = copp.Robot(DIM, Capacity=CAPACITY) is the name-value equivalent, matching the style used by the rest of the MATLAB facade.

delete

Syntax

delete(obj)

release

Syntax

RELEASED = release(OBJ)

is_valid

Syntax

tf = is_valid(obj)

append_s

Syntax

obj = append_s(obj, s)

appends a real finite vector of station values. S may be \(1 \times N\) or \(N \times 1\). S must be strictly increasing, and if OBJ already stores stations then S(1) must be greater than the current last station.

The method returns OBJ to support chaining.

set_q_2nd

Syntax

This mirrors Python Robot.set_q(..., dddq=None), while MATLAB

writes second-order geometric path derivatives starting at station 1. Q, DQ, and DDQ must have the same \(\mathrm{dim} \times N\) shape. Column k corresponds to station start_idx_s + k - 1.

Name-value options: start_idx_s: 1-based global station index where the first column is written. Defaults to 1.

This mirrors Python Robot.set_q(..., dddq=None), while MATLAB keeps the explicit second-order name for readability.

set_q_3rd

Syntax

obj = set_q_3rd(obj, q, dq, ddq, dddq)
obj = set_q_3rd(obj, q, dq, ddq, dddq, start_idx_s=start_idx_s)

writes third-order geometric path derivatives starting at station 1. All matrices must have the same \(\mathrm{dim} \times N\) shape, with one column per station.

Name-value options: start_idx_s: 1-based global station index where the first column is written. Defaults to 1.

set_q_from_path_2nd

Syntax

set_q_from_path_2nd(..., idx_s_from=I, idx_s_to=J)

evaluates PATH at the station values already stored in OBJ and writes q, dq/ds, and d2q/ds2 from station 1 through OBJ.len.

PATH must remain valid only for the duration of this call; the sampled derivatives are copied into the native Robot.

set_q_from_path_3rd

Syntax

set_q_from_path_3rd(..., idx_s_from=I, idx_s_to=J)

evaluates PATH at OBJ's stored station values and writes q, dq/ds, d2q/ds2, and d3q/ds3 from station 1 through OBJ.len.

add_velocity_limits

Syntax

obj = add_velocity_limits(obj, upper, lower)
obj = add_velocity_limits(obj, upper, lower, start_idx_s=start_idx_s, length=length)

adds per-axis bounds over the interval from station 1 through OBJ.len. Vector inputs must have length dim (\(\mathrm{dim} \times 1\) or 1-by-dim) and are broadcast over the interval. Matrix inputs must have shape \(\mathrm{dim} \times N\) and specify station-varying limits, where N is the selected interval length.

Name-value options: start_idx_s: 1-based first station receiving the limits. Defaults to 1. length: Number of stations for broadcast vector limits. When omitted, length is inferred as OBJ.len - start_idx_s + 1.

The method returns OBJ to support chaining.

add_acceleration_limits

Syntax

obj = add_acceleration_limits(obj, upper, lower)
obj = add_acceleration_limits(obj, upper, lower, start_idx_s=start_idx_s, length=length)

This method has the same vector/matrix shape, indexing, Inf, and length inference rules as add_velocity_limits(), but it writes second-order acceleration constraints used by TOPP2/COPP2.

The method returns OBJ to support chaining.

add_jerk_limits

Syntax

obj = add_jerk_limits(obj, upper, lower)
obj = add_jerk_limits(obj, upper, lower, start_idx_s=start_idx_s, length=length)

This method has the same vector/matrix shape, indexing, Inf, and length inference rules as add_velocity_limits(), but it writes third-order jerk constraints used by TOPP3/COPP3 solvers. The robot must already contain third-order path derivative data over the target interval.

add_torque_limits

Syntax

obj = add_torque_limits(obj, upper, lower)
obj = add_torque_limits(obj, upper, lower, start_idx_s=start_idx_s, length=length)

This method has the same vector/matrix shape, indexing, Inf, and length inference rules as add_velocity_limits(): vector bounds have length dim and are broadcast, while matrix bounds are \(\mathrm{dim} \times N\) with one column per station. Torque evaluation uses the currently installed inverse-dynamics callback, or the native default point dynamics \(\tau = \ddot{q}\) when no callback is installed.

add_raw_constraint_1st

Syntax

obj = add_raw_constraint_1st(obj, amax)
obj = add_raw_constraint_1st(obj, amax, start_idx_s=start_idx_s)

AMAX may be a vector of length N for one raw row per station, or an R-by-N matrix for R raw inequality rows per station. Column k corresponds to station start_idx_s + k - 1.

add_raw_constraint_2nd

Syntax

obj = add_raw_constraint_2nd(obj, acc_a, acc_b, acc_max)
obj = add_raw_constraint_2nd(obj, acc_a, acc_b, acc_max, start_idx_s=start_idx_s)

ACC_A, ACC_B, and ACC_MAX must have identical shapes. Use a length-N vector for one row per station, or an R-by-N matrix for R raw rows per station. Columns are station samples.

add_raw_constraint_3rd

Syntax

obj = add_raw_constraint_3rd(obj, jerk_a, jerk_b, jerk_c, jerk_d, jerk_max)
obj = add_raw_constraint_3rd(obj, jerk_a, jerk_b, jerk_c, jerk_d, jerk_max, start_idx_s=start_idx_s)

JERK_A, JERK_B, JERK_C, JERK_D, and JERK_MAX must have identical shapes. Use a length-N vector for one row per station, or an R-by-N matrix for R raw rows per station. Columns are station samples.

clear_constraints

Syntax

obj = clear_constraints(obj)
obj = clear_constraints(obj, keep_idx_s=keep_idx_s)

keep_idx_s=true keeps the \(1 \times N\)/\(N \times 1\) station vector S and clears derivative and constraint buffers. keep_idx_s=false clears the station vector as well.

pop_front_n

Syntax

obj = pop_front_n(obj, n)

pop_back_n

Syntax

obj = pop_back_n(obj, n)

set_inverse_dynamics

Syntax

tau = callback(q, dq, ddq)

CALLBACK is called pointwise, not batched:

clear_inverse_dynamics

Syntax

obj = clear_inverse_dynamics(obj)

exceed_topp2

Syntax

[E1, E2] = exceed_topp2(OBJ, A)
A = (ds/dt)^2 on the stations idx_s_start through
b(k)
E1 is the maximum violation of 0 <= a(k) <= amax(k) and E2 the

evaluates the node profile A = \((ds/dt)^2\) on the stations idx_s_start through idx_s_start + numel(A) - 1. The path acceleration of each interval is reconstructed by the TOPP2 relation b(k) = (a(k+1) - a(k)) / (2*(s(k+1) - s(k))), and the second-order rows of both endpoint stations are checked against that interval's b.

E1 is the maximum violation of 0 <= a(k) <= amax(k) and E2 the maximum violation of acc_a*a + acc_b*b <= acc_max. Each value is <= 0 when the profile satisfies that constraint order and positive when it is violated. Both are NaN when the station range is not stored in the robot or b cannot be reconstructed from A.

Name-value options: idx_s_start: 1-based station of A(1). Defaults to 1.

exceed_topp3

Syntax

[E1, E2, E3] = exceed_topp3(OBJ, A, B)
profiles A = (ds/dt)^2 and B = d2s/dt2 on the stations
[E1, E2, E3] = exceed_topp3(OBJ, PROFILE)
E1 is the maximum violation of 0 <= a(k) <= amax(k), E2 of
acc_a*a(k) + acc_b*b(k) <= acc_max, and E3 of the original
sqrt(a)

evaluates the node profiles A = \((ds/dt)^2\) and B = \(d^2s/dt^2\) on the stations idx_s_start through idx_s_start + numel(A) - 1.

takes a, b, and num_stationary from a copp.Profile3rd. B and num_stationary must not be passed in this form.

E1 is the maximum violation of 0 <= a(k) <= amax(k), E2 of acc_a*a(k) + acc_b*b(k) <= acc_max, and E3 of the original nonlinear third-order rows sqrt(a)*(jerk_a*a + jerk_b*b + jerk_c*c + jerk_d) <= jerk_max, not their linearization. Each interval contributes c = (b(k+1) - b(k)) / (s(k+1) - s(k)) at both of its endpoints; the two stationary blocks are skipped. Each value is <= 0 when the profile satisfies that constraint order and positive when it is violated. All three are NaN when the station range is not stored in the robot, A and B differ in length or have fewer than two entries, a station interval is not strictly increasing, or PROFILE holds a non-finite a or b (A and B vectors must be finite).

This audits the profile that is actually delivered, so call it after post-processing such as Profile3rd.force_positive_a.

Name-value options: num_stationary: [NS0, NSF] stationary interval counts of the profile, as stored in Profile3rd.num_stationary. Empty (default) means [0, 0] for A/B vectors; it must stay empty for a Profile3rd. idx_s_start: 1-based station of A(1). Defaults to 1.

See Also

copp