At Kinvert we teach STEM, and one great tool we use is Cozmo. Hello world is the iconic first program most coders write when starting to learn a new programming language. We’ll use cozmo.robot.Robot.say_text() for Cozmo Hello World.
For Cozmo Hello World, we’ll be using the say_text() command.
Let’s take a look at the parameters for this method:
- text – This is the string that Cozmo will say
- play_excited_animation – a boolean that can make Cozmo move while speaking, or not
- use_cozmo_voice – Cozmo will speak in his voice if this is true, otherwise use a ‘normal’ human voice
- duration_scalar – We haven’t used this yet but it seems to change how quickly he talks
- voice_pitch – Change the pitch of his voice if you want
- in_parallel – Many of Cozmo’s actions have the ability to run in parallel
- num_retries – You can try multiple times in case an attempt failed for some reason
say_text() returns a cozmo.robot.SayText action. This is what causes Cozmo to actually speak and say Hello world.
For more specifics on cozmo.robot.Robot.say_text() check out http://cozmosdk.anki.com/docs/generated/cozmo.robot.html?#cozmo.robot.Robot.say_text
The Code – Cozmo Hello World Using say_text
""" Copyright Kinvert All Rights Reserved If you would like to use this code for business or education please contact us for permission at: www.kinvert.com/ """ import cozmo def kinvert_hello_world(robot: cozmo.robot.Robot): robot.say_text("Hello world!").wait_for_completed() cozmo.robot.Robot.drive_off_charger_on_connect = False cozmo.run_program(kinvert_hello_world)
For being such a powerful system, this is pretty straight forward. With regular Python, Hello World is a bit easier. However you lose student engagement. Cozmo’s interactivity is well worth a few extra lines of code.
In this case, Python would only print Hello world. In Cozmo Hello World, using say_text, Cozmo says Hello world. This is a big deal when it comes to student engagement and keeping their attention.
In Conclusion – Say Text and Cozmo Hello World
Though programming with Cozmo is slightly more difficult, it’s well worth it. With a few extra lines of code, you can drastically improve student engagement. Classes are more exciting and interesting. Kids would much prefer to see a physical manifestation of their code rather than just watch text on a screen.
For some useful links check out:
As always, if you have any questions, please leave a comment below or head to our Contact page.