function [time,sig,f] = PUSHSIG(t,ne,le,e,ep,nx,lnp,x,xp) x0 = 0.025; %defines contact line stiffn = 300; spalightnode = 4; %conversion between SPACAR Light node and Spacar (full) node. %(for each SPACAR Light node, there are 2 nodes in Spacar full. %They are numbered consecutively. First one is the translation node, %second one is the rotation node. Here, we're taking just the translation node.) spanode = (spalightnode-1)*2+1; %get current position pos = x(lnp(spanode,1:3)); %contains x,y,z coordinate of spalightnode %define a custom force node = spanode; %node number (according to Spacar full numbering) dir = 1; %direction of force: 1 for x, 2 for y, 3 for z debug_info = 1; %print out some debug info during simulation if debug_info fprintf('Current position: %f\n',pos(1)) end if pos(1) > x0 %if within (forbidden) contact region val = -stiffn*(pos(1)-x0); %define force to push it back deriv = stiffn; f = [node dir val deriv 0]; %apply force if debug_info fprintf('Within contact region. Applying force: %f\n',val) end else f = []; %if not within contact region, don't apply contact force if debug_info fprintf('Not within contact region.\n') end end sig = []; %can be left empty (is used for specifying generalized stresses) time = t; %this line needs to be there; don't modify. end