├── design
├── 01-Animations.jpg
├── 02-Animations mouseover.jpg
├── 03-Animations clicked.jpg
├── 04-Animations animation done.jpg
└── 05-Animations tags not showing.jpg
├── static
├── img
│ ├── application-screenshot.jpg
│ ├── application-screenshot-v2.0.png
│ ├── cozmo-logo.svg
│ ├── cozmo_blank.svg
│ ├── cozmo_playing.svg
│ └── cozmo_eyes.svg
├── css
│ ├── images
│ │ ├── ui-icons_444444_256x240.png
│ │ ├── ui-icons_555555_256x240.png
│ │ ├── ui-icons_777620_256x240.png
│ │ ├── ui-icons_777777_256x240.png
│ │ ├── ui-icons_cc0000_256x240.png
│ │ └── ui-icons_ffffff_256x240.png
│ ├── cozmo_animation_list_old.css
│ ├── cozmo_animation_list.css
│ └── jquery-ui.css
└── js
│ ├── jquery.ui.touch-punch.min.js
│ ├── jquery.hideseek.js
│ └── engine.js
├── play_animation.py
├── README.md
├── templates
├── index_old.html
└── index.html
├── flask_helpers.py
└── animation_explorer.py
/design/01-Animations.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/design/01-Animations.jpg
--------------------------------------------------------------------------------
/design/02-Animations mouseover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/design/02-Animations mouseover.jpg
--------------------------------------------------------------------------------
/design/03-Animations clicked.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/design/03-Animations clicked.jpg
--------------------------------------------------------------------------------
/design/04-Animations animation done.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/design/04-Animations animation done.jpg
--------------------------------------------------------------------------------
/static/img/application-screenshot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/static/img/application-screenshot.jpg
--------------------------------------------------------------------------------
/design/05-Animations tags not showing.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/design/05-Animations tags not showing.jpg
--------------------------------------------------------------------------------
/static/img/application-screenshot-v2.0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/static/img/application-screenshot-v2.0.png
--------------------------------------------------------------------------------
/static/css/images/ui-icons_444444_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/static/css/images/ui-icons_444444_256x240.png
--------------------------------------------------------------------------------
/static/css/images/ui-icons_555555_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/static/css/images/ui-icons_555555_256x240.png
--------------------------------------------------------------------------------
/static/css/images/ui-icons_777620_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/static/css/images/ui-icons_777620_256x240.png
--------------------------------------------------------------------------------
/static/css/images/ui-icons_777777_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/static/css/images/ui-icons_777777_256x240.png
--------------------------------------------------------------------------------
/static/css/images/ui-icons_cc0000_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/static/css/images/ui-icons_cc0000_256x240.png
--------------------------------------------------------------------------------
/static/css/images/ui-icons_ffffff_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrinningHermit/Cozmo-Animation-Explorer/HEAD/static/css/images/ui-icons_ffffff_256x240.png
--------------------------------------------------------------------------------
/play_animation.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | '''
4 | Play animation script
5 |
6 | Makes Cozmo execute a sample animation
7 |
8 | If you are looking for the interface to test all animations, run 'animation-explorer.py'
9 | '''
10 |
11 | import sys
12 |
13 | import cozmo
14 |
15 |
16 | def run(sdk_conn):
17 | '''The run method runs once Cozmo is connected.'''
18 | robot = sdk_conn.wait_for_robot()
19 | robot.play_anim('anim_freeplay_reacttoface_like_01').wait_for_completed()
20 |
21 | print('Run \'animation-explorer.py\' if you want to try other animations')
22 |
23 | if __name__ == '__main__':
24 | cozmo.setup_basic_logging()
25 |
26 | try:
27 | cozmo.connect(run)
28 | except cozmo.ConnectionError as e:
29 | sys.exit('A connection error occurred: %s' % e)
30 |
--------------------------------------------------------------------------------
/static/js/jquery.ui.touch-punch.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * jQuery UI Touch Punch 0.2.3
3 | *
4 | * Copyright 2011–2014, Dave Furfero
5 | * Dual licensed under the MIT or GPL Version 2 licenses.
6 | *
7 | * Depends:
8 | * jquery.ui.widget.js
9 | * jquery.ui.mouse.js
10 | */
11 | !function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);
--------------------------------------------------------------------------------
/static/img/cozmo-logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Cozmo Animation Explorer v2.0
2 | Interface to test all animations of the robot Cozmo from Anki
3 | ---
4 | While finding out how the SDK of Cozmo works and how to build stuff with it, it appeared there was no listing provided for all the built-in animations the robot can do. This project attempts to remedy that.
5 |
6 | What does it do exactly?
7 | -
8 | Running the script 'animation-explorer.py' in python will open a web page listing all the animations Cozmo has. A user can click the play button of a listed animation and Cozmo will execute it. It is also possible to search for a particular animation and buttons are provided to group animations based on their naming convention. Triggers and Behaviors can also be played. They have separate lists that can be accessed by choosing their respective menu tabs.
9 |
10 | Changes compared to v1.0
11 | -
12 | - Triggers can now be played. They are group names for a set of similar animations. When played, one of the animations from the set is picked randomly.
13 | - Behaviors can now be played. They are ongoing sets of instructions that can be interrupted. I.e.: Playing 'KnockOverCubes' will cause Cozmo to crash a stack of cubes he sees. If no stacked cubes are visible, he will do nothing.
14 | - An option 'return to pose' can be checked. Depending on the animation Cozmo executes, he can move around. Not every animation ends where he started. This checkbox makes sure he returns to the pose he had before the animation starts.
15 | - Playing an animation is now achieved by clicking a button that appears on the line that has the mouse cursor hovering over it.
16 | - Copying the animation can now be done by clicking a button that appears on the line that has the mouse cursor hovering over it OR by selecting the text of the animation name and using the keyboard shortcut Ctrl-C (Windows/Linux) or Command-C (Mac).
17 |
18 | What do you need to use it?
19 | -
20 | 1. Cozmo himself (http://anki.com/cozmo)
21 | 2. A PC and a mobile device
22 | 3. A little knowledge about Python
23 | 4. Knowledge of the Cozmo SDK (http://cozmosdk.anki.com/docs)
24 | 5. The files in this repository
25 |
26 | If you know how to run an example file from the Cozmo SDK, you should be able to run this script.
27 |
28 | System requirements
29 | -
30 | - PC with Windows OS, mac OSX or Linux
31 | - Python 3.5.1 or later
32 | - WiFi connection
33 | - An iOS or Android mobile device with the Cozmo app installed, connected to the PC via USB cable
34 |
35 | Installation notes
36 | -
37 | - Running 'animation-explorer.py' will attempt to open a browser window at 127.0.0.1:5000. This is similar to 'remote_control_cozmo.py' from the Cozmo SDK examples.
38 | - Install the entire project, not just the .py file, or it won't work.
39 |
40 |
41 | 
42 |
--------------------------------------------------------------------------------
/templates/index_old.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
45 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
46 |
47 |
48 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
49 |
50 |
51 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
nothing
72 |
started yet
73 |
74 |
75 |
76 | This is the complete list of animations directly pulled from Cozmo's memory. Click an animation to play it. You can copy an animation for your own use in your python script.
Check the project file 'play_animation.py' on how to play the animation in your own script.
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/flask_helpers.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2016 Anki, Inc.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License in the file LICENSE.txt or at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | '''Wrappers and helpers for using Flask with Cozmo.
16 |
17 | Flask is a Python web framework. remote_control_cozmo.py and other scripts may use
18 | these utility functions to interact with a web browser.
19 | '''
20 |
21 | import logging
22 | import sys
23 | from threading import Thread
24 | import webbrowser
25 | from time import sleep
26 | from io import BytesIO
27 | try:
28 | from flask import make_response, send_file
29 | except ImportError:
30 | sys.exit("Cannot import from flask: Do `pip3 install --user flask` to install")
31 |
32 |
33 |
34 | def _delayed_open_web_browser(url, delay, new=0, autoraise=True, specific_browser=None):
35 | '''
36 | Spawn a thread and call sleep_and_open_web_browser from within it so that main thread can keep executing at the
37 | same time. Insert a small sleep before opening a web-browser
38 | this gives Flask a chance to start running before the browser starts requesting data from Flask.
39 | '''
40 |
41 | def _sleep_and_open_web_browser(url, delay, new, autoraise, specific_browser):
42 | sleep(delay)
43 | browser = webbrowser
44 |
45 | # E.g. On OSX the following would use the Chrome browser app from that location
46 | # specific_browser = 'open -a /Applications/Google\ Chrome.app %s'
47 | if specific_browser:
48 | browser = webbrowser.get(specific_browser)
49 |
50 | browser.open(url, new=new, autoraise=autoraise)
51 |
52 | thread = Thread(target=_sleep_and_open_web_browser,
53 | kwargs=dict(url=url, new=new, autoraise=autoraise, delay=delay, specific_browser=specific_browser))
54 | thread.daemon = True # Force to quit on main quitting
55 | thread.start()
56 |
57 |
58 | def run_flask(flask_app, host_ip="127.0.0.1", host_port=5000, enable_flask_logging=False,
59 | open_page=True, open_page_delay=1.0):
60 | '''
61 | Run the Flask webserver on specified host and port
62 | optionally also open that same host:port page in your browser to connect
63 | '''
64 |
65 | if not enable_flask_logging:
66 | # disable logging in Flask (it's enabled by default)
67 | log = logging.getLogger('werkzeug')
68 | log.setLevel(logging.ERROR)
69 |
70 | if open_page:
71 | # we add a delay (dispatched in another thread) to open the page so that the flask webserver is open
72 | # before the webpage requests any data
73 | _delayed_open_web_browser("http://" + host_ip + ":" + str(host_port), delay=open_page_delay)
74 |
75 | flask_app.run(host=host_ip, port=host_port, use_evalex=False)
76 |
77 |
78 | def make_uncached_response(in_file):
79 | response = make_response(in_file)
80 | response.headers['Pragma-Directive'] = 'no-cache'
81 | response.headers['Cache-Directive'] = 'no-cache'
82 | response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
83 | response.headers['Pragma'] = 'no-cache'
84 | response.headers['Expires'] = '0'
85 | return response
86 |
87 |
88 | def serve_pil_image(pil_img, serve_as_jpeg=False, jpeg_quality=70):
89 | '''Convert PIL image to relevant image file and send it'''
90 | img_io = BytesIO()
91 |
92 | if serve_as_jpeg:
93 | pil_img.save(img_io, 'JPEG', quality=jpeg_quality)
94 | img_io.seek(0)
95 | return make_uncached_response(send_file(img_io, mimetype='image/jpeg'))
96 | else:
97 | pil_img.save(img_io, 'PNG')
98 | img_io.seek(0)
99 | return make_uncached_response(send_file(img_io, mimetype='image/png'))
100 |
--------------------------------------------------------------------------------
/static/css/cozmo_animation_list_old.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | padding: 0;
4 | font-family: "Roboto", "Lucida Grande", Verdana, Arial, sans-serif;
5 | }
6 |
7 | #header {
8 | font-family: "Roboto", "Lucida Grande", Verdana, Arial, sans-serif;
9 | font-size: 2.5em;
10 | color: #ffffff;
11 | text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.05);
12 | background-image: linear-gradient(to bottom right, #fff022, #ffc736);
13 | padding: 20px;
14 | height: 30px;
15 | line-height: 30px;
16 | }
17 |
18 | #content {
19 | display: flex;
20 | flex-direction: row;
21 | text-align: left;
22 | overflow: hidden;
23 | padding: 0 20px 0 20px;
24 | }
25 |
26 | #l-col {
27 | flex: 1 300px;
28 | }
29 |
30 | #c-col {
31 | flex: 1 auto;
32 | }
33 |
34 | #r-col {
35 | flex: 99999;
36 | padding: 20px;
37 | }
38 |
39 | .flex-col {
40 | flex-direction: column;
41 | }
42 |
43 | .flex-item {
44 | flex: auto;
45 | }
46 |
47 | ul {
48 | display: inline-block;
49 | overflow-y: scroll;
50 | list-style: none;
51 | font-family: "Courier", "Lucida Console", monospace;
52 | font-size: .8em;
53 | width: auto;
54 | margin: 0;
55 | padding: 0;
56 | }
57 | li {
58 | clear: both;
59 | border-bottom: solid 1px #eeeeee;
60 | line-height: 26px;
61 | padding: 0 8px 0 8px;
62 | color: #444444;
63 | background-color: #ffffff;
64 | }
65 |
66 | li:hover {
67 | color: #ffffff;
68 | background-color: #444444;
69 | }
70 |
71 | input {
72 | height: 30px;
73 | font-size: 1em;
74 | outline: none;
75 | margin: 0 5px 0 20px;
76 | width: 270px;
77 | }
78 |
79 | select:focus,
80 | textarea:focus,
81 | button:focus {
82 | outline: none;
83 | }
84 |
85 | #filtersubmit {
86 | position: relative;
87 | z-index: 1;
88 | left: -40px;
89 | top: 1px;
90 | color: #dddddd;
91 | width: 0;
92 | }
93 |
94 | #filterclear {
95 | position: relative;
96 | z-index: 2;
97 | left: -34px;
98 | top: 1px;
99 | color: #aaaaaa;
100 | cursor: pointer;
101 | width: 0;
102 | visibility: hidden;
103 | }
104 |
105 | .ui-button{
106 | margin: 5px 5px 0 0;
107 | font-size: .7em;
108 | }
109 |
110 | .logo {
111 | filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.05));
112 | height: 30px;
113 | }
114 |
115 | .bg-grey {
116 | background-color: #eeeeee;
117 | margin: 0 0 0 -20px;
118 | padding: 5px 0 5px 0;
119 | }
120 |
121 | .cozmo {
122 | position: absolute;
123 | width: 200px;
124 | }
125 |
126 | #c-play {
127 | display: none;
128 | animation-name: blink;
129 | animation-duration: 1.2s;
130 | animation-iteration-count: infinite;
131 | }
132 |
133 | #c-eyes {
134 | animation-name: eyeblink;
135 | animation-duration: 10s;
136 | animation-iteration-count: infinite;
137 | }
138 |
139 | @keyframes eyeblink {
140 | 0% {opacity: 1;}
141 | 50% {opacity: 1;}
142 | 50.1% {opacity: 0;}
143 | 51% {opacity: 0;}
144 | 51.1% {opacity: 1;}
145 | 100% {opacity: 1;}
146 | }
147 |
148 | @keyframes blink {
149 | 0% {opacity: 1;}
150 | 50% {opacity: 1;}
151 | 50.1% {opacity: 0;}
152 | 99.9% {opacity: 0;}
153 | 100% {opacity: 1;}
154 | }
155 |
156 | #animation-name {
157 | color: #444444;
158 | font-size: .8em;
159 | text-align: center;
160 | background-color: #eeeeee;
161 | padding: 5px;
162 | line-height: 24px;
163 | position: absolute;
164 | top: 300px;
165 | width: 200px;
166 | }
167 |
168 | #mono {
169 | font-family: "Courier", "Lucida Console", monospace;
170 | word-wrap: break-word;
171 | }
172 |
173 | #status {
174 | color: #aaaaaa;
175 | }
176 |
177 | #animation-name .ui-button {
178 | font-size: 1em;
179 | }
180 |
181 | .content-text {
182 | position: absolute;
183 | top: 440px;
184 | width:200px;
185 | color: #aaaaaa;
186 | font-size: .8em;
187 | }
188 |
189 | .ui-effects-transfer { border: 2px dotted gray; }
190 |
191 | .hermit {
192 | float: right;
193 | font-size: .3em;
194 | color: #bbbbbb;
195 | padding: 11px 0 0 0;
196 | }
197 |
198 | .hermit a{
199 | color: #bbbbbb;
200 | }
201 |
--------------------------------------------------------------------------------
/animation_explorer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | """
4 | List all Cozmo animations on a web page with buttons to try the animations.
5 | In order to run this script, you also need all the other files inside the project.
6 | If that is the case, running this script will load the interface.
7 | """
8 |
9 | from flask import Flask, render_template, request
10 | import flask_helpers
11 | import cozmo
12 | import json
13 | import random
14 | import time
15 | import logging
16 | logging.basicConfig(format='%(asctime)s animation explorer %(levelname)s %(message)s', level=logging.INFO)
17 |
18 | robot = None
19 | cozmoEnabled = True
20 | return_to_pose = False
21 | flask_app = Flask(__name__)
22 | rndID = random.randrange(1000000000, 9999999999)
23 | animations = ''
24 | triggers = ''
25 | behaviors = ''
26 | action = []
27 | pose = None
28 |
29 |
30 | @flask_app.route('/')
31 | def index():
32 | return render_template('index.html', randomID=rndID, animations=animations, triggers=triggers, behaviors=behaviors)
33 |
34 |
35 | @flask_app.route('/toggle_pose', methods=['POST'])
36 | def toggle_pose():
37 | global return_to_pose
38 | # Toggle for returning to pose after finishing animation
39 | return_to_pose = not return_to_pose
40 | logging.info('return_to_pose is set to: ' + str(return_to_pose))
41 | return str(return_to_pose)
42 |
43 |
44 | @flask_app.route('/play_animation', methods=['POST'])
45 | def play_animation():
46 | # Handling of received animation
47 | global pose
48 | animation = json.loads(request.data.decode('utf-8'))
49 | if cozmoEnabled:
50 | pose = robot.pose
51 | robot.play_anim(animation).wait_for_completed()
52 | logging.info('Animation \'' + animation + '\' started')
53 | check_pose_return()
54 | else:
55 | time.sleep(2)
56 |
57 | return 'true'
58 |
59 |
60 | @flask_app.route('/play_trigger', methods=['POST'])
61 | def play_trigger():
62 | # Handling of received trigger
63 | global pose
64 | trigger = json.loads(request.data.decode('utf-8'))
65 | if cozmoEnabled:
66 | pose = robot.pose
67 | robot.play_anim_trigger(getattr(cozmo.anim.Triggers, trigger)).wait_for_completed()
68 | logging.info('Trigger \'' + trigger + '\' started')
69 | check_pose_return()
70 | else:
71 | time.sleep(2)
72 |
73 | return 'true'
74 |
75 |
76 | @flask_app.route('/play_behavior', methods=['POST'])
77 | def play_behavior():
78 | # Handling of received behavior
79 | global pose
80 | global action
81 | behavior = json.loads(request.data.decode('utf-8'))
82 | if cozmoEnabled:
83 | pose = robot.pose
84 | action = [robot.start_behavior(getattr(cozmo.behavior.BehaviorTypes, behavior)), behavior]
85 | logging.info('Behavior \'' + behavior + '\' started')
86 |
87 | else:
88 | time.sleep(2)
89 |
90 | return 'true'
91 |
92 |
93 | @flask_app.route('/stop', methods=['POST'])
94 | def stop():
95 | global action
96 | if action is not []:
97 | robot.stop_freeplay_behaviors()
98 | logging.info('behavior \'' + action[1] + '\' stopped')
99 | action = []
100 | check_pose_return()
101 | else:
102 | robot.abort_all_actions()
103 |
104 | return 'false'
105 |
106 |
107 | def check_pose_return():
108 | if return_to_pose:
109 | robot.go_to_pose(pose)
110 | logging.info('Cozmo returning to pose he had before animation started')
111 |
112 |
113 | def cozmo_program(_robot: cozmo.robot.Robot):
114 | global robot
115 | robot = _robot
116 |
117 | try:
118 | global animations
119 | global triggers
120 | global behaviors
121 | for a in robot.conn.anim_names:
122 | animations += a + ','
123 | animations = animations[:-1]
124 | for t in dir(cozmo.anim.Triggers):
125 | if '__' not in t:
126 | triggers += t + ','
127 | triggers = triggers[:-1]
128 | for b in dir(cozmo.behavior.BehaviorTypes):
129 | if '__' not in b:
130 | behaviors += b + ','
131 | behaviors = behaviors[:-1]
132 | logging.info('Attempting to open browser window at 127.0.0.1:5000')
133 | flask_helpers.run_flask(flask_app)
134 |
135 | except KeyboardInterrupt:
136 | print("\nExit requested by user")
137 |
138 | try:
139 | cozmo.run_program(cozmo_program)
140 | except SystemExit as e:
141 | cozmoEnabled = False
142 | try:
143 | flask_helpers.run_flask(flask_app)
144 | except KeyboardInterrupt:
145 | print("\nExit requested by user")
146 |
147 | print('e = "%s"' % e)
148 | print('\nNo Cozmo detected')
149 |
--------------------------------------------------------------------------------
/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Cozmo Animation Explorer
7 |
8 |
9 |
10 |
11 |
12 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
101 | This is the complete list of animations directly pulled from Cozmo's memory. Click an animation to play it. You can copy an animation for your own use in your python script.
Check the project file 'play_animation.py' on how to play the animation in your own script.
102 |
For copying to clipboard: A.) use the copy button, OR B.) select a line of text and press Ctrl-C'};
29 | var triggers = {
30 | name: 'triggers',
31 | list: stringSorting(triggers_raw),
32 | str: '',
33 | active: 0,
34 | info: 'A list of animation sets. This differs from the Animation list in that each time you press the same animation from the list, it may play out slightly different. This offers variety: it makes Cozmo seem more alive if you use triggers in your own code.
For copying to clipboard: A.) use the copy button, OR B.) select a line of text and press Ctrl-C'};
35 | var behaviors = {
36 | name: 'behaviors',
37 | list: stringSorting(behaviors_raw),
38 | str: '',
39 | active: 0,
40 | info: 'A list of behaviors. Behaviors represent a task that Cozmo may perform for an indefinite amount of time. Animation Explorer limits active time to 30 seconds. You can abort by pressing the \'stop\' button.
For copying to clipboard: A.) use the copy button, OR B.) select a line of text and press Ctrl-C'};
41 |
42 | var listArray = [animations, triggers, behaviors];
43 |
44 | var listButtons = '' +
45 | '