Skip to content
Snippets Groups Projects
Commit 2aa69300 authored by hui's avatar hui
Browse files

remove the unnecessary lines

parent ba8fce3d
Branches main
No related tags found
1 merge request!12fix the bugs for imput files
import bike.gen as g
import numpy as np
import sys
# initial, set up the physical world
# the positions of points are generated using random function from np
num_point = 4
#points_position = np.random.rand(num_point, 2)*8+3
# for test
def creat_bike(points_position):
......@@ -15,6 +8,7 @@ def creat_bike(points_position):
Args:
points_position (np.array): a 4x2 np.array
"""
num_point=len(points_position)
start_x = np.max(points_position[:, 0])
points_velocity = np.zeros_like(points_position)
......@@ -33,15 +27,10 @@ def creat_bike(points_position):
gravity = -9.81 # unit [ m /s2]
spring_initial_length = g.calc_spring_length(points_position, spring_indexs)
# for animation
run_time = 15 # unit [s]
dt = 0.01 # unit [s]
def update(points_position,points_velocity):
# boundary condition 1
if np.min(points_position[2:, 1] - g.ground(points_position[2:, 0])) < 0:
return(np.max(points_position[:, 0])-start_x)
sys.exit(0)
else:
state_y = points_position[:, 1] - g.ground(points_position[:, 0])
state_y[0] -= wheel_radius
......@@ -64,6 +53,10 @@ def creat_bike(points_position):
if points_position[0, 1] < wheel_radius+g.ground(points_position[0, 0]):
points_velocity[0, 0] = 2
# for time-domain solver
run_time = 15 # unit [s]
dt = 0.01 # unit [s]
for i in np.arange(1, int(run_time/dt)):
update(points_position,points_velocity)
return (np.max(points_position[:, 0])-start_x)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment