Skip to content

Commit

Permalink
bouncing ball
Browse files Browse the repository at this point in the history
  • Loading branch information
prabinrath committed Mar 24, 2022
1 parent b7593e3 commit a07aff8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Legged Robotics/Bouncing-Ball/ball_dynamics.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function yd = ball_dynamics(t,y)
yd = [y(2); -9.81];
end

Binary file added Legged Robotics/Bouncing-Ball/bouncing_ball.mlx
Binary file not shown.
6 changes: 6 additions & 0 deletions Legged Robotics/Bouncing-Ball/contact.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function [position,isterminal,direction] = contact(t,y,ground)
position = y(1) - ground;
direction = -1;
isterminal = 1;
end

5 changes: 5 additions & 0 deletions Legged Robotics/Bouncing-Ball/one_bounce.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function [tsim,ysim] = one_bounce(tstart,deltat,y0,ground)
options = odeset('Events',@(t,y) contact(t,y,ground));
[tsim,ysim] = ode45(@ball_dynamics,[tstart tstart+deltat],y0,options);
end

Binary file modified Legged Robotics/Double-Pendulum/int_double_pendulum.mlx
Binary file not shown.

0 comments on commit a07aff8

Please sign in to comment.