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
f98caef3
Commit
f98caef3
authored
2 years ago
by
Alberto.Rovetta
Browse files
Options
Downloads
Patches
Plain Diff
Created get_img function to save bike images
parent
c51fa231
Branches
main
No related tags found
1 merge request
!10
Created get_img function to save bike images
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
images/get_img.py
+36
-0
36 additions, 0 deletions
images/get_img.py
with
36 additions
and
0 deletions
images/get_img.py
0 → 100644
+
36
−
0
View file @
f98caef3
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
matplotlib.animation
import
FuncAnimation
def
save_bike_image
(
points_position
,
counter
)
fig
,
ax
=
plt
.
subplots
()
ax
.
set_title
(
'
Bikes
'
)
ax
.
axis
(
'
equal
'
)
ax
.
set_xlim
(
0
,
35
)
ax
.
set_ylim
(
-
5
,
20
)
num_point
=
4
points_position
=
np
.
random
.
rand
(
num_point
,
2
)
*
8
+
3
wheel_radius
=
1.2
spring_indexs
=
[]
for
i
in
range
(
num_point
):
for
j
in
range
(
num_point
):
if
i
!=
j
:
spring_indexs
.
append
([
i
,
j
])
spring_indexs
=
np
.
array
(
spring_indexs
)
ax
.
plot
(
np
.
arange
(
-
10
,
40
,
0.5
),
np
.
sin
(
np
.
arange
(
-
10
,
40
,
0.5
)),
'
k
'
)
# ground
balls
=
[]
balls
.
append
(
plt
.
Circle
(
(
points_position
[
0
][
0
],
points_position
[
0
][
1
]),
wheel_radius
,
color
=
'
r
'
))
balls
.
append
(
plt
.
Circle
(
(
points_position
[
1
][
0
],
points_position
[
1
][
1
]),
wheel_radius
))
lines
=
[]
for
item
in
spring_indexs
:
lines
.
append
(
ax
.
plot
([
points_position
[
item
[
0
],
0
],
points_position
[
item
[
1
],
0
]],
[
points_position
[
item
[
0
],
1
],
points_position
[
item
[
1
],
1
]],
'
o-
'
,
markersize
=
9
,
markerfacecolor
=
'
b
'
))
for
item
in
balls
:
ax
.
add_patch
(
item
)
plt
.
savefig
(
f
"
img_
{
counter
}
.png
"
)
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