Running Selenium Webdriver on Bash for Windows

Bash for Windows has been working pretty great for me until I needed to run Selenium Webdriver on it. I quickly learned that it wouldn’t work just work right out of the box, and the set up for it is quite convoluted.

You will need

Bash setup

Install Firefox:

sudo apt-get install firefox

Export DISPLAY variable in ~/.bashrc. Just add this to the ~/.bashrc:

export DISPLAY=:0

Xming setup

Just download it from the link above and run it.

Download geckodriver

Download geckodriver from the link above and put in the /usr/bin/ folder in Bash for Windows.

Running Selenium

Here is a piece of sample Python code I used to setup the web browser. It will setup the browser, open Google, sit there for 10 second and then quit.

import time

from selenium import webdriver
from selenium.webdriver import DesiredCapabilities

def execute_with_retry(method, max_attempts):
    e = None
    for i in range(0, max_attempts):
            return method()
        except Exception as e:
    if e is not None:
        raise e

capabilities = DesiredCapabilities.FIREFOX
capabilities["marionette"] = True
firefox_bin = "/usr/bin/firefox"
browser = execute_with_retry(lambda: webdriver.Firefox(
    firefox_binary=firefox_bin, capabilities=capabilities), 10)




Should you be an engineer?

It’s not easy to decide what career path to take.  Especially for high school students, who don’t yet know what they want to do.  During my time in university, I spent a bit of time in engineering outreach to speak to high school students and first-year university students about studying engineering.

A few days ago, I had the opportunity to go back to my old high school and present to students about studying engineering (link to presentation below), and to help guide them with their career choices.  The idea was to communicate:

  • What engineering is as a profession
  • What engineering is about
  • That they should consider it as a career

At the same time, it wasn’t meant to “persuade” them to study engineering, but more like show them what it’s about so that they can make a more informed decision when they choose their university majors.  I also wanted to tell them this as general advice:

  • Do what you’re interested in
  • Nothing worth doing is ever easy
  • Don’t do it just for the money

Overall, the students seemed to be receptive to what I had to say, and had good questions to ask me about my experiences.  Hopefully, I helped guide them to make a career choice for themselves!

Link to the presentation: here

Valuable Resource for Learning UnrealScript Game Programming

About three years ago, I dabbled briefly in programming for the Unreal Engine (AKA the Unreal Development Kit).  As a student at the time, it was my way to get more experience in the coding scene.  The mistake I made at the time was trying to build a project that was way too advanced for my skill level.   I should have learned the basics.

Looking back, I should have used a book like the “UnrealScript Game Programming Cookbook” by Dave Voyles.  This book is directed towards audiences who have never touched Unreal programming before.  However, it does require readers to have some familiarity with general object oriented programming knowledge.

This book in particular follows a recipe-based approach for teaching the basics of Unreal programming and covers the core topics in programming for UDK.  The recipes are designed to be basic in order to give learners good exposure without too much of a knowledge dump.  Some may argue that having a recipe-based approach doesn’t teach people how to synthesize solutions for themselves.  I see recipes as a good stepping stone.

This book is not meant to teach you everything there is to know about UDK, but enough for people to get started with a good foundation to learn off of.  From the book, I would have liked to see more details about the nuances of the UnrealScript language, as well as a more big picture view of how all the different topics illustrated in the book fit together – perhaps a chapter dedicated to that.  The way it is organized right now is that the big picture is explained, but the explanations are scattered throughout the book.  I am someone who much prefers a more top-down approach on topics like this.

In any case, this book is still a great resource for learning Unreal programming and I would recommend it to people who would like to start their learning adventure in UDK.  Here is a sample chapter of the book for those who are curious in seeing for themselves what this book has to offer (here).  For more information about the book, click here.

RoboCup 2013 in Eindhoven

After a year of hard work redesigning our soccer robots, it was time to take them to the real competition.  Last year, the team went to Mexico City, but this year, we went to Eindhoven, Netherlands to compete. The event was so well known, that even the queen of the Netherlands paid a visit to the competition!

We had spent a whole year upgrading everything.  I designed a new ball kicking system that was more durable, more maintenance free, and more powerful than the year before.  The other mechanical systems were more robust as well.  The electrical system also had a huge upgrade.  Burning and smoking electrical boards were a thing of the past!  We have never had a design this robust – ever!

What is RoboCup?

For those who don’t know what RoboCup is, RoboCup is an international robotics competition aimed to further robotics research.  Their long-term goal is to have robots beat the World Cup Soccer team winners by 2050. There are various leagues within RoboCup, such as in robotic soccer (where we participate), home care, rescue, simulation, etc.  Our team, the UBC Thunderbots, compete in the small-size soccer league, which is probably has the fastest game play of all the different leagues.  The robots are generally cylinders with a diameter of about 18 cm and a height of 15 cm.  They can move at around 4 m/s and kick a golf ball at 8 m/s.

One of the other leagues, the Standard Platform League competes with standardized robots for all teams and the key difference between each is the software that is written for the robots.

Another league, the mid-size league in RoboCup Soccer competes with robots that are about a 1/3 of the size of a person. The game isn’t as quick as the small-size league game and they play with a real soccer ball instead of a golf ball. During the competition, it gathered quite the crowd too.

Preparing for the Games

