Skip to content

Commit

Permalink
working on replacing dynamical system constraint methods with the new…
Browse files Browse the repository at this point in the history
… constraint classes
  • Loading branch information
RussTedrake committed Oct 5, 2014
1 parent 33ee9c9 commit e9a3e6e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
4 changes: 2 additions & 2 deletions systems/@DrakeSystem/DrakeSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@
obj.num_xcon_eq = obj.num_xcon_eq + sum(con.lb == con.ub);
obj.num_xcon_ineq = obj.num_xcon_ineq + sum(con.lb ~= con.ub);
id = numel(obj.state_constraints);
end
end

function obj = updateStateConstraint(obj,id,con)
% @param id is the identifier returned from addStateConstraint
% @param con is a constraint object
Expand Down
1 change: 1 addition & 0 deletions systems/SpotPolynomialSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
end
end
obj.p_state_constraints = p_state_constraints;
error('todo: need to reset the drake.state_constraints with this new constraint');
end

function p_state_constraints = getPolyStateConstraints(obj)
Expand Down
15 changes: 7 additions & 8 deletions systems/plants/@Manipulator/Manipulator.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
% which can be enforced directly in the manipulator dynamics.
% This method will also register phi (and it's time derivative)
% as state constraints for the dynamical system.

typecheck(con,'Constraint');
assert(con.xdim == obj.num_positions,'DrakeSystem:InvalidPositionConstraint','Position constraints must take a vector that is the same size as the number of positions of this system as an input');
assert(all(con.lb == con.ub));
Expand All @@ -169,7 +169,7 @@

obj.warning_manager.warnOnce('Drake:Manipulator:Todo','still need to add time derivatives of position constraints');
end

function obj = addVelocityEqualityConstraint(obj,con)
% Adds a velocity constraint of the form psi(q,v) = constant
% (with dpsidv~=0) which can be enforced directly in the manipulator dynamics.
Expand Down Expand Up @@ -220,7 +220,7 @@
function n = getNumVelocities(obj);
n = obj.num_velocities;
end

function varargout = positionConstraints(obj,q)
% Implements position constraints of the form phi(q) = 0

Expand All @@ -231,7 +231,7 @@
v{1} = v{1} - obj.state_constraints{obj.position_constraint_ids(i)}.lb; % center it around 0
for j=1:nargout
varargout{j} = vertcat(varargout{j},v{j});
end
end
end
end

Expand All @@ -249,7 +249,7 @@
varargout{j} = vertcat(varargout{j},v{j});
end
end
end
end

function n = getNumJointLimitConstraints(obj)
% returns number of constraints imposed by finite joint limits
Expand Down Expand Up @@ -451,9 +451,8 @@ function num_contacts(obj)
[obj,obj.joint_limit_constraint_id] = addStateConstraint(obj,con);
else
obj = updateStateConstraint(obj,obj.joint_limit_constraint_id,con);
end
end

end

end

properties (SetAccess = private, GetAccess = public)
Expand Down
30 changes: 13 additions & 17 deletions systems/plants/TimeSteppingRigidBodyManipulator.m
Original file line number Diff line number Diff line change
Expand Up @@ -568,20 +568,20 @@ function checkDirty(obj)

function varargout = pdcontrol(sys,Kp,Kd,index)
if nargin<4, index=[]; end
[pdff,pdfb] = pdcontrol(sys.manip,Kp,Kd,index);
[pdff,pdfb] = pdcontrol(sys.manip,Kp,Kd,index);
pdfb = setInputFrame(pdfb,sys.manip.getStateFrame());
pdfb = setOutputFrame(pdfb,sys.getInputFrame());
pdff = setOutputFrame(pdff,sys.getInputFrame());
if nargout>1
varargout{1} = pdff;
varargout{2} = pdfb;
else
% note: design the PD controller with the (non time-stepping
% manipulator), but build the closed loop system with the
% time-stepping manipulator:
varargout{1} = cascade(pdff,feedback(sys,pdfb));
end
pdfb = setOutputFrame(pdfb,sys.getInputFrame());
pdff = setOutputFrame(pdff,sys.getInputFrame());
if nargout>1
varargout{1} = pdff;
varargout{2} = pdfb;
else
% note: design the PD controller with the (non time-stepping
% manipulator), but build the closed loop system with the
% time-stepping manipulator:
varargout{1} = cascade(pdff,feedback(sys,pdfb));
end
end

end

Expand Down Expand Up @@ -715,7 +715,7 @@ function checkDirty(obj)
[obj.manip,manip_id] = obj.manip.addStateConstraint(obj,con);
assert(id==manip_id);
end

function obj = updateStateConstraint(obj,id,con)
obj = updateStateConstraint@DrakeSystem(obj,id,con);
obj.manip = updateStateConstraint(obj.manip,id,con);
Expand Down Expand Up @@ -944,10 +944,6 @@ function checkDirty(obj)
model.manip = setParams(model.manip,p);
end

function [lb,ub] = getStateLimits(obj)
[lb,ub] = obj.manip.getStateLimits();
end

function terrain_contact_point_struct = getTerrainContactPoints(obj,varargin)
terrain_contact_point_struct = getTerrainContactPoints(obj.manip,varargin{:});
end
Expand Down

0 comments on commit e9a3e6e

Please sign in to comment.