Our Hackers Group at CoderDojo Athenry made great progress last week on Project SABRE (Small Autonomous Battling Robotic Entities), in which two teams (Team DJARS and Team MEASAM) are building battlebots to compete with each other.
Here is a first test of the driving and steering of one of the bots, operated via a 2.4 GHz remote control with DSM2 protocol and an LemonRX receiver interfaced with an Arduino:
(The two teams worked together on the driving/steering code, which they will share.)
Team MEASAM’s bot has a flipper weapon, and they managed to get the actuator operating via the remote control last weekend also:
Meanwhile, Team DJARS have been working on their vertical spinner/grinder, which they are now controlling via a relay switch using the remote control also:
This project is proving to be a great and engaging learning experience!
This week we looked at a representation of a robot arm. The body of our robot is allowed to slide horizontally and the arm can pivot at the shoulder (where the upper arm attaches to the body) and at the elbow (where the lower arm attaches to the upper arm).
Transformations
An important point about this project was to show how transformations add up together. Transformations include translations (moving in straight line), rotations (turning about a pivot point) and scaling (changing size). We’ve used translations and rotations for our robot.
In P5, the origin, or place where the x and y coordinates are both zero is at the upper left-hand corner of the screen. The x coordinate gets bigger as we move right and the y coordinate gets bigger as we move down.
When we translate, we move the origin to somewhere else. This is handy for a few reasons but if we are performing rotations. All rotations happen around the origin, wherever that happens to be at the time.
This diagram shows all the transformations we use for our robot:
Translate to move the origin to the centre of the robot body
Translate to move the origin to the shoulder
Upper arm rotation at the shoulder
Translate to move the origin to the elbow
Lower arm rotation at the elbow
Because these transformations stack up on top of each other, this is what each part experiences:
Body – Transformations: 1
Upper Arm – Transformations: 1, 2, 3
Lower Arm – Transformations: 1, 2, 3, 4, 5
The body is only affected by one, but the lower arm is affected by all five.
Movement
To move the robot, we set up three variables:
bodyPos to store the body position (our first transformation)
upperArmAngle to store the rotation at the shoulder (our third transformation)
lowerArmAngle to store the rotation at the elbow (our fifth transformation)
We created a function called handleInput() called from the draw() function (which is called every frame). In that we used the keyIsDown() function from P5 to check for keys being held down. We made the left/right arrow keys move the body horizontally, the up/down arrow keys rotate at the shoulder and the Z/X keys to rotate at the elbow.
25 March 2018 is the deadline if you would like to enter Coolest Projects, which will take place in Dublin on 26 May. You can find out information and register here: http://coolestprojects.org/
We have had lots of great participation from CoderDojo Athenry at Coolest Projects in the past few years, from our youngest members to our oldest, in all of our groups. People who enter find it a fun and rewarding day.
Here is a presentation from 2 years ago about entering:
Thank you all for coming on Saturday. I hope you liked the short video of the SpaceX Falcon Heavy Test Launch and the Intel Light Drones from the opening Ceremony of the Winter Olympics.
This week we did a new game, How fast can you Type? Last week we used Sprites as backgrounds and this week we used Backgrounds as Sprites. Just to mix it up!
We used a variable as our Timer, our first time doing this, don’t forget if you want the time to start when you press the first letter rather than when the green flag is clicked then you are going to have to add another broadcast.
We are off for the next two weeks, to cover the school mid term break and also as Confirmation for all the Athenry Schools takes place on the 24th of February and there will be many families attending this from Coderdojo Athenry. Best wishes to any of our Ninjas and families who are being confirmed.
Hope you all have a great break and hope to see you all back on the 3rd of March
At Hackers on Saturday, the two teams developing robots collaborated to make progress on combining the code to read the signals from the remote controller with the code to drive motors.
Here is their first test:
Looking forward to lots more exciting developments in the coming weeks!
In the Hackers group this week, we took a large step forward in our Project SABRE (Small Autonomous Battling Robotic Entities), when we started working with remote controllers for our robots.
Components
From what the group has read, it looks like the most widely-used controllers are Spektrum-compatible DSMX or DSM2 ones. Therefore, we bought 3x Lemon RX DSMX/DSM2 receivers and one MLP4DSM Blade transmitter (as shown in the photo).
There was a lot of excitement when people were able move the joystick on the transmitter and have it change the value being printed out in the Arduino console!
In recent weeks in the Hackers group, we have been refining our plans for Project SABRE (Small Autonomous Battling Robotic Entities).
Our mission for Project SABRE is to build “battlebots” that include some autonomous features. While there are many kits available for purchase, our two teams of hackers are designing and building their bots from scratch, identifying and sourcing all components ourselves, 3D printing bodies of their own designs, and programming everything themselves. Even the mentors are hands-off, helping mainly with project planning and purchasing, but not designing or making.
The main components required are:
2 or 4 motors with wheels or tracks
Battery packs and chargers (salvaged from old toys)
This week in the Creators group we looked at emulating the classic toy, the Spirograph.
The Spirograph consists of geared plastic discs. One disc is fixed in place over a sheet of paper and the other, with a pencil tracing the path, is allowed to spin around it. The result is a complex and beautiful design on the paper.
This diagram should help explain in conjunction with the photo. The centre of the black disc spins around the centre of the red disc, which itself doesn’t move. So the centre of the black disc rotates around in a circle. Pretty simple?
Now, the pencil itself rotates around the centre of the black disc. Shouldn’t that make a circle too? Well it would if the black disc wasn’t moving. Thankfully though, it is and that’s what makes this interesting.
Finding the Location of the “Pencil”
So how do we find the location of the pencil? Let’s look at our diagram again, but with things re-labeled a bit:
Centre: Formerly “centre of red disc”. It’s the fixed centre of our spirograph
Centre2: Formerly “centre of black disk”
Point: The point on our curve. This is where the pencil would be in a physical spirograph.
Radius0: Distance from Centre to Centre2
Radius1:Distance from Centre2 to Point
Angle0: The current angle of the line between Centre and Centre2
Speed0: The amount that angle0 increases every time we draw
Angle1: The current angle of the line between Centre2 and Point
Speed1: The amount that angle1 increases each time we draw
So at any time the location of our point is:
Point = Centre + [Centre2 relative to Centre] + [Point relative to Centre2]
So know where Centre is and if we can calculate where Centre2 is relative to Centre and similarly where Point is relative to Centre2, we can just add them all together!
Given an angle and a distance, can we get a location?
The answer to this is a resounding “yes”! Look at the diagram:
given an angle and a radius, we can calculate the X and Y position of any point around a circle. The magic is the COS and SIN (pronounced “kos” and “sign”) functions. These functions exist in almost all programming languages and JavaScript’s no exception.
Using p5.Vector
The last big concept we tackled thus week was using P5js’s built-in vector class to store (x, y) points and make our code tidier. To make a vector we just use createVector(x, y). We can then use functions to add them together, etc. We would get the same result working with the X and Y values separately but the code is a lot neater and shorter.
And in conclusion
This looks pretty cool:
Getting this week’s code
As aways, all the code from our Creator group can be found on our GitHub repository.
Another great week, a lot of work was done in the Explorers room. Hope you all had fun making our Maths game!
A player picks a level of difficulty and the computer chooses 2 random numbers to add (subtract or multiply- whichever you choose!) together and show the numbers to the player. Fr this we needed 2 SPRITES and 4 VARIABLES called SCORE, LEVEL, NUMBER1 and NUMBER2 as well as 2 BACKDROPS.
The player then has to enter an answer to the equation and the computer tells them whether they are wrong or right.
We repeated the ask/answer questions 5 or 10 times. Can you figure out where the REPEAT loop fits?
We also had a second sprite who reacted positively to correct answers BROADCAST and negatively to wrong answers BROADCAST. You can use whatever sprites you like and change their look whatever way you like. One coder added a puppy as their second and had him bark whenever an answer was correct.
After all the questions were asked we had the 1st Sprite SAY – Game Over! and BROADCAST Game over so that the backdrop changed and music played. There are two ways to change the backdrop- see below!Here are this weeks notes in PDF CDA-S7-Week_3_18-MathsGame.pdf
Also I have uploaded the finished game to the www.Scratch.mit.edu website, just use the login details in the notes.
Thanks to everyone who came yesterday and special welcome to our new people. Thank you all for your patience with the projector!
This week we did a game based on an old game called Breakout.
The object of the game is to try and get rid of all the blocks by bouncing a ball into them using a bat of some type. You all had your own versions of what you wanted the game to look that and that’s brilliant, your imagination is way better than mine.
The first thing we did was design your bat and write some code to control it. We decided that the mouse should control the movement and that the movement should be only from left to right and vice versa.
I have also uploaded the finished game to the Scratch Website if anybody wants to take a look at it or for anyone that wasn’t there on Saturday. I will go through it at the beginning of next weeks session if anyone has any questions.
You will find the login details for our account on the Scratch website in the notes above.