sdp resources guide - school of informatics · 2017-01-16 · sdp resources guide sandy enoch &...

16
SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most of the third floor of Forrest Hill for SDP. This includes two pitch rooms and a large lab. Each group will be allocated some desks in the lab. Each of you was assigned to a group, and the groups will be paired up to form teams. You’ll know who your teammates are from the beginning, and you will need to devise a strategy to work with them, sharing work as appropriate. Report marking will be based on groups throughout the course. Match performance is group based during the first two assessments (matches) but team based on match day three and four. This guide will briefly outline the facilities that you have access to, what you have to make and what you’re given to make it with, who to contact for support, and how to contact them. Things are going to be cramped this year, but it should actually be a lot of fun. 1 The mentors, James, Kat and Garry are here to make sure you get the most out of SDP. 2 Lab space and facilities The areas allocated for SDP are largely on the third floor of the Forrest Hill building. For the most part, you will work in the large lab, where your group is given dedicated space. The two pitch rooms are used for match days and assessment. You can use these rooms to practice as well, initially on a first-come first-serve basis, but later on through a booking system to make sure everyone gets a shot. 2.1 The Main Lab The layout of the main lab is shown in Fig. 1. Each team gets one side of a row of desks, with a small practice area for that team at the end of the row. Each group is therefore allocated two flip desk machines. Each group has one PC with a vision feed to one of the pitch rooms (odd numbered teams are connected to room 3.D03 and even numbered teams to room 3.D04 - please note that each group will consist of a odd and even numbered team). These feeds are analogue and run through a sequence of boosters, splitters etc., so will have varying latencies and noise levels. There are two projectors in the main working lab which are connected to the pitches to allow for demo and game viewing. On match days only the group operator (group’s assigned computer commanding and system monitoring person) and group robot handler are allowed in the pitch room and only for setup and at the time of play of the own group. 2.1.1 The Practice Areas At the end of each row is a small area of floor marked out with white tape. The carpet here is the same as that used in the pitch rooms, and the tape used to mark it out is the same as the stuff used on the pitches. You may position a webcam to look down on the practice area and connect it to one of your group’s DICE machines, and you have your team’s very own mini pitch. You should also use your practice area to test the movement of your robot, your communications system, and any onboard sensors you have. Please do as much testing as possible in your practice area, to ease the load on the pitch rooms. Your team’s practice area borders that of the team next to you. Try to work with them to use the whole space, and play mini-friendlies when you are ready. When walking through the lab, you’ll pretty much have to walk through the practice areas. Watch out for robots and stray lego parts, and if you’ve got your robot in a practice area it is your responsibility to guard it against being stepped on/tripped over. 1 And work. Lots of work. 1

Upload: others

Post on 06-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

SDP Resources Guide

Sandy Enoch & Garry Ellard

January 16, 2017

1 Introduction

Welcome to SDP 2017.You will have most of the third floor of Forrest Hill for SDP. This includes two pitch rooms and a large lab. Each

group will be allocated some desks in the lab.Each of you was assigned to a group, and the groups will be paired up to form teams. You’ll know who your

teammates are from the beginning, and you will need to devise a strategy to work with them, sharing work asappropriate. Report marking will be based on groups throughout the course. Match performance is group basedduring the first two assessments (matches) but team based on match day three and four.

This guide will briefly outline the facilities that you have access to, what you have to make and what you’re givento make it with, who to contact for support, and how to contact them.

Things are going to be cramped this year, but it should actually be a lot of fun.1 The mentors, James, Kat andGarry are here to make sure you get the most out of SDP.

2 Lab space and facilities

The areas allocated for SDP are largely on the third floor of the Forrest Hill building. For the most part, you willwork in the large lab, where your group is given dedicated space. The two pitch rooms are used for match days andassessment. You can use these rooms to practice as well, initially on a first-come first-serve basis, but later on througha booking system to make sure everyone gets a shot.

2.1 The Main Lab

The layout of the main lab is shown in Fig. 1. Each team gets one side of a row of desks, with a small practice areafor that team at the end of the row. Each group is therefore allocated two flip desk machines.

Each group has one PC with a vision feed to one of the pitch rooms (odd numbered teams are connected to room3.D03 and even numbered teams to room 3.D04 - please note that each group will consist of a odd and even numberedteam). These feeds are analogue and run through a sequence of boosters, splitters etc., so will have varying latenciesand noise levels.

There are two projectors in the main working lab which are connected to the pitches to allow for demo and gameviewing. On match days only the group operator (group’s assigned computer commanding and system monitoringperson) and group robot handler are allowed in the pitch room and only for setup and at the time of play of the owngroup.

2.1.1 The Practice Areas

At the end of each row is a small area of floor marked out with white tape. The carpet here is the same as that usedin the pitch rooms, and the tape used to mark it out is the same as the stuff used on the pitches.

You may position a webcam to look down on the practice area and connect it to one of your group’s DICE machines,and you have your team’s very own mini pitch.

You should also use your practice area to test the movement of your robot, your communications system, and anyonboard sensors you have. Please do as much testing as possible in your practice area, to ease the load on the pitchrooms.

Your team’s practice area borders that of the team next to you. Try to work with them to use the whole space,and play mini-friendlies when you are ready.

When walking through the lab, you’ll pretty much have to walk through the practice areas. Watch out for robotsand stray lego parts, and if you’ve got your robot in a practice area it is your responsibility to guard it against beingstepped on/tripped over.

