Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Genetic Bike A
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ii
collabschools
NORBIS-DLN Collaboration School 2022
Genetic Bike A
Commits
2aa69300
Commit
2aa69300
authored
2 years ago
by
hui
Browse files
Options
Downloads
Patches
Plain Diff
remove the unnecessary lines
parent
ba8fce3d
Branches
main
No related tags found
1 merge request
!12
fix the bugs for imput files
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bike/simu_bike.py
+5
-12
5 additions, 12 deletions
bike/simu_bike.py
with
5 additions
and
12 deletions
bike/simu_bike.py
+
5
−
12
View file @
2aa69300
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment