Robot competitions are in the air these days, what with the recent Battlebots competition in Massachusetts and the earlier Student Robot Challenge in the UK. Here’s an update from Tanya Morton, who ran the event in England.
A few weeks ago, MathWorks hosted a Student Robot Challenge at our new office building in Cambridge. The event was a great success. The students had fun and learned plenty about modelling, simulation, control design, code generation, and teamwork. I wrote a blog about the event here:
We’ve compiled a brand-new video with the highlights of the day, which explains more about the contest and shows the LEGO MINDSTORM NXT robots in action!
It has been a while since we last talked about displaying data tips on MATLAB Mobile.
The data cursor feature has since then evolved from tap-and-hold invocation to a more prominent ‘Show Data Cursor’ button. Tapping on this button brings up the crosshair. Move the crosshair to any location on the figure to display the coordinates of that location.
We’re happy to announce that the latest release of MATLAB Mobile for Android supports this feature, much like its iOS counterpart.
Tap on Show Data Cursor Position crosshair at desired location
This week I welcome Dr. Paul Kassebaum to the blog. Paul is a physicist at MathWorks working to engage the public with engineering and science. He fell in love with engineering at the Cooper Union for the Advancement of Science and Art, and then became obsessed with physics at the Worcester Polytechnic Institute, where he earned a Ph.D. specialized in quantum mechanics. His latest projects at MathWorks include designing a digital interactive museum exhibition at the Ecotarium in Worcester and managing a sponsorship between MathWorks and Artisan’s Asylum. His work at Artisan’s Asylum focuses on using MATLAB to create 3D prints that help one literally grasp abstract math and physics concepts.
Build Your Own Autonomous Battlebot
A massive maker space. Cutting-edge software. Expert mentors. And just one week to craft the most devastating robot possible.
by Dr. Paul Kassebaum
MathWorks is teaming up with Artisan’s Asylum to wage a robot battle accelerated by Simulink’s run on target hardware capabilities and the computer controlled manufacturing tools at Artisan’s Asylum, the largest maker space on the east coast. The fight will serve as the grand finale of the Cambridge Science Festival on Sunday April 21st at the Center for Arts at the Armory, and will be free and open to the public. The contest begins on Sunday April 14th at Artisan’s Asylum, where teams will design their robots over the course of a week. To sign up and for more info, have a look at designchallengebattlebots.com.
Sergio Biagioni is working at MathWorks to develop a Simulink framework to aid high school and undergraduate contestants in their algorithm designs. Each robot will be equipped with an Arduino Mega 2560, a line sensor, touch sensors, sonar, and a wireless feed akin to GPS sent from an eye in the sky. The overhead camera will use the Computer Vision System Toolbox to locate each robot and its orientation based on colored stickers applied to the chassis.
Rob Masek, facilities manager of Artisan’s Asylum, is organizing the tournament, drawing on his experience as a (three time) contestant on Comedy Central’s BattleBots and as an organizer of several US FIRST Robotics competitions and a home-brew robot competition called Pound of Pain. I’m confident he’ll be able to replicate his previous successes.
Gui Cavalcanti, the founder of Artisan’s Asylum, is whipping up a robot chassis to help Sergio develop the Simulink framework all of the contestants will use. This prototype robot will be made of the same components available to the contestants, and will be offered up to the contestants to help them jump right into software development before their own chassis are fully operational. While the robots in this competition will have wheels, most of Gui’s robots have more than their fair share of legs.
Stay tuned for more details as the story progresses!
This week I’d like to introduce guest blogger Dr Tanya Morton. Tanya leads the Application Engineering team in the UK, helping customers in industry and academia to apply MATLAB & Simulink to their technical, business and educational challenges. She is keen to encourage more people to enjoy lifelong careers in science, technology, engineering and mathematics. You can find Tanya on Twitter and LinkedIn.
The MathWorks Student Robot Challenge
by Dr. Tanya Morton, MathWorks UK
Earlier this year a colleague and I were bouncing around ideas for ways to do more outreach with the local student community. He pointed behind him and said, “Why don’t we make use of the empty space in the new office to host a robot contest?” An idea was born…
Last Friday, this idea came to fruition when MathWorks hosted a Student Robot Challenge. Nine teams from the University of Cambridge participated in the contest. The challenge was to develop a controller for a LEGO MINDSTORM NXT robot to make it visit a set of 12 locations on an arena in the shortest time possible.
After a briefing, the students started working their way through short tasks designed to bring them up to speed with Simulink, the principles of controller design, and the process of generating code to run on the robot. Within five minutes, you could hear the first robot spinning on the spot.
In the afternoon, the students explored a variety of navigation and control strategies, which they tested using a combination of simulation and hardware testing on their robot.
The day ended with a final contest where the teams competed against each other to navigate to the most locations in the shortest time. Team names were picked out of the hat to decide the running order for the final contest. The first to go was the QED-grad team, an experienced team of PhD engineering students. The team successfully hit all 12 locations in a time of 1 minute and 41.3 seconds. Their robot left each location quickly, but tended to spiral around the next target rather than approach it directly.
The LEGO robot with positioning ball used in the final arena
Five of the next seven teams were not able to complete the course within the 3-minute time limit. One of these teams was QED-’12, a team of first-year undergraduate engineers who had been taught to program LEGO by the QED-grad team. Briefly, it seemed that the youngest team in the competition were going to beat their lab demonstrators; however, their robot stopped at the 11th point because they had forgotten to program in the 12th. An important lesson learned! Only the team of PhD mathematicians on Team CCA came close to the time of the QED-grad team with a time of 1 minute and 44.5 seconds.
The last team to go was MatLads, with its leader Richard Peach, a 3rd year undergraduate engineer. MatLads’ robot moved neatly around the course to knock the QED-grad team off the top spot to win by a mere 1.6 seconds!
Paths taken by the fastest two robots (click to see a larger image)
It was an exciting finale to a fun event. The students enjoyed the project-based learning experience and gained some valuable skills to help them in their future careers.
I’ve recently been talking with professors eager to use Cody in the classroom. From these discussions, I’ve learned of seven great reasons to challenge your students with MATLAB practice problems in Cody:
1. Great problems to draw on
There are already over 900 ready-made MATLAB programming problems, in just the first year online. Search for your subject matter of interest. Check back often, as the Community area is growing rapidly.
2. Fits into your workflow
Navigate to Cody problems by hyperlink directly from your Learning Management System (LMS), HTML syllabus page or simply link directly into each Cody problem in email to your students.
Copy the Cody test suite into desktop MATLAB. Let students write their Cody function with the full power of MATLAB, then paste their answer back into Cody to verify correctness. For example, the Times 2 problem could be solved in MATLAB as follows:
times2.m: function y = times2(x)
% Modify the line below so that the output y is twice the incoming value x
y = 2*x;
% After you fix the code, press the "Submit" button, and you're on your way.
end
Running testsuite.m confirms the function passes each test case, hence success.
6. Experiment to see how people try to solve your problems
Draw on the MATLAB Central community to confirm your Cody problem challenges exactly the skills you want students to learn. We offer you a large population of MATLAB experts eager to try out the latest MATLAB programming puzzle. Use the Solution Map to see outlier attempts, to better understand how your students could react before offering the practice problem in class.
7. Identify learning gaps
Using the solution map, keep an eye across multiple problems from the point in time you’ve offered in class. Compare these across problems to identify subject matter areas meriting more lecture coverage. For example,
Problem 7: Column Removal
shows a cluster of incorrect attempts worth exploring. You’ll quickly see which topics need follow-up coverage in class.
I’ve also prepared a five minute video to demonstrate the above points. Please let me know how you’ve found Cody helpful.
As Product Manager of MATLAB Central, Bob helps MathWorks hear a collective voice of the community to uncover and address what’s needed most. Please reach out to me at bob.levy(at)mathworks(dot)com with feedback and suggestions.
This week I’d like to introduce guest blogger Joachim Schlosser. Joachim leads the team of Education Technical Specialists in Europe, supporting professors and teaching staff using MATLAB & Simulink in education. His mission is to serve development organizations, universities, professors and engineers in all stages of their career to best leverage their proficiency by finding out what kind of methodology and tools are of greatest use for them. You can find Joachim on Twitter, LinkedIn and Google+.
Dancing in the Spotlight
by Joachim Schlosser
I love trade shows and conferences, because you get the opportunity to speak with people creating very different things all on one day. The Embedded World trade show, held each year end of February in Nuremberg, Germany, is such an event. Every time it is amazing to see the breadth of topics that people approach us on, and it is fun to discuss and find out which of our tools around MATLAB & Simulink can make them successful.
Dancing: Enter Anna.
People might stop because they see our hostess Anna making the cute little Nao robot dance, but they come into discussion because they get the vision about what they could achieve themselves. What they see on the booth is just a catalyst for people’s own insight and needs, just a starting point to evaluate which tools serve best their applications.
Photo courtesy Joachim Schlosser.
Movement: Enter John.
Enter booth visitor John (not his real name) from Ynapmoc, Inc. (not his real company), a small to mid size manufacturer with 40 years of experience in the area of medical devices (not his real industry). When he approached me, he said he stopped because he noticed we somehow analyze the real picture data, and he was curious to find out more. He then found yet another demonstration in the booth where a Simulink model made an Arduino board with a webcam track and follow a colored ball. Think of it as a stripped down version of this one, but you get the idea.
Now the reason John was curious is because they are abstracting movements of people filmed in their lab to detect anomalies in their muscle tissue functions and provide a self-assessment tool (not his real application). They had been coding it by hand, with little possibility to do fast prototyping, and with additional effort to adapt the functionality each time they got another camera, each time they have another idea to make the algorithm better. To see that he could do video processing in Simulink was a relief to him, since he knew it from his engineering studies. To see additionally that he could real-time prototype on a low cost Arduino board made John enthusiastic.
Grid stability: Enter Lynn.
Enter Lynn (not her real name), engineer from Sunshine Corp (not her real company), who works on electrical energy generators used in production plants as backup to the regular power grid (not her real application). She had seen our offerings around simulating electrical systems and wondered whether this would not just work for simulating an isolated device but the production plant’s power grid as a whole.
Well, it’s not just possible to simulate an entire plant’s grid, Transpower from New Zealand went a bit further and simulated the entire national grid. They do this to calculate the reserve they need to provide in order to maintain grid stability. So, Lynn has made her next step in solving her challenge, discussing the scenario with one of our Application Engineers to find out the exact needs and a plan for implementing the solution.
Now what if you combine both, image processing and control?
3D Imaging: Enter Nao.
Enter Nao (its real name) from Aldebaran (its real company). Nao is the little robot from the beginning of this story. Think of movement. Think of control theory. Think of feedback control. Think of Simulink. And now attach Microsoft® Kinect® with its support in MATLAB & Simulink, one of the many hardware resources for project-based learning. Kinect provides a 3D image of a person, which is transformed into a mesh in MATLAB & Simulink, allowing it to calculate trajectories for the robot. The rest is normal control system theory with Model-Based Design.
You get: A dancing machine being able to mimic movements of a human. A lot of fun in the realms of engineering, science, commercial and education developments, controls, video, data analysis. And lots of nice discussions with bright people of different disciplines who either are already using MATLAB & Simulink or are exploring their way into doing so. To live and breathe their art.
2012 was an eventful year for MATLAB Mobile, with releases for the iPad, the Android platform, and several enhancements to graphics and usability.
To kick off 2013 on a high note, we are making connecting to the cloud even better.
Introducing… MATLAB Cloud Storage
You can now upload MATLAB files and data to MathWorks Cloud and run them from MATLAB Mobile. You can also download your files from the cloud and save them to your computer.
To upload your files, navigate to the MATLAB Cloud Storage page at https://www.mathworks.com/mobile/cloud-storage.html. To access this page, you will need to have a valid MathWorks Account associated with a license that is current on maintenance. You will also need to have created a user ID on MATLAB Mobile.
Once your files have been uploaded, you can execute them from your mobile device running MATLAB Mobile. For more information, please refer to Store MATLAB files on the cloud.
But wait, there’s more!
- When you connect to MathWorks cloud, you can now access all your licensed MathWorks products.
- We’ve also added a customized keyboard for the Android platform, making it easy for you to enter MATLAB commands without having to switch between multiple screens. The keyboard provides easy access to commonly used MATLAB characters like parenthesis, indexing operators, arithmetic operators and the like. You can also access previously entered commands with the touch of a single key. Tapping and holding on selected keys displays additional characters. For instance, a long tap on the ‘.’ key displays the list of characters in blue.
- MATLAB Mobile for iOS now supports iPhone 5 and iPad mini.
To download the latest version of MATLAB Mobile, visit the App Store or Google Play.
With cloud storage, what files are you running from your mobile device? How is the new Android keyboard helping you? Leave us a comment here with your thoughts.
Because of the amount of traffic that it gets, Cody generates a tremendous amount of interesting data every day. Most of it gets silently stored, because we haven’t found good ways to reflect it directly in the application yet. I decided it was time to try out some Javascript visualization techniques on the data. This is the result: Cody Data Visualizer.
Go play around with it and tell me what you find. Shown above is one view: author ID vs. problem ID. It shows patterns of how problem authors contribute. The size of the dots is relative to the number of comments on the problem. That horizontal stripe across this middle at around author_id = 3000 is super contributor (and current Cody front runner) Richard Zapor, who has single-handedly contributed 122 problems!
This tool loads a relatively large (200 KB) data set when it starts up, so please be patient as it loads! Also, please note that this is an experimental tool that works with an archived static data set from February 8, 2013. It won’t reflect changes in Cody after that date.
One of the virtues of a good programmer (as observed by Larry Wall) is laziness. Don’t write code that you don’t have to! In this spirit, the File Exchange is a boon to the lazy. Whenever you sit down to code, listen to the voice that says “someone must have written this already.” Because it’s probably good advice. Sometimes you’ll find exactly what you need on the File Exchange. Done! Other times you might find something that’s close to the right thing, but not quite. In those cases, consider taking what you find and adapting it to your needs… and then consider resubmitting your adapted code to the File Exchange.
It may feel like cheating at first, but the File Exchange has a mechanism to let you acknowledge the person (or people) that you borrowed code from.
When you submit a file to the File Exchange, you come across a section called “License and Acknowledgments.” This gives you a place to mention the other files that helped you create yours, either because you borrowed code from them or because you just want to publicly acknowledge your appreciation of their influence.
Of the more than 17,000 files on the File Exchange, there are 2910 separate acknowledgments like the one mentioned above. In one way or another, 2050 files acknowledge their debt to a total of 1870 inspiring files. If you think of each one of these acknowledgments as a pointer from the inspiring file to the inspired file, then the whole site can be thought of as a directed graph. Consider the example above. The inspiration doesn’t stop with Douglas Schwarz’s file. That one went on to inspire others. Here’s a look at the acknowledgment tree.
In this picture, each box is a different submission labeled with the author’s last name. Isn’t that lovely? It’s exciting to see the “footprints” of good ideas as they move through the site.
These patterns of acknowledgment can be extensive and visually striking. Some of the trees are deep and some are wide. Here’s a wide one that starts with Oliver Woodford’s exportfig.
With our link data, we can figure out which is the single most influential file in terms of link count. And the answer is… one of the oldest files on the site from Christophe Couvreur. Take a look at how wide this one is.
The largest fully-connected subnet of files has over 200 files in it, all of them connected to each other through a series of links, each link a thoughtful token of respect.
If we go from a file-centric to an author-centric view, we can determine the most influential authors. Who has the most acknowledgments considering all the files they submitted (we ignore self-linking for this analysis). In other words, which authors are the most influential?
These people are heroes of the MATLAB Community. They have freely given, and we have all benefited.
I want to see your name on this list!
Let’s say you agree. Let’s say you’re ready to let people start building on your code. How do you start? Paradoxically, a good way to start is by borrowing someone else’s code. You’ll learn good coding practices by borrowing from the best, and you’re likelier to build something worth borrowing by standing on the shoulders of others. You’ll also be bound more deeply into the community. And soon you’ll see how satisfying it is to have someone use your code as a springboard for something wonderful that never would have occurred to you. So give by taking. You’ll be surprised how far it gets you.
In my last post I wrote about English football. This time I'm talking about the American version. Here in the U.S. it's playoff season for professional football, and that means greasy food, beer, big-screen televisions, and football squares.
And what are football squares, you may ask? It's a simple mechanism to let a group of people wager on the outcome of a ballgame. Consider the following plot.
a = invhilb(10)<0;
% Why invhilb? See this Cody problem:% http://www.mathworks.com/matlabcentral/cody/problems/4-make-a-checkerboard-matrix
tick = 0:9;
imagesc(tick,tick,a)
colormap([1; 0.8]*[1 1 1])
set(gca, ...'XAxisLocation','top', ...'XTick',tick, ...'YTick',tick)
axis square
xlabel('Last Digit of Team A''s Score')
ylabel('Last Digit of Team B''s Score')
It has 100 small squares in it, each one corresponding to a pair of one-digit numbers. These one-digit numbers, in turn, correspond to the last digit in the final score of one of the two teams. Before the game, everyone buys one or more squares until they've all been sold. Now, if the Alligators (team A) go on to defeat the Buckaroos (team B) 17-10, then the owner of the square at location (7,0) would be the winner.
As you can imagine, some score pairs are much more likely than others. For this reason, in practice the squares are usually sold off at random. You don't get to pick which score pair you will receive.
All this sets the scene for a Super Bowl party from a few years ago. The Green Bay Packers were playing the Pittsburgh Steelers, and I had acquired a square. But not just any square. My square was linked to the score pair (2,2).
This struck me as a rare score pair. But how rare? Being quantitatively minded, and armed with my favorite technical computing tool, I went looking for data.
A little web searching turned up a site with every single NFL football game played since 1920, nearly 15,000 games. A savvy reader may observe that the game has changed a lot during that interval. Nevermind that! Let's do the calculations and see what we get.
Get the Data
First grab the HTML.
url = 'http://www.pro-football-reference.com/boxscores/game_scores.cgi#game_scores::none';
html = urlread(url);
Regular Expressions to the Rescue!
By carefully examining the structure of the HTML, we can make a regular expression target that will extract the information we need.
Armed with the textual data from the HTML, we can insert it into a matrix with counts for all the possible outcomes.
score = zeros(100);
oneDigitScore = zeros(10);
for i = 1:length(tk)
winning = str2num(tk{i}{1});
winningMod10 = mod(winning,10);
losing = str2num(tk{i}{2});
losingMod10 = mod(losing,10);
game_count = str2num(tk{i}{3});
% 100-by-100 score grid with actual final scores
score(winning+1,losing+1) = game_count;
% 10-by-10 score grid with mod 10 final scores
oneDigitScore(winningMod10+1,losingMod10+1) = oneDigitScore(winningMod10+1,losingMod10+1) + game_count/2;
oneDigitScore(losingMod10+1,winningMod10+1) = oneDigitScore(losingMod10+1,winningMod10+1) + game_count/2;
end
Compute the Probability Matrix
Calculate percentages based on the total number of games and visualize the results.
prob = oneDigitScore/sum(oneDigitScore(:))*100;
imagesc(0:9,0:9,prob)
colormap(summer(64))
colorbar
set(gca, ...'XAxisLocation','top', ...'XTick',tick, ...'YTick',tick)
axis square
xlabel('Last Digit of Team A''s Score')
ylabel('Last Digit of Team B''s Score')
Just to be safe, let's verify that the sum of the probability matrix is 100%.
fprintf('Sum of all probabilities (percent): %2.1f\n',sum(prob(:)));
Sum of all probabilities (percent): 100.0
Add Numbers to the Plot
No surprise: the likeliest outcome is the pair (7,0) or (0,7). What about (2,2)? It's looking pretty grim. Let's throw some numbers on the plot to find out.
colorbar off
[rows,cols] = size(prob);
for i = 1:rows
for j = 1:cols
text(j-1,i-1,sprintf('%1.2f',prob(i,j)),...'FontSize', 8, ...'Color','red', ...'HorizontalAlignment','center');
endend
set(gca,'XAxisLocation','top')
xlabel('Last Digit of Steelers Score')
ylabel('Last Digit of Packers Score')
patch([2 3 3 2 2]-0.5,[2 2 3 3 2]-0.5,'red', ...'FaceColor','none','LineWidth',2,'EdgeColor','yellow')
patch([5 6 6 5 5]-0.5,[1 1 2 2 1]-0.5,'red', ...'FaceColor','none','LineWidth',2,'EdgeColor','yellow')
Ouch!
The Bottom Line
All this is a long-winded way of saying that my pick, (2,2), is the absolute worst possible choice. Since the merger in 1970, there have been exactly two games that ended with (2,2). On December 5, 2004, the Buffalo Bills beat the Miami Dolphins 42-32, and on November 4, 2012 the Tampa Bay Buccaneers defeated the Oakland Raiders by the same score.
Incidentally, the actual winning result for Steelers-Packers Super Bowl, (1,5), is also quite rare. Rare as these things go, but still eleven times more likely than (2,2).
Not that I'm bitter about it.
Addendum
LATE ADDITION: In the comments below, Sean and Matt banter about soccer scores and the Football Squares game. Here is the plot that results from English Premier League games (partial season). Numbers shown are percentages.
Recent Comments