1And work. Lots of work.

1

Page 2: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

GRO

UP

1G

ROU

P 2

GRO

UP

3G

ROU

P 4

GRO

UP

5G

ROU

P 6

GRO

UP

7G

ROU

P 8

GRO

UP

9G

ROU

P 10

GRO

UP

11G

ROU

P 12

GRO

UP

13G

ROU

P 14

GRO

UP

15G

ROU

P 16

PRACTICEAREA

PRACTICEAREA

PRACTICEAREA

PRACTICEAREA

PRACTICEAREA

STORE

ELEC

TRO

NIC

S &

SO

LDER

ING

STA

TIO

N

GRO

UP

17G

ROU

P 20

GRO

UP

19

GRO

UP

18

Figure 1: Layout of the main lab.

2.2 The Pitch Rooms

There are two pitch rooms, which will be used interchangeably for matches. You should ensure that your robot isequally happy, or at least equally unhappy, in either room.

Each room has six DICE PCs. You will not be given the choice of which machine to use for matches, so yoursystem must work on any of the machines. You will also have very limited set up time, so make sure any calibrationis automatic, uses saved values, or is near-instant to perform.

Each room has a pitch marked out in tape and bordered with small boundary walls. More info on the pitch itselfcan be found in the Rules document.

A camera is mounted above each pitch, looking straight down. Due to mounting constraints, the location of thecamera relative to the pitch is slightly different in each pitch room. Each of the DICE computers receives a feed fromthe overhead camera. This feed can be seen in Xawtv (recommend), VLC, Mplayer, and can be opened with openCV2,or anything that uses Video4Linux3. More info on how to connect to and use the vision feed is in section 7.

The cameras have settings for brightness, saturation, etc. If you’re getting a dodgy feed look at these settings.You’ll also want to make sure they’re set properly to allow your colour segmentation to work.

2.3 Additional Meeting Space

For group/team meetings you can make use of any rooms in Forrest Hill, provided that they aren’t being used fora class or tutorial at that point in time. You may be able to view room bookings via the following link: https:

//www.ted.is.ed.ac.uk/UOE1617_SWS/default.aspx

If they can’t ask Garry to check the timetables for them as required, and rooms can be booked directly via the ITO.Note that we want to keep robot construction and testing etc limited to the main lab and pitch rooms.

2.4 Lockers

You will have the use of a locker to store your equipment. We will require a £5 deposit for locker keys and there will be1 key available per group to start off with. Additional keys may be available upon request. Garry has a set of masterkeys for the lockers in case of emergencies. Extra batteries may be issued dependent on your systems requirements.

2.5 The Store

A lego store cabinet can be found in the lab, which contains various boxes of lego parts such as plates, beams, axles,gears, wheels, fixings and all sorts of other random lego parts. This cabinet is left open 24/7 and you have free accessto the parts within. Please return all unused parts and all the boxes to the cabinet when you are done using themeach day. Hoarding of parts in your own lockers is not allowed and action may be taken to prevent this.

2http://www.opencv.org3https://en.wikipedia.org/wiki/Video4Linux

2

Page 3: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

2.6 The Technician’s (Garry’s) Office

Garry is the course technician, his office is 3.D08. You can go to speak to Garry during supported hours, for adviceand technical support.

Various example robots from previous years SDP groups along with kickers, the kick-bot and motor testing diff-rigsare available to borrow from the technicians office (room 3.D08). These should be returned intact to the technician’soffice during technical support hours or returned to the lego store if out of hours.

The technician’s office also houses a battery charging station, and is where Garry stores various sensors, switches,and other bits and bobs which you may be able to borrow.

2.7 DICE Machines

DiCE machines are maintained and have the full range of supported software but root access is not available andcustomisation is limited to what DiCE allows.

There are a few articles on the computing support help pages that detail how to install some of the software thatyou may find useful.

The vision PCs have had their disk space opened up for you to make use of and this can be found in the /scratch/sdpfolder. Be warned this space is NOT backed up and is open to the next SDP student who logs into that machine touse. Therefore it should be considered as unsecure and used only for installation and video streaming/processing use.

Each team can have a group space provided for them upon request (which will be found at:- /group/teaching/sdp/sdp1-20). You may use this for both your working area and for hosting any web-pages you create for the project. Your owngroup space is secure, with the exception of the html folder, which is world readable.

The SDP archive folder can be found at /groups/sdp/archive and is open for you to see previous years code. Seealso the repositories linked to from the wiki.

3 HelpOr How to Complain Efficiently

Support is available from many places, from technical help, to support in the case of issues within groups. There is alarge amount of self-learning required for SDP, but that doesn’t mean you or your group are completely on their own.

Technical Help Check the documentation, Google it, speak to your teammates and coursemates, use Slack, andspeak to Garry. For any issues with the kits or equipment in general, speak to Garry

Other Help Your mentor should usually be your first point of contact, but you can escalate up the chain if needsbe. After your mentor you can speak to the Teaching Assistant.

3.1 Course Management Structure

3.1.1 Mentors

Every group is assigned a mentor, who should normally be your first point of contact for any issues or questions. Yourmentor is meant to provide team guidance, and ensure that no group member is being treated unfairly. Your mentoris not allowed to provide technical assistance, but can refer you to the appropriate source.

Your mentor should meet with the whole group at least once a week, and you should e-mail your mentor if anythingcomes up in the interim.

