Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
255 commits
Select commit Hold shift + click to select a range
c696bfa
Dockerize
ka2ush19e Apr 17, 2017
90cbc0a
Fix pickup-mode
ka2ush19e May 10, 2017
df6d569
Add model reset script
ka2ush19e May 11, 2017
819c31a
Update README.md
mehmandarov Jul 17, 2017
ad1191a
Update README.md
mehmandarov Jul 17, 2017
c947ef2
Update README.md
mehmandarov Jul 17, 2017
749648f
Update README.md
mehmandarov Jul 17, 2017
5f82066
Update README.md
mehmandarov Jul 18, 2017
a082852
Update build_package.sh
mehmandarov Jul 18, 2017
cdf1541
Update README.md
mehmandarov Jul 18, 2017
4b89022
Update README.md
mehmandarov Jul 18, 2017
61f69aa
Update README.md
mehmandarov Jul 18, 2017
bbfd429
Update README.md
mehmandarov Jul 18, 2017
d4334fd
Update v1beta1 to v1. Ver. v1beta1 is deprecated.
mehmandarov Jul 18, 2017
2eefe16
Update linux_box.md
mehmandarov Aug 16, 2017
8535827
Update linux_box.md
mehmandarov Aug 16, 2017
cb70ac7
Some improvements of the setup
mehmandarov Aug 28, 2017
421cd60
Merge branch 'develop' of https://github.com/mehmandarov/FindYourCand…
mehmandarov Aug 28, 2017
587f2ea
Added a description for the new, docker-based setup
mehmandarov Aug 29, 2017
364d105
Minor changes
mehmandarov Aug 29, 2017
55aaf9c
Minor changes
mehmandarov Aug 29, 2017
dc9e1db
Update linux_box.md
mehmandarov Aug 29, 2017
a209862
Updated ML API version to v1 from beta
mehmandarov Mar 13, 2018
391302c
Merge branch 'develop' of https://github.com/mehmandarov/FindYourCand…
mehmandarov Mar 13, 2018
5c00f22
Merge branch 'develop'
Jun 27, 2018
b1d8307
Add new setup guide and simplify setup
SindreSB Jun 27, 2018
0df8b57
changed UI language to norwegian, updated CSS-colors.
Jun 27, 2018
fbd9acf
Changed ansible script to rebuild docker images
SindreSB Jun 27, 2018
18abd97
Fix path error in ansible script
SindreSB Jun 27, 2018
66a9748
Fix missing directory specifier
SindreSB Jun 27, 2018
94849bc
Improved setup guide
SindreSB Jun 27, 2018
ac02a31
Fix setup guide to state that the robot should be calibated before th…
SindreSB Jun 27, 2018
1d7351e
Fix setupguide
SindreSB Jun 27, 2018
e2ba579
Add new setup guide and simplify setup
SindreSB Jun 27, 2018
69dea24
Merge branch 'feature-improve-setup' of https://github.com/SindreSB/F…
SindreSB Jun 27, 2018
ef2f3fb
Kjørende program
Jun 28, 2018
01e01b3
images
Jun 28, 2018
a49a4f6
plotter accuracy og loss, skal forbedre treningen. Test og trening da…
Jun 29, 2018
21826a6
Add API-endpoint for translating text using the Google Cloud Translat…
SindreSB Jul 2, 2018
2c25320
Fix error, and make source language optional.
SindreSB Jul 2, 2018
1cd81d4
Update SETUP_GUIDE.md
ingrie Jul 2, 2018
5d49b7e
Merge branch 'feature-norwegian-translation'
SindreSB Jul 2, 2018
5e69ffe
Add dummy image and update config
SindreSB Jul 2, 2018
9f04975
Merge branch 'design' into improve-css
ingrie Jul 2, 2018
80dc7e5
plot har labels som viser hva som er hva, har også lagt til utskrift …
Jul 2, 2018
0a611ab
Update README.md
SindreSB Jul 2, 2018
7bcff74
Disable Flask reloader, as this causes issues with Tensorflow when de…
SindreSB Jul 2, 2018
1fdb36f
Update depencencies and code to Python 3
SindreSB Jul 2, 2018
b30bf0f
ferdig læring
Jul 3, 2018
a991360
Begin updating Docker images to Python3
SindreSB Jul 3, 2018
f610e2e
Merge branch 'machine-leaning' into python3
SindreSB Jul 3, 2018
65616e6
label name fix
Jul 3, 2018
46dbcf4
Merge branch 'machine-leaning' into python3
SindreSB Jul 3, 2018
7a0a31c
Use new classification model
SindreSB Jul 3, 2018
b92f301
Update Docker images to python 3
SindreSB Jul 3, 2018
93230ae
README.md
Jul 3, 2018
16e6663
README.md fix
Jul 3, 2018
1a3c79e
Disable logging to file in production
SindreSB Jul 3, 2018
de178cd
Move uWSGI requirment to prod to support windows in dev
SindreSB Jul 3, 2018
35ba33a
Merge remote-tracking branch 'origin/machine-leaning' into python3
SindreSB Jul 3, 2018
fdbe4fa
Merge remote-tracking branch 'origin/python3-docker' into python3
SindreSB Jul 3, 2018
af705f9
Fix loading of Word2Vec model and reduce blur threshold
SindreSB Jul 3, 2018
91b4524
delay in predict UI, loading animation, logo
ingrie Jul 3, 2018
c5b1ccd
Move robot requirements to support windows
SindreSB Jul 3, 2018
03c4e14
Update robot-arm to support Python 3.6
SindreSB Jul 4, 2018
3f96330
ingrie Jul 4, 2018
f86c6d7
Remove test to enable use on Google Cloud ML
SindreSB Jul 4, 2018
88a9c31
Update Cloud ML job to TF1.8 and Python 3.5
SindreSB Jul 4, 2018
ddc0b02
Merge branch 'gcp-ml-t18' into python3
SindreSB Jul 4, 2018
6da2e10
ingrie Jul 4, 2018
22abcd5
ingrie Jul 4, 2018
8fdb5ff
Update README.md
SindreSB Jul 4, 2018
00c9afb
Update README.md
SindreSB Jul 4, 2018
6b42f38
Fix image urls when hosted on windows
SindreSB Jul 4, 2018
964b00f
Add utility functions to work around the use of symlinks for classifi…
SindreSB Jul 4, 2018
963f76e
Cache text analysis to avoid making duplicate requests
SindreSB Jul 4, 2018
5124ed3
Move unused scripts
SindreSB Jul 5, 2018
bd087aa
Add readme to descripbe ansible/docker setup
SindreSB Jul 5, 2018
dd3b124
Move and rename setup guides
SindreSB Jul 5, 2018
ae60ebb
Merge branch 'cache-text-analysis'
SindreSB Jul 5, 2018
e4697fe
Merge branch 'windows-compatability'
SindreSB Jul 5, 2018
5b20789
ingrie Jul 5, 2018
533685d
Merge branch 'improve-css'
ingrie Jul 5, 2018
38b09c1
Fix disabled speech recognition
SindreSB Jul 5, 2018
f376fcf
Major improvements to UI and ML, as well as updating system to Python 3
SindreSB Jul 5, 2018
b510614
Add support for gripper commands in dobot library
SindreSB Jul 5, 2018
9160dca
larger trainingset and more challenging test images, test flag added …
Jul 6, 2018
1356100
Merge branch 'master' into release
mehmandarov Jul 9, 2018
15248e4
Merge pull request #1 from SindreSB/release
mehmandarov Jul 9, 2018
2f5bdda
New design thanks-page
ingrie Jul 9, 2018
ad03884
model trained on 250 pictures per label
Jul 9, 2018
d94f7ff
ingrie Jul 9, 2018
5f3ab25
Merge branch 'master' into translate-UI
ingrie Jul 9, 2018
a54d763
model trained on 250 pictures per label
Jul 9, 2018
bdefd60
ingrie Jul 9, 2018
d883c31
Possible logic for key/time navigation between predict steps
Jul 9, 2018
bc4c672
Add support for running the belt forwards and backwards
SindreSB Jul 9, 2018
02c0f6b
Merge branch 'master' of https://github.com/SindreSB/FindYourCandy
SindreSB Jul 9, 2018
d18ce3e
ingrie Jul 10, 2018
cfe1783
Add check in case /similarities is called without a previous call to …
SindreSB Jul 10, 2018
6059109
Made following presses of the wait-key navigate forwards
Jul 10, 2018
f49565f
Add a fake API to simplify setup to UI development
SindreSB Jul 10, 2018
e58357c
Added short readme
SindreSB Jul 10, 2018
fa4218a
Added encoding to file
SindreSB Jul 10, 2018
2a72b55
Enable rotation in robot client code
SindreSB Jul 10, 2018
c863638
Merge branch 'mock-api'
SindreSB Jul 10, 2018
a0faf7c
Merge branch 'translate-UI'
ingrie Jul 10, 2018
5362513
Merge remote-tracking branch 'origin/master'
ingrie Jul 10, 2018
9765863
Add endpoint for pickup with gripper, and update robot tune to python 3
SindreSB Jul 10, 2018
3a3c7c0
Tune sleeping params
SindreSB Jul 10, 2018
43dd342
ingrie Jul 11, 2018
f75cb02
Added script for capturing training images
Jul 11, 2018
0a4c769
Merge branch 'master' into ml-merge-master
Jul 11, 2018
3358c98
New logo/symbols. Changes to match sketches
ingrie Jul 11, 2018
763a39c
Merge branch 'cam-UI'
ingrie Jul 11, 2018
095f42c
Add functionality to use gripper with correct rotation to pick up candy
SindreSB Jul 11, 2018
48112c7
Merge branch 'rotation'
SindreSB Jul 11, 2018
c41adb5
Add new example tune which doesn't use invalid coordinates
SindreSB Jul 11, 2018
34f8f63
Added camera UI.
ingrie Jul 11, 2018
fa84c0b
Merge branch 'cam-UI'
ingrie Jul 11, 2018
34ea5ba
minor color change to match sketch
ingrie Jul 11, 2018
eb26564
cleaned up, however not ready for merging with master
Jul 11, 2018
98ab85a
Add support for tuning of rotation
SindreSB Jul 12, 2018
3808dbf
Update example tune with optional serving destination, and tweek tuni…
SindreSB Jul 12, 2018
0c8642c
Cam UI showing labels. Not ready for merge
ingrie Jul 12, 2018
805dc1d
Add more instructions to the robot_tune script
SindreSB Jul 13, 2018
08be217
Merge branch 'calibrate-robot-rotation'
SindreSB Jul 13, 2018
ce0ceb1
Return error info when image capture fails
SindreSB Jul 13, 2018
212bc2c
Cam-UI improvements
ingrie Jul 13, 2018
28f3609
Blurry filter effect, wip
ingrie Jul 13, 2018
69e7749
Minor changes to make master release friendly
SindreSB Jul 16, 2018
108f8c4
Fix errors in tune scripts and default config
SindreSB Jul 16, 2018
d1c4442
Use --mark-drop argument in tune_robot.sh
SindreSB Jul 16, 2018
0cb3b0e
Cam-UI animations working.
ingrie Jul 17, 2018
ae1d016
Fixed end-roll
ingrie Jul 17, 2018
6bdc0da
Footer-styling
ingrie Jul 17, 2018
06f2533
Add first draft of simple speech to text server
SindreSB Jul 17, 2018
feda643
Minor improvements and cleanup
ingrie Jul 18, 2018
6f8ba64
Fixed animation time
ingrie Jul 18, 2018
b84e7f1
Merge branch 'cam-UI'
Jul 18, 2018
2d83248
Fixed delayed input text UI
ingrie Jul 18, 2018
bddb5cf
Add new attempt and more test clips
SindreSB Jul 18, 2018
dc23089
Begin work to support returning results
SindreSB Jul 18, 2018
7d3cfca
one model for box candy, one for twist.
Jul 18, 2018
0a15465
Support streaming GCP Voice API over websocket
SindreSB Jul 18, 2018
d0ed2bd
capture_images_for_training is done
Jul 19, 2018
2188b9f
Set a variable for candy_type in views.config, 0 for twist is set as …
Jul 19, 2018
b9655d8
Merge branch 'ml-merge-master'
Jul 19, 2018
2cd4399
Removing unused files
Jul 19, 2018
ad8dfda
Refactor code into multiple files for readability
SindreSB Jul 19, 2018
9904784
Merge branch 'speech-streaming'
SindreSB Jul 19, 2018
7689be7
Use Speech API and show interim results
SindreSB Jul 19, 2018
62d2ed8
Added fix to read config from camera_tune
SindreSB Jul 20, 2018
898cc35
Add docker image for speech
SindreSB Jul 20, 2018
f0f8dbc
Add speech container to build script
SindreSB Jul 20, 2018
bdeb735
Added phrase hints to speech app
SindreSB Jul 23, 2018
cb38f26
Added more colors in CSS
ingrie Jul 23, 2018
03a4b28
Rewrote speech streaming into using class syntax
SindreSB Jul 23, 2018
29074ac
Merge branch 'speech-docker'
SindreSB Jul 23, 2018
4edc751
Add ability to pause before next step
SindreSB Jul 23, 2018
10c5dc5
Send center coordinates for all candies in similarities endpoint
SindreSB Jul 23, 2018
24a60b3
Add pause.js for pause functionality
SindreSB Jul 23, 2018
47084ea
Change reported language from japanese to norwegian on the predict an…
SindreSB Jul 23, 2018
659480d
Fixes for robot-app to improve pickup with gripper
SindreSB Jul 23, 2018
44dc13b
Improve pickup with gripper and surface alarm info
SindreSB Jul 24, 2018
0854d5b
Modify pickup to not use "jumping"
SindreSB Jul 24, 2018
02cdae1
Add jumping again and document more alarm states
SindreSB Jul 24, 2018
b4019a9
Add camera status endpoint to api
SindreSB Jul 24, 2018
744af9e
Merge branch 'calibrate_camera'
SindreSB Jul 24, 2018
26aa23b
Added Settings route in Mock-Api
ingrie Jul 25, 2018
aaf371e
New logos and icons
ingrie Jul 25, 2018
c7652a9
Added settings js, html and css
ingrie Jul 25, 2018
c380154
Icon for settings page in predict
ingrie Jul 25, 2018
9424dca
Changed from only colors to text status
ingrie Jul 25, 2018
30e175c
Support two classification models
SindreSB Jul 25, 2018
0441a96
Add docstring to speech-app run script
SindreSB Jul 25, 2018
856610c
Settings page UI, missing js
ingrie Jul 25, 2018
2fd39aa
UI fixes
ingrie Jul 25, 2018
6922466
Add more status API endpoints to simplify error diagnosis
SindreSB Jul 25, 2018
ce7c1ae
Fix symlinks for classifiers
ingrie Jul 26, 2018
de9d378
Merge branch 'settings-UI'
ingrie Jul 26, 2018
44ca4cd
Rename error response
SindreSB Jul 26, 2018
e25c711
Merge branch 'status-api'
SindreSB Jul 26, 2018
0c879eb
Implement status checking on status page and begin implementings a co…
SindreSB Jul 26, 2018
a48ea21
Added config.js, implemented all settings
SindreSB Jul 26, 2018
7b0cf2e
Implemented language setting
SindreSB Jul 26, 2018
e153ead
Add capability to set transition times in config
SindreSB Jul 27, 2018
41753d2
added changes to feature_extractor and capture_images_for_training
Jul 27, 2018
05b8ca8
changes added to camera_tune, train and config
Jul 27, 2018
b42b28e
settings.css refactor, added custom scrollbar
ingrie Jul 27, 2018
cff9a3c
Try to use multithreading
SindreSB Jul 27, 2018
6a76eb2
Updated hand animation
ingrie Jul 27, 2018
0821c98
Expose threading argument and multithread test extraction as well
SindreSB Jul 27, 2018
27fa2ac
Refactor endroll, no user feedback
ingrie Jul 27, 2018
447c886
Update feature extractor to multithread both train and test, and merg…
SindreSB Jul 27, 2018
38b4bbe
Refactor and rewrite feature extractor to safely utilize multiple thr…
SindreSB Jul 30, 2018
f86aa49
Add finish estimation to feature_extractor
SindreSB Jul 30, 2018
63da34d
UI changes to match sketch
ingrie Jul 30, 2018
12f8fb5
Batch calls to path generator to reduce locking frequency
SindreSB Jul 30, 2018
5ae7a94
updated init() in init.js
ingrie Jul 30, 2018
cbe9801
Create README.md
SindreSB Jul 30, 2018
4fed6ff
pause and fwd icons on pause/resume
ingrie Jul 30, 2018
8674776
Implemented pause countdown spinner
ingrie Jul 31, 2018
f29212e
Cam-ui lines fixed, no gap
ingrie Jul 31, 2018
c44edb6
Fix settings bug
ingrie Jul 31, 2018
2c94ba8
All labels same color in cam
ingrie Jul 31, 2018
1c160be
removed redirect on click
ingrie Jul 31, 2018
b8382df
Merge branch 'sketch-ui'
Jul 31, 2018
d31942c
hostname changed
ingrie Jul 31, 2018
1aa164c
Add modification of gamma values to feature extraction
SindreSB Jul 31, 2018
7d47e3b
Add typecasting to gamma correction and mute depreacting warnings fro…
SindreSB Jul 31, 2018
ef45d98
Ann conversion back to uint8
SindreSB Jul 31, 2018
736f3f2
Changed circle size cam, removed learn link from speech
ingrie Jul 31, 2018
6bdab3b
Add general suggestions for input
ingrie Jul 31, 2018
b5d31ec
Change UI language updates localstorage variable
ingrie Jul 31, 2018
4959938
removed consolelog
ingrie Jul 31, 2018
fb48e1b
Added language resource file
ingrie Jul 31, 2018
03159e1
Change into using multiple processes for feature extraction and add r…
SindreSB Aug 1, 2018
c76894b
Localization working for all html
ingrie Aug 1, 2018
eb934c9
Examples change on UI-lang
ingrie Aug 1, 2018
fd5f5b5
Fix using wrong output file for test
SindreSB Aug 1, 2018
3607ed0
Suppress warnings and move start of queue to before process creation
SindreSB Aug 1, 2018
2d091fc
Update feature_extractor to generate more random gamma values
SindreSB Aug 1, 2018
6a9e35e
Make train.py imports compatible with Google Cloud ML
SindreSB Aug 2, 2018
b99509a
Update config with production values
SindreSB Aug 2, 2018
1007741
Minor update to readme
SindreSB Aug 2, 2018
b699fd9
Merge branch 'sketch-ui'
SindreSB Aug 2, 2018
61dfeac
Fix some labels not showing outline
SindreSB Aug 2, 2018
b4b295e
Replaced placeholder images
ingrie Aug 2, 2018
b0428ec
updated toFixed to control decimals in cam
ingrie Aug 2, 2018
a798947
Reduce size of cam bubbles
SindreSB Aug 2, 2018
7cf1339
Fixed html encoded chars after translation
SindreSB Aug 2, 2018
1062a16
Cleaned up trainer dir for merge
SindreSB Aug 2, 2018
96f4bb4
Merge branch 'ml-merge'
SindreSB Aug 2, 2018
5f7931a
Create README.md
SindreSB Aug 2, 2018
d6e3cda
Update README.md
SindreSB Aug 2, 2018
85e04c6
Update README.md
SindreSB Aug 2, 2018
9e31b93
Update README.md
SindreSB Aug 2, 2018
a7a154c
Update README.md
SindreSB Aug 2, 2018
abfbee5
Remove temp files from git
SindreSB Aug 2, 2018
a521191
Update README.md
SindreSB Aug 2, 2018
09449ed
Update README.md
SindreSB Aug 2, 2018
13c5f3b
Added z-index to cam circle and text
ingrie Aug 2, 2018
ec656d6
changed svg loop in cam, removed hard coded inputspeech
ingrie Aug 2, 2018
fea7bb3
Merge branch 'sketch-ui'
ingrie Aug 2, 2018
0618459
Update forceplot to draw in order of size
SindreSB Aug 2, 2018
76e7802
Add best twist model as initial classifier
SindreSB Aug 3, 2018
5faa666
Update README.md
mehmandarov Sep 11, 2018
8e14640
Update README.md
mehmandarov Sep 11, 2018
4879227
Merge branch 'release-final' of https://github.com/SindreSB/FindYourC…
mehmandarov Oct 10, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.git

