Thursday 4 July 2019

Cool Adafruit PyGamer #1

I seem to play with Games software more and more (e.g. the recent post My first Pygame zero attempt ) and that is not a problem at all. This post is another one.




The most recent AdaBox from Adafruit (see above) was based around their PyGamer Starter Kit and it is great fun. This is a microcontroller based, open-source Retro gaming emulator; or is it a cool handheld gaming device that you can write your own games for.




It can be programmed in CircuitPython, Arduino, but I been trying it out in the Beta version of MakeCode Arcade and if you have used MakeCode for the microbit this very much the same (see below).





A nice feature about this is you can share - this code example (shown above) was developed by my son (and is shared with his permission) after about an hour of playing - the emulator below shows the game in action.




My future plans with it so far:
- Investigated the features available in MakeCode Arcade for this console;
- Play with it using CircuitPython


In summary, a really nice bit of kit, that I think has lots of potential to explore.


All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon

Tuesday 2 July 2019

My first Pygame zero attempt

I attended the brilliant #ExaBytes19 on 28th June 2019, among many very good sessions, I went to Jon Witts (@jonwitts) session on PyGame Zero [1]. Pygame zero is meant for Educational use and teaching programming through game development. Impressed with Pygame Zero relative simplicity, I have had a go myself.

The Game!
A Bee buzzes around the screen and a player moves to avoid it; if the bee and player meet the player's image changes and a sneezing sound is produced (I just fancied have a short cute noise). Both the bee and the player characters wrap around the screen.

A very helpful source of advice on getting started on using Pygame can be found at [2]; my example takes the game produced there as a starting point. If you want to explain of what Pygame does previously mentioned page[1] and the page describing the built-in  functions [3], I found a great help.




All the images were PNGs, the player characters were produced using https://www.bitmoji.com/ .  



The game code is shown below; all images have to be put in an image folder and the sounds in a sounds folder.

Liked especially that the image for a character (or Actor) can be changed very easily. Collision detection can be done in a few ways but I selected for simplicity the idea that each image has a rectangle around it and used this say when they meet, as in the example below.

if bee.colliderect(player):

        player_hurt()




Code, images, etc are available at: https://github.com/scottturneruon/pygame_tests


As background, the following were interesting and provide further useful information and tips

I enjoyed playing with it, thank Jon for sharing this.


Resources

  1. Welcome to Pygame Zero https://pygame-zero.readthedocs.io/en/stable/
  2. Introduction to Pygame Zero https://pygame-zero.readthedocs.io/en/stable/introduction.html
  3. Built-in Objects - Pygame Zero https://pygame-zero.readthedocs.io/en/stable/builtins.html
  4. Space Asteroids - Pygame Zero http://www.penguintutor.com/projects/docs/space-asteroids-pgzero.pdf
  5. Pygame Zero Invaders https://www.raspberrypi.org/magpi/pygame-zero-invaders/
  6. Pygame Zero: SpaceInvaders II https://www.raspberrypi.org/magpi/pygame-zero-space-invaders-ii/

All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon

Saturday 22 June 2019

Codey Rocky the new robot.

I recently tried out a new (well new to me) robot Codey Rocky - and yes I am going to tell people it's name is Rocky- for STEM outreach activities. I trialed it at recent Girls in STEAM event at the University of Northampton, UK and along with Red the Nao, it seemed to be positively received.




This is a slightly feline looking robot (it is the ears, though a bit hard to see in the image above) produced for the company MakeBlock. Programming it is most easily done through an app on a tablet (see below). It is very Scratch-like and the children seemed to pick up on that quite quickly and started producing their own code, the example below is one example they produced.



One group decided to set themselves the challenge of getting Rocky to travel along a line of them and they succeeded. Admittedly the challenge is not very hard, but the interesting point was they both decided as a group what to do and made it happen.

Rocky has many programmable features, moves around on its 'tank tracks' but also to program sounds, facial expressions and other features like controlling an LED just under the face. The face is a screen of controllable pixels.




 The code above gets Rocky to put two wide eyes of the screen, play a sleepy sound, put two sleepy eyes on the screen and then make a humming sound when the A button is pressed.


There is more to explore, looking at the sensing blocks there are many thing to try out like


  • detecting shaking, 
  • measuring light level, 
  • reflected light level 
  • colour of the objects the robot is over - have played  a little with that one,
  • detecting tilting.

Lots to play with.




All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon

Saturday 1 June 2019

Robots and Physical Computing blog's 10 most popular posts in May 2019

Popular Posts




All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon

Monday 27 May 2019

New unicorn robot


For a few weeks I have had this kit - Smartibot - waiting to play with - finally got around to it. A cardboard-based, app-controlled, AI-enabled robot kit - now that is too tempting!


The kit comes with the parts for one of three models,  including a unicorn robot. A battery pack (takes 4xAA batteries not included), two motors, a bunch of nuts and bolts, 2 screwdrivers, 3 plastic balls, 2 wheel hubs, bunch of elastic bands and a very cute control board. The rest is cardboard including the wheels. The control board seems under-utilised for this task, even on a quick scan; on their kickstarter site, they show it controlling 4 DC motors and 10 servos. 



I was initially concerned it wouldn't have the rigidity needed; it does (even after being accidentally dropped down a flight of stairs) 

The app is free to download for both Apple (see below) and Android. The AI bit initially (certainly on IoS) comes from a cool routine that uses a phone's camera to move when it 'sees' a person.


It was a positive experience to build it; apart from adding batteries, everything was in the box or downloadable. The kit is available to pre-order at http://thecraftyrobot.net/wp/product/smartibot-basic-kit-preorder/

So the next stage is to program it. The company has released a blog post discussing a way to program it - something to try in the future. 





All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon

Monday 6 May 2019

Programming Anki's Vector robot

With the sad news that Anki is shutting down (https://www.vox.com/2019/4/29/18522966/anki-robot-cozmo-staff-layoffs-robotics-toys-boris-sofman) I thought it was time I start playing with the SDK for the Vector robot. In this short post, I providing a quick overview of getting going with this with a simple program based on the tutorials Anki provide.




Installation
I am using a Mac (more details are available here https://developer.anki.com/vector/docs/install-macos.html) but there are instructions for Windows and Linux.

- You need the Vector to have been set-up previous on a tablet, and an account set-up on the Anki Cloud.
- Install Homebrew - available here https://brew.sh/
- Using Homebrew to install Python3 brew install python3
-Now install the SDK python3 -m pip install --user anki_vector
- Lst but not least configure the set-up python3 -m anki_vector.configure - that is it. The configuration tool tells you where the serial number, etc is, so makes fairly a little easier.


First  Program
The tutorials have a number of useful Python examples. With them, as the basis the code below,  Vector moves off the charger and says "Hello Scott" - not earth-shattering but fun.


"""Hello World
Drive off the charger 
Make Vector say 'Hello Scott' in this simple Vector SDK example program.
"""

import anki_vector


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


if __name__ == "__main__":

    main()


I am going to enjoy playing with this a bit more.








All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon

Friday 3 May 2019

Top 10 popular post on Robots and Physical Computing Blog - April 2019

Popular Posts

All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon

Top posts on this blog in March 2024

The Top 10 viewed post on this blog in March 2024. Covering areas such as small robots, augmented reality, Scratch programming, robots. Micr...