Roughly half the mentors have done SDP before, and each team should have at least one mentor who knows what’sgoing on.

3.1.2 TA

One step above the mentors is Kat, who is the teaching assistant. If there’s something your mentor can’t or won’t fix,or you have any issues with your mentor, get in touch with her. James is also available to assist. He is the point ofcall for rule-related issues/questions.

3.1.3 Garry

Garry is the go to guy for anything technical that you can’t find the answer to in the documentation or from yourcoursemates. He does have obligations other than SDP, but you should find him and speak to him for any issues withthe kits, facilities, etc. He’s been around for many years of SDP, and has seen a lot of good robots and a lot of badrobots.

3

Page 4: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

Figure 2: Example top plate. The centre disc is your team - yellow or blue.

3.2 Group discussion - Slack

We have setup a course-wide Slack channel at: https://sdp-2017.slack.com/. Students can use the this channel tospeak to their groups as well as with the mentors and management. You will receive an invitation to join the channelby e-mail.

It’s a good place to ask technical questions as chances are another group has already faced a similar problem, or amentor might be able to point you in the right direction. Mentors are allowed to provide technical help on Slack, onthe public channels shared with everyone. Mentors are asked not to give technical help on private channels.

You can also ask for clarification on game rules, or anything else. However official announcements will be madevia email to the whole course.

While the mentors and the management will have access to the Slack, we cannot guarantee how often they willcheck it.4 If you have an urgent issue that only your mentor or the course managers can sort, you should e-mail theappropriate person.

4 The Game

The task this year is two-a-side football, based loosely on the Robocup Small Size League5. For more information, seethe rules document.

5 The Robot

You are required to build a robot. There are restrictions on how large your robot can be, and how it can interact withthe ball - see the rules for these.

Each group will be issued with, a box of lego (all groups will have an equal quantity of lego, but no two kits willbe indentical), one Arduino assembly (including power and motor boards along with the associated cables), one SRFstick, sixteen AA rechargable batteries, two 8-way battery holders, a battery charger and a battery tester. Furtherinfo on the electronics, batteries, and battery charging/testing facilities are in section 8

We have limited stocks of holonomic wheels and various types of motors, sensors and associated leads availablefrom the lego store (room 3.D02A), some of which are free and some of which are chargeable parts. However if youchoose to take items from these stocks and decide not to use them on your robot, then they must be returned to thestore room. Hoarding of these types of parts in your group lockers is not allowed and action may be taken to preventthis.

5.1 The Top Plate

On top of your robot you will place a top plate. The plates will be supplied printouts with 5 velcro fixings (comple-mentary velcro being available from Garry or the store room). The plate has a pattern that identifies your team andyour robot. An example pattern can be seen in Fig. 2. The center marker of the pattern will identify which team arobot is on, and will be either blue or yellow. The colours will be allocated at the start of each match, and your robotshould be happy working with either colour.

The remainder of the pattern (fluorescent pink and/or green markers) identify your robot specifically, so that youcan distinguish between your robot and your team-mates robot.

There will be a set of plates per room and some in the store room to start off with. There will be two sets asidefor match day use only. If needs be we will issue a set per group and can make the image files available on request.

4They’re only paid for a few hours per week, but the mentors will try to keep an eye on Slack as part of their responsibilities5http://robocupssl.cpe.ku.ac.th/

4

Page 5: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

(a) An omni-directional wheel (b) Ball Transfer Units

5.2 The Other Bits

Your robot will need to move around, and will need to sense some things about itself and it environment. The legostore contains an array of parts, but you should note:

Motors There are a few types of Lego motors in the store, the old style Technic motors (which are just motors),the power functions motors (which include some gearing) and the newer NXT motors, which are geared motorswith built in encoders to give feedback about rotation. Lots of info on lego motors can be found here: http:

//www.philohome.com/motors/motorcomp.htm

Wheels There are a few options for wheels. 1) Normal wheels; there are a few different varieties of these. 2)Omnidirectional wheels6 (commonly called holonomic wheels), which you can use to make a robot that can go sidewayswithout turning.7 3) Ball transfer units / castors - which are passive, but which will support your robot as it movesin any direction.

Sensors There are a huge number of potential sensors you could use with your robot. The lego sensors includebump switches and colour detectors, and there are many other types of sensors in the store and Garry’s office, andavailable to buy. Some examples are given later.

6 Code

SDP is a bit different from other courses. You are encouraged to not reinvent the wheel wherever possible. Thefollowing two code bases, from a previous year, are supplied and we expect you to build your code on top of one of(or a combination of the two) code bases:

• SDP 2016 2-Wheel Drive Example System: https://bitbucket.org/craigwalton/sdp-g7

• SDP 2016 Holonomic Drive Example System: http://fred.rovder.com/

You are also encouraged to use off the shelf libraries and packages as much as possible. You should fully documentyour code, and you are required to attribute code where you are re-using it.

In addition to the two supplied starting code bases, older code is still available and can be used. You are encouragedto look through this, understand what the previous years did, and see if there is anything you want to make use of.Remember that this code has been reused and re-bodged every year for several years. There may be some code worthreusing, some code for which it would be better to use a library, and some code which would be better binned andrewritten.

A good example is some of the vision systems, which require large amount of manual calibration, have very slowcycle times, and still don’t work very well. Some of the systems are worse than others for this, so think carefully beforeyou import a large chunk of code and then spend more time fixing it than it would have taken to make somethingfrom scratch.

6.1 Repositories

You are required to put your code in a repository such as github or bitbucket. You can keep it private for now, but itneeds to be there, and you should give your mentor access to it.

You should ensure that all of your group are familiar with the version control system you use, and your standardworkflow.

6https://en.wikipedia.org/wiki/Omni_wheel7First introduced to SDP by Holly: https://www.youtube.com/watch?v=KXbTorONqT0

5

Page 6: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

7 Vision

Each of the pitch rooms has a top-down camera which you can use to locate the pitch, the robots, and the ball. Eachof the PCs in the pitch rooms receive a feed from this camera, and feeds from both pitches are sent through to certaincomputers in the main lab.

7.1 The Pitch Cameras

The capture devices used have settings for brightness, saturation, etc. These settings are critical for correct operationof your vision system, and you will need to make sure, every time you log on that they are set correctly.

To test the video feed and to adjust the video format and baseline settings run xawtv from the command linewithin a terminal window. Note: by running this from the command line you will see all the relevant error messagesthat you will need to see to diagnose any potential problems.

There are several different video programs on DiCE which can be run from both the menus and the command line,however xawtv is the only one to give you useful fault finding information when the video feed fails to appear. Xawtvmay fail the first time that you try to run it, if it does, then close it and run it again.

Right click in the main window to gain access to the control menu. Check and select PAL and S-Video as theformat options. You should also centre the colour, contrast, brightness and gamma settings.

We would suggest going through this or an equivalent procedure each and every time you sit down at a visionsystem prior to launching your vision system programs.

The hardware retains the last users settings, so you may not get the image that you were expecting to see otherwise

7.1.1 Troubleshooting

The video capture devices can only do one job at a time.The first user to login into a DiCE PC gets the hardware permissions.Remotely accessing a video feed from another PC won’t work without first being logged into the machine with the

direct feed.Note that the PCI capture devices default to factory settings every time that you try to use them.Table 1 gives a guide to troubleshooting the most common issues with the video feeds. If after trying these solutions

you still cannot see the video feed correctly, report this to the course technician along with the name and location ofthe PC in question.

7.2 Using a Vision Feed

Regardless of whether you’re using a USB capture device, PCI capture card, or a USB webcam, your image feedshould be accessible through openCV and any program that uses Video4Linux. Aside from some calibration, yourcode should operate completely independently from a particular type of camera, and you must not rely on using aparticular type of capture device.

7.3 OpenCV

OpenCV8 is a fairly comprehensive open source vision library, which is easy to use from Python, C/C++, and Java.You will find that most if not all of the previous years’ code makes use of OpenCV.

OpenCV is installed on the DICE machines you will be using.

7.3.1 Python

In Python, it’s easiest to run in a Python2.7 virtual environment9 , and add /usr/lib64/python2.7/site-packages toyour PYTHONPATH, for example by adding

export PYTHONPATH=$PYTHONPATH: / usr / l i b 6 4 /python2 .7/ s i t e −packages

to your virtual environment’s /bin/activate file.It’s extremely worthwhile having your vision person/people run through the openCV Python tutorials 10

7.3.2 C++

You should find opencv in /usr/include/opencv2, and should be able to just do e.g. #include ”opencv2/core/core.hpp”.The official opencv c++ tutorials11 are a little dense, but contain a lot of information organised by opencv module.

8http://www.opencv.org9http://computing.help.inf.ed.ac.uk/python

10https://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_tutorials.html11http://docs.opencv.org/2.4/doc/tutorials/tutorials.html

6

Page 7: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

Symptom Cause Solution

Black screen The video capture device has beenupset and will not function properlywithout rebooting the PC. Reasonsfor this include, the last users pro-gram not being terminated cleanly,the last user being bounced of themachines front screen which meansthat they still have all the hardwarepermissions.

Reboot the PC.

Blue Screen The capture device is not seeing avideo feed. Note - that the capturedevices have two inputs:- Compos-ite and S-video. The device may beset to the wrong one.

• Run xawtv and check that S-Video has been selected.

• Check that the PC has a cap-ture device plugged into it.

• Check that the capture de-vice has an S-video leadplugged securely into it.

• Check that that S-Video leadgoes to an amplifier and isplugged in securely.

• Check that the amplifier hasan S-video input lead pluggedsecurely into it.

• Check that the amplifierspower light is on, if not pleaseplug the adapter back in andor switch it on at the wall.

Green Screen xawtv has crashed Try running it again from the com-mand line.

Fuzzy or Black andWhite (Greyscale)Image

You either have a faulty feed or youhave the wrong settings. • Run xawtv and select PAL

and S-Video.

• Check the attached videolead for bent or broken pins,both at the capture deviceand the nearby amplifier.

Dark/bright/strangelycoloured image

Dodgy camera settings Use your favourite method to ad-just the brightness, saturation, etc.settings for the camera

Table 1: Video feed troubleshooting guide

7

Page 8: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

(a) Power & I/O Board (b) Motor Board (c) Encoder Board

Figure 3: The basic electronics set

7.4 Papers to Read

It is strongly recommended that any persons working on the vision system read the following papers:

• Bruce, James, Balch, and Veloso. ”Fast and inexpensive color image segmentation for interactive robots.”Intelligent Robots and Systems, 2000.(IROS 2000). Proceedings. 2000 IEEE/RSJ International Conference on.Vol. 3. IEEE, 2000.

