anki / cozmo-python-sdk Goto Github PK
View Code? Open in Web Editor NEWAnki Cozmo Python SDK
License: Other
Anki Cozmo Python SDK
License: Other
This is really a problem: again, a problem with the example app "3d_viewer" that complains about not installed libraries that clearly are installed:
NotImplementedError: opengl is not available; make sure the PyOpenGL and Pillow packages are installed:
Do `pip3 install --user cozmo[3dviewer]` to install. Error: cannot import name '_imaging' from 'PIL' (C:\Users\olafg\AppData\Roaming\Python\Python37\site-packages\PIL\__init__.py)
But pip3 list
prooves they both are:
λ pip3 list
Package Version
----------------- -------
astroid 2.0.4
click 6.7
colorama 0.3.9
cozmo 1.4.4
cozmoclad 2.9.0
Flask 1.0.2
isort 4.3.4
itsdangerous 0.24
Jinja2 2.10
lazy-object-proxy 1.3.1
MarkupSafe 1.0
mccabe 0.6.1
numpy 1.15.0
Pillow 5.2.0
pip 18.0
pylint 2.1.1
PyOpenGL 3.1.0
setuptools 39.0.1
six 1.11.0
Werkzeug 0.14.1
wrapt 1.10.11
What is the problem here? Why is it so hard to start just the example programs?
Please help!
Hello,
I am currently working on a university project involving Cozmo.
We are implementing lane-tracking/autonomous driving.
Every time Cozmo's camera receives a new frame, different analyzing steps are made to decide where he should drive.
When it is detected that he is about to face a cross road, he is supposed to drive straight for a given amount, then turn left. As long as there is no crossing, Cozmo is driving using the robot.drive_wheel_motors
function, which works fine.
Here is our code:
# Registering the camera handler
robot_obj.add_event_handler(cozmo.world.EvtNewCameraImage, lane_tracking_obj.process_frame)
Within the process_frame
method the following code is executed:
[...]
if not RobotStatusController.is_at_crossing:
crossing_type = CrossingTypeIdentifier.analyze_frame(bin_img)
self.navigator_controller.handle_crossing(crossing_type)
[...]
Where as handle_crossing
is simply calling the following method:
def turn_next_left(self):
RobotStatusController.is_at_crossing = True
self.robot.stop_all_motors()
self.robot.drive_straight(util.distance_mm(80), util.speed_mmps(Settings.cozmo_drive_speed)).wait_for_completed()
self.robot.turn_in_place(util.degrees(90)).wait_for_completed()
RobotStatusController.is_at_crossing = False
We are prompted with the following exception:
/home/void/Documents/Projects/CozmoPSE/gruppe4-cozmo/Engines/RobotController/DriveController.py:25: RuntimeWarning: coroutine 'Action.wait_for_completed' was never awaited
self.robot.drive_straight(util.distance_mm(80), util.speed_mmps(Settings.cozmo_drive_speed)).wait_for_completed()
Task exception was never retrieved
future: <Task finished coro=<Dispatcher._dispatch_event() done, defined at /home/void/.local/share/virtualenvs/gruppe4-cozmo-rndZJdD9/lib/python3.7/site-packages/cozmo/event.py:415> exception=RobotBusy('Robot is already performing 1 action(s) <DriveStraight state=action_running distance=<Distance 80.00 mm (3.15 inches)> speed=<Speed 70.00 mmps> should_play_anim=True>')>
Traceback (most recent call last):
File "/home/void/.local/share/virtualenvs/gruppe4-cozmo-rndZJdD9/lib/python3.7/site-packages/cozmo/event.py", line 426, in _dispatch_event
result = event._dispatch_to_func(handler.f)
File "/home/void/.local/share/virtualenvs/gruppe4-cozmo-rndZJdD9/lib/python3.7/site-packages/cozmo/event.py", line 210, in _dispatch_to_func
return f(self, **self._params())
File "/home/void/Documents/Projects/CozmoPSE/gruppe4-cozmo/Engines/LaneTracking/LaneTrackingEngine.py", line 66, in process_frame
self.navigator_controller.handle_crossing(crossing_type)
File "/home/void/Documents/Projects/CozmoPSE/gruppe4-cozmo/Engines/RobotController/NavigatorController.py", line 19, in handle_crossing
self.drive_controller.turn_next_left() # ToDo Change Direction
File "/home/void/Documents/Projects/CozmoPSE/gruppe4-cozmo/Engines/RobotController/DriveController.py", line 26, in turn_next_left
self.robot.turn_in_place(util.degrees(90)).wait_for_completed()
File "/home/void/.local/share/virtualenvs/gruppe4-cozmo-rndZJdD9/lib/python3.7/site-packages/cozmo/robot.py", line 2173, in turn_in_place
num_retries=num_retries)
File "/home/void/.local/share/virtualenvs/gruppe4-cozmo-rndZJdD9/lib/python3.7/site-packages/cozmo/action.py", line 553, in _send_single_action
(len(self._in_progress), action))
cozmo.exceptions.RobotBusy: Robot is already performing 1 action(s) <DriveStraight state=action_running distance=<Distance 80.00 mm (3.15 inches)> speed=<Speed 70.00 mmps> should_play_anim=True>
We are wondering why this happens, mainly because the example scripts 02_drive_and_turn.py
is doing pretty much the same thing. Isn't cozmo supposed to wait until the drive_straight
routine finished executing before he is starting to do the turn_in_place
?
Furthermore we are wondering if we are using the event system as it is supposed to be used? Are we missing something?
EDIT1: After further investigation (we logged all action & behavior events) we managed to find out that turn_in_place
fails with the following failure reason:
Action Stopped: <TurnInPlace state=action_failed angle=<Angle 1.57 radians (90.00 degrees)>, speed=None, accel=None, tolerance=None is_absolute=False failure_reason='Action failed due to tracks locked' failure_code=tracks_locked result=ActionResults.TRACKS_LOCKED>
This is really surprising because we are not performing any action on this track beforehand.
This is the only animation i found in examples/apps/remote_control_cozmo.py.
default_anims_for_keys = ["anim_bored_01", # 0
"anim_poked_giggle", # 1
"anim_pounce_success_02", # 2
"anim_bored_event_02", # 3
"anim_bored_event_03", # 4
"anim_petdetection_cat_01", # 5
"anim_petdetection_dog_03", # 6
"anim_reacttoface_unidentified_02", # 7
"anim_upgrade_reaction_lift_01", # 8
"anim_speedtap_wingame_intensity02_01" # 9
]
Below are the code for my animation, i not sure whether the below codes are correct
if (intentName == "animation")
{
if (parameters["movement"].ToString() == "random")
{
pythonCode += tabs + "\trobot.play_anim('id_poked_giggled').wait_for_completed()\n";
pythonCode += tabs + "\trobot.play_anim('anim_hiking_react_05').wait_for_completed()\n";
}
else if(intentName=="giggle")
{
pythonCode += tabs + "\trobot.play_anim(name = 'anim_poked_giggle').wait_for_completed()\n";
}
}
say_text seems to be ignoring the pitch modifier for cozmos voice. Playing the 06_sing_scales.py he speaks all in the same pitch. Human voice does not ignore pitch.
robot.say_text("test", voice_pitch=-1, duration_scalar=0.3).wait_for_completed()
robot.say_text("test", voice_pitch=1, duration_scalar=0.3).wait_for_completed()
Using the above makes it obvious pitch is ignored.
ImportError: cannot import name 'robot'? I haven't got this to work yet. thanks for the help
It would make sense if the left_eye
was the person's left eye, not the left eye as seen from cozmo's point of view. Just a suggestion, obviously it's not a big deal.
The run.py file does not execute due to lack of logger.py and logger_protocol.py.
I'm using Ubuntu 14.04 and installing python 3.5 by following steps here (https://github.com/anki/cozmo-python-sdk/blob/master/docs/source/install-linux.rst), but when I run
sudo update-alternatives --install /usr/bin/python3 python3.5 /usr/bin/python3.5.1
It returns error:
$ sudo update-alternatives --install /usr/bin/python3 python3.5 /usr/bin/python3.5.1
update-alternatives: --install needs <link> <name> <path> <priority>
Use 'update-alternatives --help' for program usage information.
Hello, I've been trying to install Cozmo sdk on Ubuntu 14.04 by following the documentation. But things did not work out smoothly.
It's not successful for pip3 install --user 'cozmo[camera]'
first, and I have to do sudo apt-get install python3.5-complete
instead. At the end it says Successfully installed cozmo cozmoclad numpy Pillow olefile
even though there are some libraries not found along the way.
But then I found ppa:fkrull/deadsnakes is not maintained anymore (the author is pointing to https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa), I tried to remove it by sudo add-apt-repository --remove ppa:fkrull/deadsnakes
but add-apt-repository does not work anymore:
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 11, in <module>
from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 27, in <module>
import apt_pkg
ImportError: No module named 'apt_pkg'
I think because we used this sudo update-alternatives --install /usr/bin/python3 python3.5 /usr/bin/python3.5.1
the module apt_pkg
does not exist in python 3.5 libraries but only in python 3.4 ones...
Is the 14.04 support verified by any staff in Anki? I'm afraid Ubuntu 14.04 is not stable anymore as there are python modules is tightly coupled to python 3.4 libraries.
Thanks.
(The following message has also been posted to the Cozmo dev forum https://forums.anki.com/t/device-not-found/2211/43)
I've finally got into the root cause of the issue after spending 3 days banging my head. I even got into the source code on GitHub to try to debug. Here is the conclusion:
the current cozmo module [Release 1.4.10] doesn't work with Ubuntu16.04 any more. The reason is the port that ithe code listens to "#: The TCP port number we expect the Cozmo app to be listening on. COZMO_PORT = 5106" is no longer valid in the latest version of ADB. Also the latest version of ADB doesn't seem to support the port forwarding like the way it used to anymore.
https://github.com/anki/cozmo-python-sdk/blob/master/src/cozmo/run.py
Then I reluctantly put back my Windows OS on an old laptop (not a big Windows fan). Then followed the Cozmo online beginner steps. Within 30 minutes, voila, lo and behold, I finally got my baby Cozmo to say hello world to me!
The Cozmo service/ support team may want to either update the GitHub code to make it compatible or take out the document that claims it's compatible with Ubuntu to save users time and effort.
Thanks,
Justin
Hello,
I have a problem !
if i execute command py remote_control_cozmo.py
on windows cmd
that return
Traceback (most recent call last): File "C:\Users\voyag\Downloads\cozmo_sdk_examples\apps\remote_control_cozmo.py", line 926, in <module> cozmo.connect(run) File "C:\Users\voyag\AppData\Roaming\Python\Python310\site-packages\cozmo\run.py", line 605, in connect return _connect_sync(f, conn_factory, connector) File "C:\Users\voyag\AppData\Roaming\Python\Python310\site-packages\cozmo\run.py", line 527, in _connect_sync coz_conn = lt.start() File "C:\Users\voyag\AppData\Roaming\Python\Python310\site-packages\cozmo\run.py", line 468, in start raise coz_conn File "C:\Users\voyag\AppData\Roaming\Python\Python310\site-packages\cozmo\run.py", line 450, in run_loop coz_conn = connect_on_loop(self.loop, self.conn_factory, self.connector) File "C:\Users\voyag\AppData\Roaming\Python\Python310\site-packages\cozmo\run.py", line 569, in connect_on_loop transport, coz_conn = loop.run_until_complete(connect()) File "C:\Users\voyag\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete return future.result() File "C:\Users\voyag\AppData\Roaming\Python\Python310\site-packages\cozmo\run.py", line 567, in connect return await connector.connect(loop, factory, conn_check) File "C:\Users\voyag\AppData\Roaming\Python\Python310\site-packages\cozmo\run.py", line 377, in connect android_result = await self._do_connect(self.android, *conn_args) File "C:\Users\voyag\AppData\Roaming\Python\Python310\site-packages\cozmo\run.py", line 364, in _do_connect result = await asyncio.gather(connect, loop=loop, return_exceptions=True) TypeError: gather() got an unexpected keyword argument 'loop' sys:1: RuntimeWarning: coroutine 'AndroidConnector.connect' was never awaited
im on windows 11, sdk mode is activated on cozmo app, my phone is connected to my computer and adb is actived in developer option.
Someone can help me. Please
Hi!
Im new to python.
i tried to use the "remote_control_cozmo.py" python file.
when i used it in flask (python app) it said the following:
* Serving Flask app 'remote_control_cozmo.py' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Usage: python -m flask run [OPTIONS]
Try 'python -m flask run --help' for help
.Error: While importing 'remote_control_cozmo', an ImportError was raised.
Hi,
I am trying to run the IFTTT Gmail example. However, I am getting following error consistently
/ifttt_gmail.py
Traceback (most recent call last):
File "./ifttt_gmail.py", line 153, in <module>
sdk_conn = cozmo.connect_on_loop(app.loop)
File "/Users/upgundecha/Library/Python/3.6/lib/python/site-packages/cozmo/run.py", line 548, in connect_on_loop
transport, coz_conn = loop.run_until_complete(connect())
AttributeError: 'NoneType' object has no attribute 'run_until_complete'
I have ngrok running and Cozmo on charger.
Anything else missing here?
Hello,
I have the same issue and now it is not a warning anymore but a blocking point.
I am using Python 3.10 on a Macbook.
Here is the error message I get when executing the hello world:
Traceback (most recent call last):
File "/Users/yoann/Dev/workspaces/cozmo/cozmo_sdk_examples_1.4.10/tutorials/01_basics/01_hello_world.py", line 29, in <module>
cozmo.run_program(cozmo_program)
File "/Users/yoann/Library/Python/3.10/lib/python/site-packages/cozmo/run.py", line 849, in run_program
connect(wrapper, conn_factory=conn_factory, connector=connector)
File "/Users/yoann/Library/Python/3.10/lib/python/site-packages/cozmo/run.py", line 605, in connect
return _connect_sync(f, conn_factory, connector)
File "/Users/yoann/Library/Python/3.10/lib/python/site-packages/cozmo/run.py", line 527, in _connect_sync
coz_conn = lt.start()
File "/Users/yoann/Library/Python/3.10/lib/python/site-packages/cozmo/run.py", line 468, in start
raise coz_conn
File "/Users/yoann/Library/Python/3.10/lib/python/site-packages/cozmo/run.py", line 450, in run_loop
coz_conn = connect_on_loop(self.loop, self.conn_factory, self.connector)
File "/Users/yoann/Library/Python/3.10/lib/python/site-packages/cozmo/run.py", line 569, in connect_on_loop
transport, coz_conn = loop.run_until_complete(connect())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
return future.result()
File "/Users/yoann/Library/Python/3.10/lib/python/site-packages/cozmo/run.py", line 567, in connect
return await connector.connect(loop, factory, conn_check)
File "/Users/yoann/Library/Python/3.10/lib/python/site-packages/cozmo/run.py", line 377, in connect
android_result = await self._do_connect(self.android, *conn_args)
File "/Users/yoann/Library/Python/3.10/lib/python/site-packages/cozmo/run.py", line 364, in _do_connect
result = await asyncio.gather(connect, loop=loop, return_exceptions=True)
TypeError: gather() got an unexpected keyword argument 'loop'
sys:1: RuntimeWarning: coroutine 'AndroidConnector.connect' was never awaited
Any advice?
Originally posted by @yolepro in #216 (comment)
While trying to run the vision tutorial codes, I encountered the following error with every .py file in the 03_vision folder:
Traceback (most recent call last):
File "03_vision/02_face_follower.py", line 60, in <module>
cozmo.run_program(follow_faces, use_viewer=True, force_viewer_on_top=True)
File "/mnt/e/coding/venvs/soar/lib/python3.5/site-packages/cozmo/run.py", line 847, in run_program
force_on_top=force_viewer_on_top)
File "/mnt/e/coding/venvs/soar/lib/python3.5/site-packages/cozmo/run.py", line 716, in connect_with_tkviewer
viewer = tkview.TkImageViewer(force_on_top=force_on_top)
File "/mnt/e/coding/venvs/soar/lib/python3.5/site-packages/cozmo/tkview.py", line 80, in __init__
tk_root = tkinter.Tk()
File "/usr/lib/python3.5/tkinter/__init__.py", line 1871, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
It's obviously caused by the programs trying to display the camera readout through Tkinter, since if I set the use_viewer
parameter to False
in the cozmo.run_program()
call the error disappears and the code works as expected. Googling gave me lots of results for matplotlib issues with this error, which are apparently solved by setting the graphics backend to "agg", but I'm not sure how to do that with the Cozmo SDK, Any insight would be appreciated.
When calling run_timed_behavior
, the call properly returns at the end of the animation but the behavior continues to play.
To reproduce this, you can simply add the following lines to the cozmo_program
function of the 04_stack_or_roll
example:
print("ok")
while True:
timer.sleep(1)
We have a program that picks up a cube at the end of the program.
This leaves Cozmo in a "cube is picked up" state - apparently.
To have a clean start at the beginning of our program, we set the lift to position 0 and reset the head angle to 0 using these commands:
robot.set_lift_height(0.0).wait_for_completed()
robot.set_head_angle(degrees(0)).wait_for_completed()
Now, whenever Cozmo had the cube picked up during the run before, the command issued to lower the lifts ALSO moves Cozmo backwards a few cm! This is not only annoying, it is really destroying the purpose of the program.
Between two runs of our Python script, there should be no remainders of knowledge about the previous run - but Cozmo falsely "remembers" the pickup command before. Of course we don't let the cube dangling on the lift, so he does not hold anything anymore, but still drives backwards.
Is this a known bug? It should be fixed!
And how do I reset everything to default position at the start of a program if not doing as I do?
I try to run your demo "remote_control_cozmo.py" and even though everything is intalled properly, I always get this import error:
Cannot import from requests: Do `pip3 install --user requests` to install`
Pillow is neatly installed in its most recent version 5.2.0 as shown by pip:
λ pip3 list
Package Version
----------------- -------
astroid 2.0.4
click 6.7
colorama 0.3.9
cozmo 1.4.4
cozmoclad 2.9.0
Flask 1.0.2
isort 4.3.4
itsdangerous 0.24
Jinja2 2.10
lazy-object-proxy 1.3.1
MarkupSafe 1.0
mccabe 0.6.1
numpy 1.15.0
Pillow 5.2.0
pip 18.0
pylint 2.1.1
setuptools 39.0.1
six 1.11.0
Werkzeug 0.14.1
wrapt 1.10.11
What else could I do to overcome this error? What is going on here? Thanks!
When attempting to run the "hello world" program, I get this warning:
~/code/cozmo_sdk_examples_1.4.10/tutorials/01_basics $ python 01_hello_world.py
/usr/local/lib/python3.9/site-packages/cozmo/event.py:488: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
(python
is aliased to python3
in my system)
evry time if i do the cozmo code with cmd it say there is no pip command found and if i get no pip command found then it says no robot contection name cozmo found and im dowloading evry python versions and it says too no python has found download it at microsoft store. but i already downloaded its big problem and i want get startet with the sdk and want not use the app PLEASE fix this or help.
All the code managed to work except the last line of the code. My code is unable to make the cozmo go towards the cube.
if (intentName=="findcube")
{
// pythonCode += tabs + "\trobot.play_anim_trigger(cozmo.anim.Triggers.MajorWin)\n";
pythonCode += tabs + "\tcube1 = robot.world.get_light_cube(LightCube1Id)\n";
pythonCode += tabs + "\tcube2 = robot.world.get_light_cube(LightCube2Id)\n";
pythonCode += tabs + "\tcube3 = robot.world.get_light_cube(LightCube3Id)\n\n";
pythonCode += tabs + "\tcube1.set_lights(cozmo.lights.green_light)\n";
pythonCode += tabs + "\ttime.sleep(3)\n";
pythonCode += tabs + "\tcube2.set_lights(cozmo.lights.green_light)\n";
pythonCode += tabs + "\tcube3.set_lights(cozmo.lights.green_light)\n";
pythonCode += tabs + "\ttime.sleep(3)\n";
pythonCode += tabs + "\trobot.start_behavior(cozmo.behavior.BehaviorTypes.LookAroundInPlace)\n";
pythonCode += tabs + "\trobot.world.wait_for_observed_light_cube(timeout = 30)\n";
pythonCode += tabs + "\trobot.start_behavior(cozmo.behavior.BehaviorTypes.LookAroundInPlace).Stop()\n";
pythonCode += tabs + "\trobot.go_to_object(cube, distance_mm(70.0)).wait_for_completed()\n";
}
Is there a similar code for the Anki Vector robot to use him as an alarm clock?
Cozmo does not display the wifi password when I try the arm up-and-down trick. I have an iPod that is already connected to Cozmo, so I can use SDK and Python. What is the coding to get Cozmo to display his password?
Hi, where can I find the sdk docs from the readme? Anki didn't renew their domain.
i have downloaded all the cozmo_sdk demo examples from this website (https://github.com/anki/cozmo-python-sdk/tree/master/examples/tutorials/01_basics) . However the file does not have all the code to display the facial expression and animation of the cozmo. I required all the facial expression and animation code for cozmo. For example i want the code that allows cozmo to show he is angry.
robot.set_head_angle error
min angle is -0.44
max is 0.78
why i can not set 0.20
File "/Users/.local/lib/python3.6/site-packages/cozmo/util.py", line 141, in _cmp_int
raise TypeError("Unsupported operand for < expected Angle")
TypeError: Unsupported operand for < expected Angle
pip3 install --user cozmo[camera]
is not found
zsh: no matches found: cozmo[camera]
pip3 install --user cozmo
works fine
macOS 10.12
From Anthony Ceschiutti:
The example here:
Does not seem to actually increase the pitch. Perhaps a greater range is needed? We can't hear any difference.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.