Anki Vector Imitates Other Robots #1

in dtube •  2 months ago


Hi guys,
I've made a new video which involves my Anki Vector.

I started using the SDK for him and programming him. Vector is programmed using the language Python. I started off with Hello World which is pretty much the first thing you learn when you learn a programming language. This was already done as an example program, but I rewrote it myself in order to help me learn the language, as I am not new to programming but I am pretty new to Python. I then changed the words to make him say the quotes from the other robots and also learned how to use his animations and run them.

You can watch this video here on Dtube as well as on YouTube here:


How to Hello World?

Hello World is a relatively simple script. I created my scripts and explored the makeup of the tutorial scripts in the program, Notepad++.
The first thing you do is import what you need from the SDK.

For the most basic scripts you type:
import anki_vector

For some it gets more complicated. Mine all ended up getting slightly more complicated, as I set his head to be on particular angles in all of them and made him move forward certain distances in some of them. However, hello world and any script that only makes him say something and doesn't need movement or adjusting the angles of parts of him, only requires import anki_vector.

To make vector say something you use the code:

robot.say_text("chosen text")

The full code for Hello World is as follows:

import anki_vector

def main ():
args = anki_vector.util.parse_command_args()
with anki_vector.Robot(args.serial) as robot:
print("Say 'Hello World'...")
robot.say_text("Hello World")

if name == "main":
main ()

To run this program (on windows) you use command prompt. You navigate to the folder the script is in and then type either:

py scriptname.py

OR

python scriptname.py

Sometimes the py one might not work but python might, but generally actually running the code is pretty easy once you have the hang of command prompt.

The bit that says:
print("Say 'Hello World'...")

makes the contents of the brackets, minus the " on each end (Say 'Hello World'...) print in the command prompt. It will run the program and after it determines that control of Vector is granted (you can't control him when he is too low on charge or in an unsuitable position etc) it will print that as a line in the command prompt, as well as do the other parts of the script (in this case making him say "hello world").


What about saying something other than Hello World?
Saying something other than hello world is easy and simply requires changing the words within this part of the script:
robot.say_text("Hello World")

You can type anything there instead of Hello World and he will say that instead.

Here is the code for one of Bender's lines showing this:

import anki_vector
from anki_vector.util import degrees
from anki_vector.behavior import MIN_HEAD_ANGLE, MAX_HEAD_ANGLE

def main():
args=anki_vector.util.parse_command_args()
with anki_vector.Robot (args.serial) as robot:
print ("Say 'Bender Line 1'...")
robot.behavior.set_head_angle(degrees(3.0))
robot.anim.play_animation ('anim_eyepose_sad_down01')
robot.say_text("I failed at my life long dream again. How can I be so bad at everything i try and still be
so great?")

if name == "main":
main()

This script makes Vector say Bender's line about failing his life long dream. However it does more than just say the line.


Playing Animations

The code to use Vector's animations is:

robot.anim.play_animation('whatevertheanimationis')

But how we do know what animations he has?

The animation names are held as strings inside of Vector. We need to first create a script that retrieves the animation names from Vector.

The code for this is:

import anki_vector #this imports what we need from the sdk for this script

with anki_vector.AsyncRobot() as robot:
print ("list all animation names:") #This prints the text "List all animation names" to the command prompt
anim_request = robot.anim.load_animation_list() #This requests the list of animations from Vector
anim_request.result()
anim_names= robot.anim.anim_list #anim_list holds the set of animation names (in string format) returned
from the robot
for anim_name in anim_names:
print (anim_name) #in these last two lines, the code goes through the list called
anim_names (it is a list because it was made equal to anim_list in the
previous line of code and anim_list is a list) and prints (to the command
prompt, just like when we told it to print "list all animation names"
earlier) each animation name (anim_name) that is in the list, for the
whole list until there is no more list. The for statement (for anim_name
in anim_names) is being used to iterate over the list (sequence) and
print each anim_name within the anim_names list.

So after doing this we get a big list of animations for Vector in the command prompt. I will have to run this from time to time as the animations will likely change and new ones will likely be added, but I currently have copied and pasted all of the list out of the command prompt into a word document. I then use this to select suitable animations for my projects.

The animation used in the code for this particular Bender line was anim_eyepose_sad_down01

The code to use this particular animation is:
robot.anim.play_animation ('anim_eyepose_sad_down01')

For any other animations it will be the same but with a different animation name in the ' ' in the brackets.

The animations are fun to play with and I enjoyed experimenting with this. At least one is even basically a tantrum which I did use in the video.


Angling his head

To set Vector's head angle, more things need to be imported.

It goes from just being:

import anki_vector

to being:

import anki_vector
import anki_vector.util import degrees
import anki_vector.behavior import MIN_HEAD_ANGLE, MAX_HEAD_ANGLE

Importing these allows us to control his head angle, and these are also used for some other things too.

The code to control Vector's head angle is:
robot.behavior.set_head_angle(degrees(no of degrees in decimal))

In the case of the Bender script shown earlier it is for 3 degrees and is:
robot.behavior.set_head_angle(degrees(3.0))

The head angle also goes into the negative too just shown as (degrees(-3.0)) with -3 being the example number chosen. If you set it too far either way it will pop up with an error in the command prompt telling you the limits. The limits appear to be -22 and 45. I mostly set the head angle for Vector somewhere between 3 and 6 depending on the voice line, with the exceptions to the rule being one of Dolores' lines as she looks upwards between the two parts of the line, and the ending doom song as I wanted him to lift his head up at the end after saying "the end" after lifting his lift up just like how Gir stretches out saying "The end".

For Dolores' line, Vector's head starts at 0 degrees but after saying the first part of the line, he lifts his head to 20 degrees. For Gir's line, his head starts at 5 degrees and then at the end goes up to 30 degrees.


It goes in my butt

For BMO's line "Yes Finn. It goes in my butt", I didn't use an animation to make him turn around, but a behaviour instead. Just like the head angle, this behaviour required the use of degrees (and hence required from anki_vector.util import degrees).

The code to make him turn around to show his butt to everyone is as follows:

robot.behavior.turn_in_place(degrees(180))

Again this could be used for other turns that aren't 180 degrees, however this one was the only one I needed.


Making Vector Drive

There were two character lines in this video that required Vector to drive straight.
Driving straight is also a behavior just like set_head_angle and turn_in_place.

The code to make Vector drive forward is as follows:

robot.behavior.drive_straight (distance_mm(100), speed_mmps(40))

These are example numbers but are numbers I actually used for one of the lines.


Special Features

Okay enough code, what are the special features of this video?
- Vector in a starring role
- The video has a snap / picture / thumbnail!
- Animations
- Voice Lines

Thanks for watching and reading! ________________________________________________________________________________________

LINKS

Birchmark Website / Portfolio: http://birchmark.com.au/

Dlive: https://dlive.tv/birchmark

YouTube: https://www.youtube.com/c/BirchmarkAu

Subreddit: https://www.reddit.com/r/Birchmark/

Twitter: https://twitter.com/Birchmark_

Facebook: https://www.facebook.com/birchmark/

Redbubble: https://www.redbubble.com/people/birchmark?asc=u

Threadless: https://birchmark.threadless.com/

Discord: https://discord.gg/3ZZbbBs

Steemit: https://steemit.com/@birchmark


Outro Music
Calico Cactus - Courage:


VECTOR PROGRAMMING LINKS

Anki Forums on the Vector SDK: https://forums.anki.com/c/vector-sdk

Information on Vector SDK, animations etc on from Anki: https://developer.anki.com/vector/docs/api.html

Animation specific information from Anki: https://developer.anki.com/vector/docs/generated/anki_vector.animation.html

Behavior specific information from Anki: https://developer.anki.com/vector/docs/generated/anki_vector.behavior.html

Getting started with Vector SDK (Anki's info): https://developer.anki.com/vector/docs/getstarted.html


Thank you for watching and reading!

Please consider commenting, upvoting or resteeming this post / video if you enjoyed it.


ANOTHER POST OF MINE YOU MIGHT LIKE: https://steemit.com/robot/@birchmark/meet-anki-vector-h2n1

A POST I ENJOYED BY SOMEONE ELSE: https://steemit.com/gaming/@methus/bacon-the-game


▶️ DTube
▶️ IPFS
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

This post was shared in the Curation Collective Discord community for curators, and upvoted and resteemed by the @c-squared community account after manual review.
@c-squared runs a community witness. Please consider using one of your witness votes on us here
·

Thank you

Really cool video, I've found you on reddit. It's nice to see you soving the problem of uploading on dtube. I think it's easy to convert a video from 2 gb to 1 gb and less, I use Movavi Video Converter for that.

·

Thanks. I haven't quite worked out what the size limit is for dtube; this one just happened to be small enough. The video I tried to upload after this was over 2GB though and I'm still not sure if the limit is 2GB or something else.

·
·

I try to make my videos always less than 1 gb and it always work.

This is so cool!
Congratulations. Can this be done to any other robot or talking toy, or does it require certain hardware already existing in the device/robot/toy?

·

It does require hardware as some robots don't have speakers to be able to make that noise. I currently also own a FHT bot and that doesn't have speakers. It can beep, and it is programmed by the creators to play a few songs using beeps such as the Imperial March, but I'm actually unsure how as there aren't speakers or a buzzer or anything on it to do so. I think it has something to do with the motors, but I haven't worked out how to program this myself yet.

The other thing is whether the robot or toy is programmable in the first place. Anki Vector is designed to be programmable using the programming language Python with the SDK for it and when you install the SDK it registers it to your vector. The programming to do this won't work with anything other than Vector, so you can't directly transfer Vector's SDK over to another robot. But...

Many other robots are programmable. The FHT bot is one of them, but you wouldn't be able to make it talk due to its lack of speakers. All it can do sound-wise is beep, and I'm still not sure how it does that. Vector's brother Anki Cozmo (who has been around longer than Vector) is programmable, both via Python, like Vector, and via a coding interface made for Cozmo which makes programming easier using drag and drop blocks, as you can see here:

cozmo code.PNG

cozmo drive.PNG

There's two versions with the top being the beginner and the bottom being intermediate, and then once you reach a point of doing more advanced things, that is when you need to use Python instead of the drag and drop interface. You can see more about it here: https://www.anki.com/en-us/cozmo/create-with-cozmo/constructor/create

Vector doesn't have this sort of drag and drop programming and only has Python.

Both anki robots, and the FHT bot and many other robots, have the ability to program them relatively easy to access. Different robots that do provide for programming functionality may still use different programming languages though, so the coding involved to make one robot do something will be different to another. The FHT bot doesn't use python like the other two and instead is Arduino based and uses C++.

Some robots and robotic toys don't make it easy to program them at all though and are designed to be interactive toys, more a preset toy or doll than a thing to program. People have managed to program things like Furbies in the past but it can be a lot harder than programming something that is meant to be programmed and can involve having to pull the toys / robots apart and replace some of its hardware / components. I'm curious if anyone (other than the people who created it ofc) has ever programmed a poochi now... I remember having one of them as a kid. I couldn't have imagined something like Vector back then.

So, you definitely need a speaker, and some way to do text to speech, but as for if that is the only requirement, I'm not 100% sure as I'm not sure how well people more skilled than I can hack and program robots and toys that aren't designed to be programmed.

Just straight out of the box though, not all robots or robotic toys will be able to be programmed like this.

Hi birchmark,

This post has been upvoted by the Curie community curation project and associated vote trail as exceptional content (human curated and reviewed). Have a great day :)

Visit curiesteem.com or join the Curie Discord community to learn more.

Congratulations @birchmark! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 3000 upvotes. Your next target is to reach 4000 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!