• Bruce, James, and Veloso. ”Fast and accurate vision-based pattern detection and identification.” Robotics andAutomation, 2003. Proceedings. ICRA’03. IEEE International Conference on. Vol. 1. IEEE, 2003.

These papers describe methods for segmenting an image by colour, and for recognising patterns in segmentedimages, exactly as you are required to do.

Even better, code that implements these algorithms is available at: http://www.cs.cmu.edu/~jbruce/cmvision/

7.4.1 SSL Vision

The vision processing problem you face is very similar to that faced in the Robocup Small Size League. The leaguemakes use of a communal vision system called SSLVision1213 14, which you may wish to investigate.

7.4.2 Crediting Code

To reiterate, if you make use of open source libraries or packages, or anybody else’s code in general, you must leaverelevant licenses in place. You must also indicate in your documentation/technical reports etc. where you have utilisedothers’ code. Failure to do this, or attempting to pass others’ work off as your own, may lead to serious negativerepercussions.

8 Electronics

You are provided with a selection of electronics to use on your robot. At the core of the standard kit is an ArduinoXino RF15, a variant of the Arduino Uno with an attached Radio Frequency (RF) link. This RF link appears as aserial port to your Arduino, and can be used to speak to a USB RF stick which plugs into a PC. The RF stick appearsas a serial device on the PC as well. More information on the RF comms is given in section 9.

Fig. 3 shows the main electronics kit. The Arduino attaches to the Power and I/O board, which does some powermanagement stuff and breaks out some digital pins, some analog pins, and a bunch of I2C sockets for you to use.16.

The Motor Board connects via I2C and drives up to six motors. The Encoder board also connects via I2C, andconnects to up to six rotary encoders of the type used in the lego NXT motors or available separately in the kit. Asthe name suggests, rotary encoders measure rotation, and these should be used at least to measure the rotation ofyour wheels.

You can add lots of different types of sensors, and some examples are given later in this section. You are also freeto use your budget to upgrade the electronics on your robot.

12Zickler, Stefan, et al. ”SSL-vision: The shared vision system for the RoboCup Small Size League.” RoboCup 2009: Robot Soccer WorldCup XIII. Springer Berlin Heidelberg, 2010. 425-436.

13Zickler, Stefan, et al. ”Five Years of SSL-Vision - Impact and Development.” RoboCup 2013: Robot World Cup XVII. Springer BerlinHeidelberg, 2014. 656-663.

14https://github.com/RoboCup-SSL/ssl-vision15http://openmicros.org/index.php/articles/88-ciseco-product-documentation/235-xinorf-learning-the-basics16more info on that later

8

Page 9: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

8.1 The Arduino

An Arduino is a microcontroller with some firmware loaded to make things more simple. A basic Arduino programconsists of a setup function, called once at the beginning, and a loop function which is run indefinitely. You programthe Arduino in C or C++, although the Arduino environment provides some simplifications to use if you wish.

The Arduino IDE is loaded on the DICE machines. If plug your Arduino in through the mini-USB (no externalpower needed at this point), and run the arduino program, it should find your Arduino Uno on one of the ttyACMserial ports.

There are many example Arduino programs available17, lots of libraries, and examples of connecting externaldevices to your Arduino.

8.1.1 The SDP Arduino Library

On the SDP wiki, there is a link to SDPArduino.zip, which contains a small library to help you get started with theArduino.

If you extract this .zip into ∼/sketchbook/libraries/SDPArduino/, you can then ”#include <SDPArduino.h>” atthe start of your Arduino programs.

Have a look through the SDPArduino.h and SDPArduino.cpp files. You will see that there is an SDPSetup()function which configures the I/O ports (default to analog/digital I/O as inputs and digital I/O as outputs) andactivates the RF comms.

There are also functions for controlling the Motor Board, and some simplified I/O functions. A demo script fortesting the motor board is also available on the wiki.

8.2 Power & I/O Board

The Power and I/O Board is effectively an Arduino shield. It plugs into your Arduino, providing power to it andbreaking out digital, analog, and I2C connections.

A schematic of the Power and I/O Board is shown in Fig. 4. There are four 6-pin connectors which expose variouspower levels and digital and analog ports from the Arduino. These ports are directly connected to the Arduino withno additional protection circuitry, so make sure you know what you are doing before you start connecting stuff. If youdon’t know what you’re doing, have a look at the examples section.

The boards have a bank of seven 4-pin I2C connectors. The cables provided to attach to the motor board and theencoder board should only fit in one way, so you shouldn’t be able to connect these up incorrectly. If attaching yourown I2C devices, pay attention to the pinout on the schematic.

8.3 Batteries and Chargers

You will be provided with a set of rechargeable AA cells, two 8-cell holders, and a battery charger and tester.

8.3.1 Battery Charging Station

A battery charging station is available in the technicians office (room 3.08) and you are allowed access during thesupported hours to trade in empty batteries for charged ones on a one for one basis.

8.4 Motor Board

Fig. 5 shows a schematic of the Motor Board.The board has two I2C connectors, you can attach one to your Arduino via the Power and I/O Board, and use the

other I2C connector to attach something else. It doesn’t matter which you use.The board has six 2-pin connectors to attach to motors. Adaptor cables are provided for connecting the lego

