classdef chompCollisionOptions
%CHOMPCOLLISIONOPTIONS Collision options for CHOMP trajectories
%
%   OPTS = chompCollisionOptions returns a collisions options object, OPTS,
%   which can be used with manipulatorCHOMP to optimize a trajectory to
%   avoid collisions.
%
%   OPTS = chompCollisionOptions(PropertyName=PropertyValue) sets
%   properties on the object using name-value arguments.
%
%   chompCollisionOptions properties:
%       CollisionClearance      - Clearance distance to maintain to avoid
%                                 collisions
%       SkippedSelfCollisions   - Body pairs skipped for self-collision
%                                 costs
%       IgnoreSelfCollision     - IgnoreSelfCollision avoidance costs
%       CollisionCostWeight     - Weight of collision cost of trajectory
%
%   Example:
%
%       % Load a robot and create a CHOMP solver.
%       rbt = loadrobot("kinovaGen3",DataFormat="column");
%       chomp = manipulatorCHOMP(rbt);
%
%       % Create collision options for CHOMP solver.
%       collisionOpts = chompCollisionOptions;
%
%       % Set the collision clearance to 0.10 m.
%       collisionOpts.CollisionClearance = 0.10;
%
%       % Consider self-collision costs.
%       collisionOpts.IgnoreSelfCollision = false;
%
%       % Assign the collision options to CHOMP solver.
%       chomp.CollisionOptions = collisionOpts;
%
%   See also manipulatorCHOMP, chompSmoothnessOptions, chompSolverOptions

% Copyright 2022 The MathWorks, Inc.

%#codegen
    properties
        %CollisionClearance Clearance distance to maintain to avoid collisions
        %   Clearance distance to maintain to avoid collisions, specified
        %   as a positive numeric scalar.
        %
        %   Default: 1e-3
        CollisionClearance (1,1) {...
            mustBeNumeric,...
            mustBeGreaterThanOrEqual(CollisionClearance,0)}=1e-3

        %SkippedSelfCollisions Body pairs skipped for self-collision costs
        %   Body pairs skipped for self-collision costs, specified as
        %   either "parent" or "adjacent":
        %   - "parent"      - Skip collision cost between child and parent
        %                     bodies.
        %   - "adjacent"    - Skip collision cost between bodies on
        %                     adjacent indices.
        %
        %   Default: 'parent'
        SkippedSelfCollisions{...
            mustBeA(SkippedSelfCollisions,{'string','char'}),...
            validatestring(SkippedSelfCollisions,["parent","adjacent"])}='parent'

        %CollisionCostWeight Weight of collision cost of trajectory
        %   Weight of collision cost of trajectory, specified as a
        %   nonnegative numeric scalar.
        %
        %   Default: 10
        CollisionCostWeight (1,1) {...
            mustBeNumeric,...
            mustBeGreaterThanOrEqual(CollisionCostWeight,0)}=10

        %IgnoreSelfCollision Ignore self collision avoidance costs
        IgnoreSelfCollision (1,1) {...
            mustBeNumericOrLogical,...
            mustBeScalarOrEmpty}=true
    end

    methods
        function obj=chompCollisionOptions(nvargs)
        %chompCollisionOptions Constructor
            arguments
                nvargs.CollisionClearance
                nvargs.SkippedSelfCollisions
                nvargs.CollisionCostWeight
                nvargs.IgnoreSelfCollision
            end
            userProvidedProperties=fieldnames(nvargs);
            for i=coder.unroll(1:length(userProvidedProperties))
                obj.(userProvidedProperties{i})=nvargs.(userProvidedProperties{i});
            end
        end
    end

end
