Index-> contents reference index search external Previous Next Up-> ckbs ckbs_nonlinear nonlinear_utility sine_f.m ckbs-> license ckbs_t_general ckbs_nonlinear ckbs_L1_nonlinear ckbs_affine ckbs_affine_singular ckbs_L1_affine utility all_ok.m whatsnew wishlist bib ckbs_nonlinear-> get_started_ok.m sine_wave_ok.m vanderpol_ok.m nonlinear_utility nonlinear_utility-> box_f.m direct_h.m distance_h.m no_f.m persist_g.m pos_vel_g.m sine_f.m sine_f.m Headings-> Syntax Notation Purpose k xk index offset fk Fk Source Code

ckbs_nonlinear: Example of Nonlinear Constraint

Syntax
```[fk]     = sine_f(k, xk, params) ``` ```[fk, Fk] = sine_f(k, xk, params) ```
Notation
```       index  = params.sine_f_index       offset = params.sine_f_offset ```
Purpose
Implements an upper limit that is an offset sine wave To be specific, ``` xk( index(2) ) <= sin( xk( index(1) + offset(1) ) ) + offset(2) ```
k
is an integer scalar specifying the time index (not used).

xk
is a column vector with length `n` specifying a value for the state vector at the current time index.

index
is an integer column vector with two elements specifying the state vector indices for the sine wave constraint (see purpose above). Each such index must be between one and `n` .

offset
is an integer column vector with two elements specifying the offsets for the sine wave (see purpose above).

fk
The return value `fk` is a scalar equal to ``` xk( index(2) ) - sin( xk( index(1) + offset(1) ) ) - offset(2) ``` so that the condition `fk <= 0` is equivalent to the constraints in the purpose above.

Fk
The return value `Fk` is a row vector with `n` elements equal to the derivative of `fk` w.r.t `xk` .

Source Code ``` function [fk, Fk] = sine_f(k, xk, params) n = size(xk, 1); index = params.sine_f_index; offset = params.sine_f_offset; if (size(index, 1) ~= 2) | (size(index, 2) ~= 1) size_index_1 = size(index, 1) size_index_2 = size(index, 2) error('sine_f: index is not a column vector with two elements') end if (size(offset, 1) ~= 2) | (size(offset, 2) ~= 1) size_offset_1 = size(offset, 1) size_offset_2 = size(offset, 2) error('sine_f: offset is not a column vector with two elements') end if (max(index) > n) | (min(index) < 1) max_index = max(index) min_index = min(index) error('sine_f: max(index) > size(xk, 1) or min(index) < 1') end fk = xk( index(2) ) - sin( xk( index(1) + offset(1) ) ) - offset(2); Fk = zeros(1, n); Fk(index(2)) = 1; Fk(index(1)) = Fk(index(1)) - cos( xk( index(1) + offset(1) ) ); return end ```
Input File: example/nonlinear/sine_f.m