NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
rod_hinge_dynamics.m
1 function theta_result = rod_hinge_dynamics(theta_t, theta_dot_t, p)
2 
3 m = p.m;
4 x_r = p.x_r;
5 l = p.l;
6 g = p.g;
7 k = p.k;
8 c = p.c;
9 theta_r = p.theta_r;
10 
11 theta_dot_tp1 = theta_dot_t;
12 
13 % For the longitudinal sping and damper:
14 
15 %theta_ddot_tp1 = (3 / (m*l^3)) * ( ((m*g*l)/2)*cos(theta_t) - c*l*theta_dot_t*(sin(theta_t)^2) + k*l^2*sin(theta_t)*cos(theta_t) - k*x_r*l*sin(theta_t));
16 
17 % For the longitudinal spring, and rotational damper:
18 %theta_ddot_tp1 = (3 / (m*l^3)) * ( ((m*g*l)/2)*cos(theta_t) - c*theta_dot_t + k*l^2*sin(theta_t)*cos(theta_t) - k*x_r*l*sin(theta_t));
19 
20 % For the rotational spring and rotational damper:
21 % Note that x_r is not used here, though it's passed in as a variable.
22 theta_ddot_tp1 = (3 / (m*l^2)) * ( ((m*g*l)/2)*cos(theta_t) - c*theta_dot_t - k*theta_t + k*theta_r);
23 
24 theta_result = [theta_dot_tp1; theta_ddot_tp1];
25 
26 end