classdef chompSmoothnessOptions
%CHOMPSMOOTHNESSOPTIONS Smoothness options for CHOMP trajectories
%
%   OPTS = chompSmoothnessOptions returns a smoothness options object,
%   OPTS, which can be used with manipulatorCHOMP to optimize a trajectory
%   for its smoothness
%
%   OPTS = chompSmoothnessOptions(PropertyName=PropertyValue) sets
%   properties on the object using name-value arguments.
%
%   chompSmoothnessOptions properties:
%       VelocitySmoothnessWeight     - Weight of velocity smoothness of
%                                      trajectory
%       AccelerationSmoothnessWeight - Weight of acceleration smoothness of
%                                      trajectory
%       JerkSmoothnessWeight         - Weight of jerk smoothness of
%                                      trajectory
%       SmoothnessCostWeight         - Weight of overall smoothness cost of
%                                      trajectory
%
%   Example:
%       % Load a robot and create a CHOMP solver.
%       rbt = loadrobot("kinovaGen3",DataFormat="row");
%       chomp = manipulatorCHOMP(rbt);
%
%       % Create smoothness options for CHOMP solver.
%       smoothnessOpts = chompSmoothnessOptions;
%
%       % Set the velocity and acceleration smoothness weights to 0.5 and
%       % 0.75, respectively.
%       smoothnessOpts.VelocitySmoothnessWeight = 0.5;
%       smoothnessOpts.AccelerationSmoothnessWeight = 0.75;
%
%       % Assign the smoothness options to CHOMP solver.
%       chomp.SmoothnessOptions = smoothnessOpts;
%
%   See also chompCollisionOptions, chompSolverOptions

% Copyright 2022 The MathWorks, Inc.

%#codegen
    properties
        %VelocitySmoothnessWeight Weight of velocity smoothness of trajectory
        %   Weight of the velocity smoothness of the trajectory, specified
        %   as a nonnegative numeric scalar. This is a weight of the cost
        %   obtained by the summation of squared velocity along the
        %   trajectory.
        %
        %   Default: 1
        VelocitySmoothnessWeight (1,1) {...
            mustBeNumeric, ...
            mustBeGreaterThanOrEqual(VelocitySmoothnessWeight,0)}=1

        %AccelerationSmoothnessWeight Weight of acceleration smoothness of trajectory
        %   Weight of the acceleration smoothness of the trajectory,
        %   specified as a nonnegative numeric scalar. This is a weight of
        %   the cost obtained by the summation of squared acceleration
        %   along the trajectory.
        %
        %   Default: 1
        AccelerationSmoothnessWeight (1,1) {...
            mustBeNumeric, ...
            mustBeGreaterThanOrEqual(AccelerationSmoothnessWeight,0)}=1

        %JerkSmoothnessWeight Weight of jerk smoothness of trajectory
        %   Weight of the jerk smoothness of the trajectory, specified as a
        %   nonnegative numeric scalar. This is a weight of the cost
        %   obtained by the summation of squared jerk along the trajectory.
        %
        %   Default: 1
        JerkSmoothnessWeight (1,1) {...
            mustBeNumeric, ...
            mustBeGreaterThanOrEqual(JerkSmoothnessWeight,0)}=1

        %SmoothnessCostWeight Weight of overall smoothness cost of trajectory
        %   Weight of the smoothness cost of the trajectory, specified as a
        %   nonnegative numeric scalar. This is a weight of the cost
        %   obtained by the summation of the velocity, acceleration, and
        %   jerk smoothness costs.
        %
        %   Default: 1e-3
        SmoothnessCostWeight (1,1) {...
            mustBeNumeric, ...
            mustBeGreaterThanOrEqual(SmoothnessCostWeight,0)}=1e-3
    end

    methods
        function obj=chompSmoothnessOptions(nvargs)
        %Constructor
            arguments
                nvargs.VelocitySmoothnessWeight
                nvargs.AccelerationSmoothnessWeight
                nvargs.JerkSmoothnessWeight
                nvargs.SmoothnessCostWeight
            end
            userProvidedProperties=fieldnames(nvargs);
            for i=coder.unroll(1:length(userProvidedProperties))
                obj.(userProvidedProperties{i})=nvargs.(userProvidedProperties{i});
            end
        end
    end

end