Most teams arrived at the venue when it opened to get to work right away. Everybody wanted their robots in tip-top shape. Our team did the same. Even though our robots were ready mechanically and electrically, the key game changer was seeing which team had better artificial intelligence for their robots. Whenever got time to test on the field, we took advantage of it to make sure our AI was working well too.

Round Robin

In the round robin stage, each team gets four games against other teams in their bracket. Each bracket is made up of five teams and the skill level is spread out based on the rankings of the previous year.

We lost our first two games against a team called KIKS from the Toyota National College of Technology in Japan, and a team called STOx’s from the Universidad Santo Tomás in Colombia. In both of those games, we were simply outplayed because the other team had better software than we did. At the end of the game against the Japanese team, I spoke a bit of my horrible Japanese to them and they were super surprised and impressed that I knew a bit of Japanese!

Because our robots were finished not long before the competition began, the software team did not get a chance to test the code that was written, and so we found out the problems during the competition. Our robots were never able to drive up to a ball and take possession of it. The robots somehow always missed the ball. When the robot had the ball, it didn’t know what to do with it. It sat there holding onto the ball doing nothing. This was so frustrating for our team and even more so for the software team who wished they had more time to test.

We won our next two games against two lower tier teams. One is called RoboFEI, from the Centro Universitário da FEI in Brazil, and a team called RFC Cambridge from Harvard and MIT. It’s nice to be able to say that we beat a team from these two ivy league schools. Looks good when we look for sponsors too!

Lucky Loser Round

Because we had a 2-2 record during the group stage, we played a fifth game, the so-called Lucky Loser Round, to see if we could qualify for the quarter finals. Our match up was against a team called ODENS from the Osaka Electro-Communication University in Japan.  The game was so close that there was a dispute about the rules and whether what our team did was legitimate. Because our robots were not able to move up to a ball and shoot it at the net during the shootout, the referee introduced a workaround that the other team disputed.

Our referee’s native tongue was Portuguese, we spoke English, and the other team spoke Japanese. I didn’t know enough Japanese to translate. Eventually, members from other teams like the Thai and Chinese team came to help with the dispute. During the discussion that took about an hour, I heard people speak English, Japanese, Portuguese, Thai, Japanese, and Mandarin all at the same time. It seemed like nobody had the full picture of what was happening and how to resolve it.

The dispute was resolved when both teams agreed to a specific workaround that made it possible for our robots to do shootouts.  The game ended with a shootout and we lost on the very last shot of the shootout unfortunately. We almost made it to 8th place.  Still, achieving 9th place out of 22 teams was the best that the team has ever done before.

The Competition Ends

Skuba, from Kasetsart University in Thailand, had won the competition for four years in a row since 2009, but this year they had a surprising finish that was not even the top 4.  The second place team, ZJUNlict from Zhejiang University in China had beat them early in the quarterfinals.  ZJUNlict’s strongest opponent this year was CMDragons, from Carnegie Mellon University in USA.  In the final round, they were tied for the entire game and the game went to shootouts where CMDragons lost by one goal.  ZJUNlict had made first place in the RoboCup 2013 in the Small Size League.

As the competition came to a close, we said goodbye to the people on other teams that we met and as a parting gift from the German team ER-Force, they gave us a German flag with the names of all their team members signed onto it, with the message, “for our amazing friends, the Thunderbots, from team ER-Force”.

I realized now that the competition is over, I probably wouldn’t be going to competitions in the future because I’ve graduated from university. It made me feel a little bit sad that I couldn’t compete anymore, but at least I can still help out the team wherever they need it.

Link to photo album here

RoboCup Workshop in Mannheim

After two weeks of travelling in Europe, the next part of my journey was to participate in the RoboCup competition.  The team that I am part of, the UBC Thunderbots, would be participating in the RoboCup 2013 competition in Eindhoven.  But before that began, we spent a few days in Mannheim play a few games with two of the German teams: ER-Force from the Friedrich-Alexander University in Erlangen and the Mannheim Tigers from the Duale Hochschule of Baden Württemberg.

This gave us a lot of opportunities to find out what was wrong with our robots before the real competition began. We found out that are mechanical and electrical systems were quite robust, while our software system was the weakest link of the three.

In the downtime, we were taken on a tour of the nearby Eichbaum Brewery. The tour was quite difficult to follow because it was pretty much all in German. Even though I had learned some German, it was still quite difficult for me to follow.

I had been to Mannheim before and both times I went to Mannheim before this time, I had a very negative experience. The first time, I got food poisoning (I still remember which restaurant it was), and the second time, my friends and I waited at the Mannheim train station for 4 hours for a train to Berlin with a scheduled departure time of 12am.

Having had lived in Germany before meant I recognized a lot of brands like food chains, department stores, cell phone companies, etc. Because of that, my teammates often asked me different things about Germany such as how German phone plans worked and how to sign up for a plan. I explained it to them and even asked the cashier at the supermarket who didn’t speak English about phone plans.

On another day, we were also taken on a tour to the nearby city of Heidelberg. I had also been here before and vaguely knew my way around. We hiked up to the castle again, but we were there in the evening so the inside of the castle was closed by the time we arrived, so we just went as high as we could.

After spending a few days in Mannheim, all three of the teams organized transportation together to Eindhoven, where the real competition would begin. The workshop allowed us to see what our robots were capable of and what we could improve on early, so that we would be better prepared for the real thing.

Link to photo album here

© 2019 Henry Poon's Blog

Theme by Anders NorénUp ↑