Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
Farmbot Yolo
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robotlab
Farmbot Yolo
Commits
548b938b
Unverified
Commit
548b938b
authored
3 years ago
by
Anton Tetov Johansson
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/gripper'
parents
300fe9b9
2207a159
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/gripper.py
+3
-3
3 additions, 3 deletions
src/gripper.py
src/main.py
+0
-1
0 additions, 1 deletion
src/main.py
src/move.py
+24
-13
24 additions, 13 deletions
src/move.py
src/utils/client.py
+3
-3
3 additions, 3 deletions
src/utils/client.py
src/utils/request_token.py
+0
-0
0 additions, 0 deletions
src/utils/request_token.py
with
30 additions
and
20 deletions
src/gripper.py
+
3
−
3
View file @
548b938b
...
...
@@ -2,9 +2,9 @@
TODO: Integrate with FarmbotClient or FarmbotYoloClient
"""
from
client
import
FarmbotClient
from
creds
import
device_id
from
creds
import
token
from
utils.
client
import
FarmbotClient
from
utils.
creds
import
device_id
from
utils.
creds
import
token
GRIPPER_PIN
=
12
GRIPPER_OPEN_STATE
=
0
...
...
This diff is collapsed.
Click to expand it.
src/main.py
+
0
−
1
View file @
548b938b
...
...
@@ -48,7 +48,6 @@ def remove_overlap(table_coordinate:DataFrame, tolerance=50.00)->DataFrame:
return
table_coordinate
def
remove_temp
(
path
:
Path
)
->
None
:
'''
Clean temporary files, i.e., photos, location.txt, annotations
...
...
This diff is collapsed.
Click to expand it.
src/move.py
+
24
−
13
View file @
548b938b
...
...
@@ -8,6 +8,7 @@ Note: it is for remote server, can ben replaced by a local script
from
argparse
import
ArgumentParser
from
logging
import
getLogger
from
os
import
path
,
makedirs
,
system
import
sys
from
time
import
sleep
,
strftime
,
time
#from serial import Serial, PARITY_NONE, STOPBITS_ONE, EIGHTBITS
from
requests.api
import
delete
...
...
@@ -20,8 +21,8 @@ from datetime import timezone, datetime
from
dateutil.parser
import
parse
from
requests
import
get
,
delete
import
creds
from
client
import
FarmbotClient
import
utils.creds
as
creds
from
utils.
client
import
FarmbotClient
_SWEEEP_HEIGHT
=
0
...
...
@@ -40,7 +41,7 @@ class Opts:
def
scan
(
img_path
:
Path
,
location_path
:
Path
,
# smaller delta
min_x
=
0
,
max_x
=
1
300
,
min_y
=
0
,
max_y
=
1000
,
delta
=
10
00
,
offset
=
0
,
flag
=
True
)
->
List
:
#里面的数字需要重新测量
min_x
=
0
,
max_x
=
1
175
,
min_y
=
0
,
max_y
=
974
,
delta
=
3
00
,
offset
=
0
,
flag
=
True
)
->
List
:
#里面的数字需要重新测量
'''
scan the bed at a certain height, first move along x axis, then y, like a zig zag;
Taking pictures and record the location of the camera that corresponds to the picture
...
...
@@ -76,7 +77,8 @@ def scan(img_path: Path, location_path: Path, # smaller delta
client
.
move
(
0
,
0
,
_SWEEEP_HEIGHT
)
# ensure moving from original
for
x
,
y
in
pts
:
client
.
move
(
x
,
y
,
_SWEEEP_HEIGHT
)
# move camera
take_photo
(
img_path
)
#take_photo(img_path)
client
.
take_photo
()
client
.
shutdown
()
# write to img/location
with
open
(
path
.
join
(
location_path
,
"
location.txt
"
),
'
w
'
)
as
f
:
...
...
@@ -85,14 +87,21 @@ def scan(img_path: Path, location_path: Path, # smaller delta
return
None
def
take_photo
(
img_path
:
Path
):
HERE
=
path
.
dirname
(
__file__
)
IMG_DIR
=
path
.
join
(
HERE
,
img_path
)
def
take_photo
():
client
=
FarmbotClient
(
creds
.
device_id
,
creds
.
token
)
client
.
take_photo
()
# download image
system
(
'
python ./utils/download.py
'
)
# def take_photo(img_path: Path):
# HERE = path.dirname(__file__)
# IMG_DIR = path.join(HERE, img_path)
with
request
.
urlopen
(
'
http://localhost:8080/?action=snapshot
'
)
as
photo
:
filename
=
datetime
.
now
().
strftime
(
"
%Y-%m-%dT%H:%M:%S
"
)
+
"
.jpg
"
with
open
(
path
.
join
(
IMG_DIR
,
filename
),
mode
=
"
wb
"
)
as
save_file
:
save_file
.
write
(
photo
.
read
())
#
with request.urlopen('http://localhost:8080/?action=snapshot') as photo:
#
filename = datetime.now().strftime("%Y-%m-%dT%H:%M:%S") + ".jpg"
#
with open(path.join(IMG_DIR, filename), mode="wb") as save_file:
#
save_file.write(photo.read())
def
simple_move
(
x
:
int
,
y
:
int
,
z
:
int
)
->
None
:
...
...
@@ -145,12 +154,14 @@ if __name__ == '__main__':
destination_x
=
int
(
input
(
'
X:
'
))
destination_y
=
int
(
input
(
'
Y:
'
))
destination_z
=
int
(
input
(
'
Z:
'
))
photo
=
True
if
input
(
'
Take a photo or not?[Y/N]:
'
)
==
'
Y
'
else
False
simple_move_start
=
time
()
simple_move
(
destination_x
,
destination_y
,
destination_z
,
photo
)
simple_move
(
destination_x
,
destination_y
,
destination_z
)
Logger
.
info
(
f
'
time cost
{
time
()
-
simple_move_start
}
'
)
elif
arguments
.
mode
==
2
:
scan
(
arguments
.
photo
,
arguments
.
locations
,
flag
=
False
)
#take_photo(arguments.photo)
elif
arguments
.
mode
==
3
:
take_photo
()
else
:
Logger
.
error
(
'
Wrong mode number {arguments.mode}
'
)
...
...
This diff is collapsed.
Click to expand it.
src/client.py
→
src/
utils/
client.py
+
3
−
3
View file @
548b938b
...
...
@@ -33,12 +33,12 @@ def read_pin_request(pin_number, pin_mode="digital"):
return
{
"
kind
"
:
"
rpc_request
"
,
"
args
"
:
{
"
label
"
:
""
},
"
body
"
:
[{
"
kind
"
:
"
read_pin
"
"
body
"
:
[{
"
kind
"
:
"
read_pin
"
,
"
args
"
:
{
"
label
"
:
"
pin
"
+
str
(
pin_number
),
"
pin_mode
"
:
modes
[
pin_mode
]
or
(
modes
[
"
digital
"
]),
"
pin_number
"
:
pin_number
}
}
}]}
def
write_pin_request
(
pin_number
,
pin_value
,
pin_mode
=
"
digital
"
):
modes
=
{
"
digital
"
:
0
,
"
analog
"
:
1
}
...
...
@@ -58,7 +58,7 @@ def write_pin_request(pin_number, pin_value, pin_mode="digital"):
]
}
def
toggle_pin_request
(
pin_number
)
def
toggle_pin_request
(
pin_number
)
:
return
{
"
kind
"
:
"
rpc_request
"
,
"
args
"
:
{
"
label
"
:
""
},
"
body
"
:
[{
"
kind
"
:
"
toggle_pin
"
,
...
...
This diff is collapsed.
Click to expand it.
src/request_token.py
→
src/
utils/
request_token.py
+
0
−
0
View file @
548b938b
File moved
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