python from sympy import symbols from sympy.physics.mechanics import dynamicsymbols from sympy.physics.vector import ReferenceFrame from pydy.codegen.ode_function_generators import generate_ode_function x, y, theta = dynamicsymbols('x y theta') q = symbols('q:3') N = ReferenceFrame('N') point_n = N.point('point_n') point_n.set_vel(N, 0) point_n.set_pos(point_n, x * N.x + y * N.y) point_n.vel(N) m = symbols('m') mass_center = point_n.locatenew('mass_center', 0) mass_center.set_vel(N, point_n.vel(N)) I = symbols('I') inertia_dyadic = N.y - N.x & N.y - N.x inertia_dyadic = inertia_dyadic * I kinematic_equations = [x - dynamicsymbols('x', level=1), y - dynamicsymbols('y', level=1), theta - dynamicsymbols('theta', level=1)] force_torque_vector = -m * point_n.vel(N) torque = dynamicsymbols('torque') force_torque_vector += torque * -N.z motion_equations = mass_center.partial_velocity(N, N) - force_torque_vector states = (x, y, theta) specified = (torque,) constants = (m, I) ode_rhs = generate_ode_function(states, specified, constants, mass_center.partial_velocity(N, N), [torque]) print(ode_rhs)


上一篇:
下一篇:
切换中文