# stepevents.m

stepevents.m — Objective-C source code, 0Kb

## File contents

function [value, isterminal, direction] = stepevents(t,X) theta = X(1); % stance leg angle, (rad) phi = X(2); % swing leg angle, (rad) thetadot = X(3); % stance leg angular velocity, (rad/NDT) phidot = X(4); % swing leg angular velocity, (rad/NDT) %%% Swing Foot Elevation SF_elevation = cos(theta)-cos(phi-theta); %%% There are two possible events for this model: (1) the swing foot can hit the % ground indicated by the SF_elevation function crossing zero from (+) to (-), & % (2) the walker can fall over (forwards or backwards). %%% (1) Ignore foot scuffing and terminate if swing foot hits the ground slope if (theta < -3*pi/180) && (phi < 0) && (phi < theta) && (thetadot < 0) value(1) = SF_elevation; isterminal(1) = 1; direction(1) = -1; else value(1) = SF_elevation; isterminal(1) = 0; direction(1) = 0; end %%% (2) Walker falls over value(2) = abs(theta) - pi/2; isterminal(2) = 1; direction(2) = 0; return