**/credentials.json
**/robot_tuner.dat
**/GoogleNews-vectors-negative300.bin.gz
**/model.vec
**/classify_image_graph_def.pb
**/classifier_candy_sorter*
**/logs/*
**/tmp
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ ENV/

### Application

# data
data/

# Log rotation
*.log.*

Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@ In the training mode, the system uses Inception model with transfer learning on
- Controller PC (Linux) and camera: recognizes the candies with Cloud ML, controls the robot arm
- Robot arm: picks the candy, takes it to the certain location, and drops.

### Candy type
The robot can handle two types of candy. Small candy that can be picked up, for which it will correcly adjust the gripper to account for rotation etc. It also supports boxed/smooth candy which it picks up using a suction cup.

## Learning mode
- Android tablet: shows UI for training process updates
- Controller PC: runs Inception-v3 + transfer learning on Cloud ML to train a model from scratch, with the camera image
- More on [learning mode](/setup/demo_script.md)

## Setting things up
- Prepare [hardware components](./setup/requirements.md)
- Prepare [candies](./setup/candidate_candies.md)
- Set up as directed by [setup/README.md](./setup/README.md)
- Set up as directed by [setup/README.md](./setup/SETUP_GUIDE.md)

## Troublehooting
- See [this page](/setup/troubleshooting.md) in case you encounter any errors or unexpected behaviour.