motors to these.You control the motors by sending commands over I2C from your Arduino. The SDPArduino library contains

functions for doing this, and there is a demo script available on the SDP wiki.

8.4.1 Motor Power and Battery Level

The voltage level of your battery pack will drop as you use up the charge in the cells. The Power and I/O Boardwill keep the voltage supplied to the motors to less than 10v, regardless of input voltage, but it will not increase thevoltage from the batteries. Unless you do something clever, this will mean that with a fresh set of batteries the motorswill turn faster than with slightly discharged batteries, for the same percentage power command.

Things you can do about this include:

17https://www.arduino.cc/en/Tutorial/HomePage

9

Page 10: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

Power & I/O Board

POWER IN(BATTERY)

POWER OUT(TO MOTOR BOARD)

A0

A1

A2

A3

ANALOG IN OR

DIGITAL I/0

3 /

INT

1 /

OC

2B

5

/ O

C0

B

9 /

OC

1A

6

/ O

C0

A

DIGITAL I/0OR PWM

~9

V

GN

D 5V

GN

D

GN

DSC

LSD

A5

V

I2C

Figure 4: The Power and I/O Board

Motor Board

POWER INMOTOR 0

MOTOR 1

MOTOR 2

MOTOR 3

MOTOR 4

MOTOR 5

GNDSCLSDA5V

I2C

Figure 5: Schematic of the Motor Board

10

Page 11: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

Encoder Board

GNDSCLSDA5V

I2C

Figure 6: Schematic of the Encoder Board

• Use the rotary encoder feedback to actually measure how much your motors are turning.

• Monitor the battery level and account for it when you command the motors (example connections shown later- do not just plug the battery into an Arduino port)

• Use a voltage regulator to get a fixed voltage level for your motors. (this one’s pretty much just for the electricalnerds. Don’t bother making your own, it’s cheaper and easier to get one off the shelf).

It’s a good idea to do at least one of the above things. You should be using encoder feedback as a matter of course,so that’s a no-brainer, and monitoring the battery level is easy.

Needing to swap the battery pack after every match doesn’t look very good, and the judges are unlikely to give youmuch sympathy if you explain that your robot didn’t move at all because the batteries were not quite fully charged.

8.5 Encoder Board

The Encoder Board can be connected to your Arduino through I2C, and monitors up to six quadrature encoders. Aschematic of the board is shown in Fig. 6.

Adaptor cables are provided to connect the Lego NXT motors with built in encoders to the encoder board andmotor board simultaneously. The standalone encoders are prewired with a connector to plug into the encoder board.These connectors will only fit in the correct way round...

The Encoder Board has another Arduino at its heart. It is preprogrammed to detect movement of attachedencoders, and when queried will provide information on how much the encoders have rotated since the last query.

The firmware loaded onto the Encoder Boards18 can be found on the SDP wiki, along with a demo script forreading values from the Encoder Board.

8.6 Background Reading

Whoever is working with the electronics should be familiar with a few things, as well as the microcontroller/Arduinosystem itself. Here are some starter references

18It is technically possible for you to change the firmware on your encoder board, but you must speak to Garry first. He can providehelp, and it’s important that we know there’s an encoder board with different programming.

11

Page 12: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

I2C (Inter-Intergrated Circuit) is a bidirectional multi-master communications bus which uses four wires - power,ground, clock, and data. It’s widely used, available on almost any microcontroller, and very well documented.1920.The Arduino Wire library21 does all the complicated stuff for you.

Incremental Rotary Encoders The rotary encoders inside the NXT motors2223, and in the separate encodersprovided in the kits, are incremental encoders which give a quadrature signal on two lines.24 Put simply, a rotatingshaft will generate two pulse trains with a 90 degree phase shift between them. Which pulse train is ”leading” tellsyou in which direction the shaft is rotating. There are four states that can be produced, and these are continuouslycycled through as the encoder rotates.

8.7 Connecting Stuff to your Arduino