## Troublehooting
- See [this page](/setup/troubleshooting.md) in case you encounter any errors or unexpected behaviour.

## Note
- Currently, the system is not using Cloud Speech API. It uses Web Speech API that shares the same voice recognition backend.
- For Learning mode it is using Cloud ML training. For Serving mode it is not using Cloud ML prediction.
6 changes: 2 additions & 4 deletions robot-arm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ robot-arm (api)
===

## Note
This software is design to work with Python2.7 under following condition.
This software is designed to work with Python3.6 under following conditions:
- This software depends on the following libraries:
- OpenCV3.2 (need to be compiled from source.)
- Refer to [setup/README.md](../setup/README.md) for installation.
- Environment variables
```
export FLASK_ENV='prd' # choices are 'prd', 'stg' or 'dev'
Expand All @@ -28,7 +26,7 @@ $ sudo systemctl start uwsgi-robot.service
In this setup senario, the next command is not used. We use nginx+uWSGI instead.
```
# Run app. This requres environment variables.
$ python2 run_api.py # Be sure to use python2.7
$ python3 run_api.py # Be sure to use python2.7
```

## API example
Expand Down
22 changes: 16 additions & 6 deletions robot-arm/calibration/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


class CoordinateConverter(object):
def __init__(self, from_points, to_points, z_low=-69):
def __init__(self, from_points, to_points, z_low=-31, r=0):
"""
find T that meets x_robot = T x_logical
"""
Expand All @@ -39,18 +39,23 @@ def __init__(self, from_points, to_points, z_low=-69):

self.mat_transform = np.dot(self.mat_x_to.T, inv_x)
self.z_low = z_low
self.r_offset = r

def convert(self, x, y):
def convert(self, x, y, r = None):
xy_trans = AdjustForPictureToRobot()
x, y = xy_trans.adjust(x, y)

from_vector = np.array([x, y, 1])
transformed = np.dot(from_vector, self.mat_transform.T)

return transformed[0], transformed[1]
if r is None:
return transformed[0], transformed[1]
else:
adjusted_r = r + self.r_offset
return transformed[0], transformed[1], adjusted_r

@classmethod
def from_tuning_file(cls, file_='/tmp/robot_tuner.dat', z_low_pad=5):
def from_tuning_file(cls, file_, z_low_pad=1):
tuner_data = []
with open(file_, 'r') as readfile:
for line in readfile:
Expand All @@ -59,11 +64,16 @@ def from_tuning_file(cls, file_='/tmp/robot_tuner.dat', z_low_pad=5):
data = json.loads(line)
tuner_data.append(data)

z_low = sum([d['z'] for d in tuner_data])/3 + z_low_pad
# Find z low by averaging the measured z's
z_low = sum([d['z'] for d in tuner_data[:3]])/3 + z_low_pad
# If there is a fourth line, it contains the r-offset.
r = 0 if len(tuner_data) < 4 else tuner_data[3]['r']

return cls(
[(-0.3, 1.5), (-0.3, -1.5), (0.3, 0)],
[(tuner_data[0]['x'], tuner_data[0]['y']),
(tuner_data[1]['x'], tuner_data[1]['y']),
(tuner_data[2]['x'], tuner_data[2]['y'])],
z_low=z_low
z_low=z_low,
r=r
)
8 changes: 5 additions & 3 deletions robot-arm/calibration/example_tune.dat
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{"x":78.83, "y": 132.45, "z":-70.82}
{"x":74.41, "y":-145.70, "z":-70.06}
{"x":175.01, "y": -7.77, "z":-69.91}
{"x": 172.98753356933594, "y": 176.05148315429688, "z": -35.271888732910156}
{"x": 181.35813903808594, "y": -169.5199432373047, "z": -30.119842529296875}
{"x": 246.0970458984375, "y": 6.5959792137146, "z": -33.612144470214844}
{"r": 7.0}
{"x": 24.846025466918945, "y": 303.1612243652344, "z": 60.07351303100586}
74 changes: 74 additions & 0 deletions robot-arm/dobot/alarms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
alarms = {
"0x00": {
"Category": "Public Alarm",
"Name": "Reset Alarm",
"SetCondition": " After the system reset, the reset alarm will be set automatically",
"ResetCondition": " Protocol instruction is cleared"
},
"0x01": {
"Category": "Public Alarm",
"Name": "Undefined Instruction",
"SetCondition": "Undifined instruction is received",
"ResetCondition": "The protocol instruction is cleared."
},
"0x02": {
"Category": "Public Alarm",
"Name": "File System Error",
"SetCondition": "The file system errors;",
"ResetCondition": "Reset, if the file system initialization is successful, then reset the alarm automatically."
},
"0x03": {
"Category": "Public Alarm",
"Name": "Failed Communication between MCU and FPGA",
"SetCondition": "The communication between MCU and FPGA is failed when initialization;",
"ResetCondition": "Reset, if the communication is successful, then reset the alarm automatically"
},
"0x04": {
"Category": "Public Alarm",
"Name": "Angle Sensor Reading Error",
"SetCondition": "The angle sensor value can not be read correctly",
"ResetCondition": "Power off, power on again, if the angle sensor value can be read correctly, then reset alarm."
},
"0x11": {
"Category": "Planning Alarm",
"Name": "Inverse Resolve Alarm",
"SetCondition": "The planning target point is not in the robot work space, resulting in the reverse solution error",
"ResetCondition": "The protocol instruction is cleared"
},
"0x12": {
"Category": "Planning Alarm",
"Name": "Inverse Resolve Limit",
"SetCondition": "Inverse resolve of the target point beyond the joint limit value",
"ResetCondition": "The protocol instruction is cleared"
},
"0x13": {
"Category": "Planning Alarm",
"Name": "Arc Input Parameter Alarm",
"SetCondition": "Enter the midpoint of the arc, and the target point can not form an arc",
"ResetCondition": "The protocol instruction is cleared"
},
"0x15": {
"Category": "Planning Alarm",
"Name": "JUMP Parameter Error",
"SetCondition": "The planning starting point or the target point height above the set maximum JUMP height",
"ResetCondition": "The protocol instruction is cleared"
},
"0x21": {
"Category": "Kinematic Alarm",
"Name": "Inverse Resolve Alarm",
"SetCondition": "The movement process beyond the robot work space resulting in the inverse solution error",
"ResetCondition": "The protocol instruction is cleared"
},
"0x22": {
"Category": "Kinematic Alarm",
"Name": "Inverse Resolve Limit",
"SetCondition": "The inverse solution of the motion exceeds the Joint limit value",
"ResetCondition": "The protocol instruction is cleared"
},
"0x44": {
"Category": "Limit Alarm",
"Name": "Joint 3 Positive Limit Alarm",
"SetCondition": "Joint 3 moves in the positive direction to the limit area",
"ResetCondition": "Protocol command reset the alarm manually; reset the alarm in reverse exit limit area automatically"
}
}
57 changes: 49 additions & 8 deletions robot-arm/dobot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import logging
import time


from dobot import command
from dobot import alarms
from dobot.errors import TimeoutError
from dobot.serial import SerialCommunicator

Expand All @@ -32,6 +34,7 @@ def __init__(self, port, baudrate, read_timeout_sec=10, serial_timeout_sec=5):
port, baudrate, read_timeout_sec=read_timeout_sec, serial_timeout_sec=serial_timeout_sec
)


def get_pose(self):
return self.serial.call(command.GetPose())

Expand All @@ -51,40 +54,78 @@ def count_queued_command(self):
result = self.serial.call(command.GetQueuedCmdLeftSpace())
return DOBOT_QUEUE_SIZE - result['leftSpace']

def get_alarms_state(self, discard_reset_alarm=True):
# Get the alarms from the Dobot
result = self.serial.call(command.GetAlarmsState())
# Process alarm data into a string with bit flags
alarm_string = "".join(["{0:0>8b}".format(x)[::-1] for x in list(result)[4:-1]]) # Get only the alarm values
# Traverse the bit flags and extract the alarm IDs
alarm_ids = ["0x" + "{0:0>2X}".format(index) for index, value in
enumerate(alarm_string[int(discard_reset_alarm):]) if value == "1"]
# Lookup alarm ids to get the information about the alarms
dobot_alarms = [alarms.alarms.get(alarm_id) if alarms.alarms.get(alarm_id) else alarm_id
for alarm_id in alarm_ids]
return dobot_alarms

def clear_alarms_state(self):
return self.serial.call(command.ClearAllAlarmsState())

def initialize(self):
self.serial.call(command.ClearAllAlarmsState())
self.serial.call(command.SetQueuedCmdClear())
self.adjust_z(0)
self.serial.call(command.SetHomeCmd())

def move(self, x, y, z, velocity=200, accel=200, jump=True):
def move(self, x, y, z, r=0, velocity=200, accel=200, jump=True):
self.serial.call(command.SetPTPJointParams(velocity, velocity, velocity, velocity, accel, accel, accel, accel))

mode = 0
if not jump:
mode = 1

self.serial.call(command.SetPTPCmd(mode, x, y, z, 0))
self.serial.call(command.SetPTPCmd(mode, x, y, z, r))

def linear_move(self, x, y, z, velocity=200, accel=200):
def linear_move(self, x, y, z, r=0, velocity=200, accel=200):
self.serial.call(command.SetPTPCoordinateParams(velocity, velocity, accel, accel))
self.serial.call(command.SetPTPCmd(2, x, y, z, 0))
self.serial.call(command.SetPTPCmd(2, x, y, z, r))

def pickup(self, x, y, z_low=0, z_high=100, sleep_sec=1, velocity=200, accel=100, num_trials=1):
self.move(x, y, z_high, velocity, accel)
self.move(x, y, z_high, 0, velocity, accel)
self.pump(1)
for i in range(num_trials):
self.linear_move(x, y, z_low, velocity, accel)
self.linear_move(x, y, z_low, 0, velocity, accel)
time.sleep(sleep_sec)
self.linear_move(x, y, z_high, 0, velocity, accel)

def pickup_gripper(self, x, y, r, z_low=0, z_high=100, sleep_sec=0.5, velocity=200, accel=100, num_trials=1):
self.grip(0)
self.move(x, y, z_high, r, velocity, accel)
for i in range(num_trials):
self.linear_move(x, y, z_low, r, velocity, accel)
time.sleep(1)
self.grip(1)
self.wait(120)
time.sleep(sleep_sec)
self.linear_move(x, y, z_high, velocity, accel)
self.linear_move(x, y, z_high, r, velocity, accel)

def adjust_z(self, z):
self.wait()
pose = self.serial.call(command.GetPose())
self.linear_move(pose['x'], pose['y'], z)
self.linear_move(pose['x'], pose['y'], z, pose['r'])

def adjust_r(self, r):
self.wait()
pose = self.serial.call(command.GetPose())
self.linear_move(pose['x'], pose['y'], pose['z'], r)

def pump(self, on):
self.serial.call(command.SetEndEffectorSuctionCup(1, on))

def grip(self, grip):
self.serial.call(command.SetEndEffectorGripper(1, grip))

def stepper_motor(self, index, enabled, reverse=False):
self.serial.call(command.SetEMotor(index, enabled, -10000 if reverse else 10000))

def close(self):
self.serial.close()
29 changes: 27 additions & 2 deletions robot-arm/dobot/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def parse_to_dict(self, packet):


def checksum(payload):
return 0xFF & (0x100 - (sum([ord(c) for c in payload])))
return 0xFF & (0x100 - (sum([c for c in payload])))


def ctrl(rw, is_queued):
Expand All @@ -129,7 +129,9 @@ def __init__(self):

class GetAlarmsState(Command):
def __init__(self):
super(GetAlarmsState, self).__init__(20, 0, 0)
super(GetAlarmsState, self).__init__(
20, 0, 0, '16B'
)


class ClearAllAlarmsState(Command):
Expand Down Expand Up @@ -199,6 +201,29 @@ def __init__(self, is_ctrl_enabled, is_sucked):
self.params = struct.pack('<BB', is_ctrl_enabled, is_sucked)


class SetEndEffectorGripper(Command):
def __init__(self, is_ctrl_enabled, is_gripped):
super(SetEndEffectorGripper, self).__init__(63, 1, 1)
self.params = struct.pack('<BB', is_ctrl_enabled, is_gripped)


"""
Enable stepper motor. While protocal says that speed is a float, it is an int.
10000 will give approx 62mm/s, which is below 100mm/s (max) and not too far from
50-60mm/s which has been recommended by Dobot support.
"""
class SetEMotor(Command):
def __init__(self, index, isEnabled, speed, is_queued=True):
params_fmt = None
params_name = None
if is_queued:
params_fmt = 'Q'
params_name = ['queuedCmdIndex']

super(SetEMotor, self).__init__(135, 1, 1 if is_queued else 0, params_fmt, params_name)
self.params = struct.pack('<BBi', index, isEnabled, speed)


class SetQueuedCmdStartExec(Command):
def __init__(self):
super(SetQueuedCmdStartExec, self).__init__(240, 1, 0)
Expand Down
2 changes: 1 addition & 1 deletion robot-arm/dobot/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


def dump_hex(s):
return ":".join("{:02x}".format(ord(c)) for c in s)
return ":".join("{:02x}".format(c) for c in s)


class SerialCommunicator(object):
Expand Down
7 changes: 4 additions & 3 deletions robot-arm/dobot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def detect_dobot_port(baudrate):

def detect_ports(baudrate):
port_prefix = '/dev/ttyUSB'
all_ports = [port_prefix + str(i) for i in range(5)]
all_ports.extend(["COM" + str(i) for i in range(5)])
found_ports = []
for i in range(5):
port = port_prefix + str(i)
for port in all_ports:
logger.debug('scanning port: {}'.format(port))
try:
s = serial.Serial(port, baudrate, timeout=1)
Expand All @@ -50,7 +51,7 @@ def dobot_is_on_port(port, baudrate):
try:
ser = SerialCommunicator(port, baudrate)
ser.call(command.GetPose())
except IOError as e:
except Exception as e:
print(e)
return False
return True
Loading