This section has a few examples to get you started. For more, use Google - the Arduino tutorials (https://www.arduino.cc/en/Tutorial/HomePage) will walk you through things.

Student Beware. The pins on the Arduino are not designed to source or sink large amounts of current. Or evenmedium amounts of current. The absolute maximum per pin is about 40mA, recommended 20mA. Combined, youshould not be putting more than 100mA across a port (The ATMEGA has three ports, Arduino pins 3, 5, and 6 areon port D, pin 9 is on port B). If you break it, you might have to pay for a new one out of your budget...25

8.7.1 Battery Level Monitoring

The battery level is an analog signal, and the Arduino has analog inputs. But, the battery voltage is significantlyhigher than what the Arduino can cope with. You’ll need to use two resistors as a potential divider to scale down thevoltage, and attach the Arduino Analog input to the middle of the potential divider.

You can use one of the ∼9v pins on the Power & I/O board to get the voltage which is actually being supplied toyour motors. Use a factor of safety to make sure you don’t overload the Arduino pin. Additionally, you could thinkabout using a diode to protect the Arduino pin from getting too high a voltage.

Use the Arduino analogRead() function (e.g. ”analogRead(A0)”) to read the analog input.

8.7.2 Potentiometer

Potentiometers come in rotary and linear flavours, and give an analog readout of position. You can use these, e.g. forgetting the absolute position of your kicker. They have three pins, attach one end pin to ground, the middle pin toan analog input, and the other end pin to 5V. Again, use the arduino analogRead() function.

8.7.3 Bump Switch

You’ll need a switch and a resistor. The value of the resistor isn’t too important, 10kΩ is a nice value, but anythingabove 1k would pretty much be fine. Attach one end of the switch to 5V, the other end to an Arduino pin and theresistor, and the other end of the resistor to ground.

Set the pin up as an input (”pinMode(3, INPUT)”) in your setup function, and then use the digitalRead() functionto get the value of the switch.

8.7.4 Tilt Switch

For a simple 2-state tilt switch, its exactly the same idea as for a bump switch.

8.7.5 Servo Motor

In the general sense, a servo motor is an enclosure that includes a motor, (usually) a geartrain, an output sensor, anda closed loop controller. You can command it to go to a specific position (or velocity...), rather than control the motordirectly. In the hobbyist world, servo motors are widely used (and very cheap), and most accept a PWM signal tocommand them to go to a certain position.

19e.g. http://www.robot-electronics.co.uk/i2c-tutorial20https://en.wikipedia.org/wiki/I2C21https://www.arduino.cc/en/Reference/Wire22http://www.brickengineer.com/pages/2008/09/05/lego-nxt-motor-wiring/23When googling, note that many people refer to the encoders in the lego NXT motors as tachometers. This is not very accurate, but

ho hum.24https://en.wikipedia.org/wiki/Rotary_encoder#Incremental_rotary_encoder25Fret not, the odd accident is okay, but try to be careful

12

Page 13: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

Figure 7: The Ciseco SRF Stick

The four digital pins on the Power & I/O board are also PWM output pins, so you can connect the signal line ofyour servo to one of these. Then connect the ground of the servo to ground, and the positive line to 5V. (Note :- Thepower board won’t like powering too big a servo.) You might want to include a BEC (Battery Eliminator Circuit), toget a high current 5V, 6V or 7.2V supply for your servo(s). These are pretty cheap these days.

Typically, servos require a 50Hz pulse, with an on-time of between 1ms-2ms setting the position, but this variesbetween servos and you should check for the type you get.

You can use the Arduino Servo library, or go a bit more low level and set up the PWM yourself.26

8.7.6 I2C Modules

There are many sensor modules you can buy which will connect though I2C. Connecting these is as simple as connectingthe four pins on the sensor module to one of the I2C ports on the Power & I/O Board.

8.7.7 IR Sensor

You can implement an IR sensor for proximity/distance detection using a simple IR LED/detector pair, or by usinga dedicated IR distance sensor.27 The Sharp IR distance sensors use modulated IR so are fairly robust to noise, andgive a surprisingly accurate signal as an analog value. Lots of resources are available online.

8.7.8 Sonar

You can pick up a sonar sensor for a couple of quid, and there are lots of resources online for connecting them toArduinos.28 Also look at the Arduino Ping library.29

8.7.9 Other Sensors

There are many other sensors you may want to connect to your Arduino30, from sensors to detect the white lines ofthe pitch to colour sensors. For the most part connecting these to your system is simple, and we encourage you tohave sensors on the robot itself, you can get much faster and more specific feedback than through the vision systemalone.

9 Communications

Each group is provided with an Arduino Xino RF31 and an SRF USB Radio Stick32. User guides and full technicaldocumentation for these is available on the cited pages.

The RF system basically broadcasts to all devices on the same frequency. You can set a ”PAN ID” to configurean addressing system, and/or you can implement your own. The RF modules can be configured by transmitting three”guard characters”, and then using a command set.33 You may use the ATID command to set the ID for your stickand Arduino. Note that you must issue an ATAC (apply changes) command for this (or other changes) to take effect.

By setting the PAN ID with the ATID command (on both your Arduino and RF stick), you can configure aparticular stick to talk to your particular Arduino. However, when using the same frequency band as other groupsyou will likely see interference and dropped packets.

26https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM27see e.g. http://www.robotshop.com/uk/infrared-light-sensors.html28e.g. http://arduinobasics.blogspot.co.uk/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html29https://www.arduino.cc/en/Tutorial/Ping30see e.g. https://www.arduino.cc/en/Tutorial/HomePage http://www.proto-pic.co.uk, http://www.robotshop.com/uk/

robot-parts.html, http://www.hobbyking.com31https://www.wirelessthings.net/xinorf-100-arduino-uno-r3-based-dev-board-with-radio-transceiver32https://www.wirelessthings.net/srf-stick-868-915-mhz-easy-to-use-usb-radio33http://openmicros.org/index.php/articles/88-ciseco-product-documentation/260

13

Page 14: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

Team Group ATCN setting (hex)Default Any 0x00

Team AGroup 1 0x10Group 2 0x17

Team BGroup 3 0x20Group 4 0x27

Team CGroup 5 0x30Group 6 0x37

Team DGroup 7 0x40Group 8 0x47

Team EGroup 9 0x50Group 10 0x57

Team FGroup 11 0x60Group 12 0x67

Team GGroup 13 0x70Group 14 0x77

Team HGroup 15 0x80Group 16 0x87

Team IGroup 17 0x90Group 18 0x97

Team JGroup 19 0xA0Group 20 0xA7

Table 2: Communications ATCN (frequency) settings

You may change the frequency using the ATCN command, but only to the default (0) or the number given foryour group in Table 2. You may coordinate with your teammates to use the same frequency. Note that the frequencysettings do not appear to be persistent (i.e. you’ll need to set them every time you power up)

You must not use any other frequencies. As this may interfere with other groups. Anybody found to beusing a frequency not allotted to them may face negative repercussions. Do not use the ATCH or ATCS commandsto change these settings.

Please do not change the guard character, as it’s a pain for us to figure out later.

9.1 Using your Own Communications

There is enough money in your budget to allow you to use a different communications method if you wish, howeverbefore you do this you’ll need to do two things:

1. Speak to Garry and let him know what you’re thinking of doing

2. Check that DICE will work with your kit. It probably won’t, and there’s no point wasting your budget.

10 ROS

The Robot Operating System (ROS)34 is a framework and set of libraries used on some of the most cutting edgerobots in academia and, increasingly, in industry.35

It’s not a full OS, but it runs on top of e.g. Linux, and provides a core for passing messages, calling services andactions etc. You can set up nodes for particular parts of your system, e.g. vision, communications, planning. Youdefine the communication between them, with messages as simple as integers or as complex as full images. ROS willtake care of running your nodes in parallel, handling the communication between them, and give you an easy way tosee what’s happening, save and replay things, and so on.

ROS also has a large library of extremely useful packages, for tasks ranging from navigation to vision processingand state machines.

For this year, ROS has been installed on the DICE machines. The core functionality is there, and you can installadditional packages to your user space.

It’s not critical that you use ROS, and it will take some effort to understand and use correctly, but if you’re keenit will give you useful experience of a real world robotics tool. It can also help you modularise your system.

34http://www.ros.org/35https://vimeo.com/146183080

14

Page 15: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

Further documentation on getting started with ROS will follow. The ROS wiki36 has a whole bunch of tutorialsand other info.

11 Your Budget, and Additional Parts

Each group is allocated a budget of £100 with which to buy additional parts and equipment.Before buying something, you must get approval from Garry, otherwise you won’t get reimbursed. He can also

probably give you some advice about whether it’s a good idea, if it’s been tried before, and he might already havewhat you need in stock.

The final project spend should be finalised and mentioned in your final report. You may of course borrow itemsto test and return them without being charged.

There are also some rules about what is allowed and what is not.

The same equipment must be available to all groups. Your uncle Toby may work at Raspberry Pi and beable to give you some free Pis, but unless you’re willing to get and give the same number to every group, no free Pifor you. Similarly, you can’t use a 3D printer unless every group has access to it. Generally, anything bought from ashop is OK, or things off eBay.

There are some chargeable items in the SDP store, for example the holonomic wheels.The rules contain some restrictions about what you can use on your robot, and what you can do off pitch, so refer

to them before buying stuff. Generally, you’re allowed to use what you buy on the robot or off, but you can’t dosomething like add your own camera above the field. You can buy tools to work with your robot.

There is a lot of scope to innovate here, but remember to always have the basics down, you must deliver a functionalrobot.

Some examples of things you could buy (from the store if we have them):

• Long arm microswitches for bump detection

• Potentiometer for detecting kicker/grabber/etc. position

• Servo motors (and BEC)37

• IR distance sensors

• Sonar

• Inertial measurement unit

• Single board computer

• Onboard camera?

12 Use of Facilities

You are encouraged to make the best use possible of the given facilities and equipment.However we reserve the right to restrict anything that we deem as being unfair or unsporting use. You are also

restricted to using the equipment/parts/kit that has been (or can be) supplied to each groups equally, and kit thathas been bought in under your group budget. This also includes the use of kit that has been brought in from home,which for the purposes of the project will be considered as items bought under the groups budget and looked at onan item by item basis.

13 Teamwork

Your group is in a team with one other group, and as well as playing matches together you share certain facilities.You are permitted to work together as much as you want, but remember that groups are assessed individually.

36http://wiki.ros.org/37e.g. http://www.hobbyking.com (order from the UK warehouse for quick delivery)

15

Page 16: SDP Resources Guide - School of Informatics · 2017-01-16 · SDP Resources Guide Sandy Enoch & Garry Ellard January 16, 2017 1 Introduction Welcome to SDP 2017. You will have most

13.1 Shared Communications

Details of the provided RF communications sticks are given in section 9, you are allowed to share a communicationschannel with your teammate.

There is a limited amount of space in the frequency domain, so each group and team is allocated a particularchannel.

If there are issues with one group spamming a communications channel, please speak to your mentor or Garry.

13.2 Shared Vision

If you want to, you can run a shared vision system.

13.3 Shared Strategy

Ideally, a team will co-ordinate and have its robots work together. You may wish to designate one robot the defenderand one the attacker, and design each with these roles in mind. You may not.

13.4 Sharing a PC?

You are allowed, but not required, to run both robots from a single DICE machine for matches.

13.5 Sharing the Workload

You can spread a lot of the workload for SDP between the two groups in your team. You do need to ensure, however,that your robot performs at the end of the day. It doesn’t matter if you didn’t write the bit of code that broke, youneed to ensure you are confident in your system.

There are lots of open ended challenges in SDP, from vision performance to strategy to including interestingsensors. You should always ensure you have a working robot, but with judicious sharing of the workload, you shouldhave manpower to investigate interesting avenues. If successful, this can impress mentors and the external judges whocome along on finals day.

There is always enough work to give everybody enough to do, even with a lot of collaboration. If you don’t feellike you have anything to do, or you’re worried about how your group/team is being managed, speak to your mentor.

16