UTRA Robosoccer

Software Documentation

08 / 30 / 2018


General Meetings : Saturday 1pm-5pm (Engsci Common Room)


Faculty Advisors:

Jonathan Kelly - Computer Vision

Garbriele D’Eleuterio - Multi Agent Control


Software - Jason Wang

Electrical - Shahryar Rajabazadeh

Embedded - Tyler Gamvrelis

Mechanical/Control - Daniel Campoverde

Control - Lukas Zhornak

Licenses and Information

Google Drive


Matlab (Must use Matlab 2018b)

License Number: 40764755

Activation Key: 69197-16690-22659-16166-09236

Required Addons




When your done run initialize.m to set everything up

Other Passwords (Website, Mailchimp, Locker Combos)


* Please request access from a lead to view stuff


MY 015D

Ubuntu Computer (TX2)

Control Stuff

sudo apt-get install ros-kinetic-joint-state-controller

sudo apt-get install ros-kinetic-controller-manager

sudo apt-get install ros-kinetic-gazebo-ros-control

sudo apt-get install ros-kinetic-ros-control ros-kinetic-ros-controllers

Catkin Tools



Sudo apt-get install git

! Don’t forget to install the CUDA packages from JetPack

! Don’t forget to enable 6 coes (1 cores is by default) https://devtalk.nvidia.com/default/topic/1000345/jetson-tx2/two-cores-disabled-/

Required Learning for different roles

Physical Modelling Work

Autodesk Fusion - https://academy.autodesk.com/software/fusion-360

ROS Tutorials - http://wiki.ros.org/ROS/Tutorials

Gazebo ROS Overview - http://gazebosim.org/tutorials?cat=connect_ros

Control Work

ECE470 - Robot Modelling and Control

ECE311 - Control Systems - Introduction

ECE410 - Advanced Control Systems

All of Physical Modelling Roles

Matlab Physical Modelling - https://www.mathworks.com/academia/student-competitions/robocup.html

Computer Vision Work


VisionWorks (Optional) - https://developer.nvidia.com/embedded/visionworks

Git Information


All submodules must be forked repositories from other people on utra-robosoccer


How do do submodules

Add a submodule

git add http://submodule_url path/to/submodule

Update Recursive submodules

git submodule update --init --recursive


There are only 2 branches

Robot is the branch for robots, master is for development

Switch branches

git checkout robot


git push origin robot OR git push origin master

Using soccer-matlab

You need to ensure you have all of the submodule repositories added in the github desktop. Once you complete an issue, add your summary here. Select your current branch (must be master), and the push to remote.

You need to push all of the submodules (inner repositories first) and then finally push soccer-matlab super repository. This will make soccer-matlab super repository have the latest version of every submodule

Once you are done. Go to the issues section and then close the issue. Congratulations!

Overall System Architecturez

Remember to replace your name with the folder name and the wifi interface with your interface

# Connect ROS

source /opt/ros/kinetic/setup.bash

source /home/vuwij/soccer_ws/devel/setup.bash

# Connect Matlab with ROS

MY_IP=$(ifconfig wlp4s0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '')

export ROS_IP=$MY_IP

export ROS_MASTER_URI="http://"$ROS_IP":11311"

Soccer Workspace

soccer_ws (https://github.com/utra-robosoccer/soccer_ws) is a folder that contains the precompiled libraries such as darknet_ros and gazebo simulations as well as connectivity to the actual robot

The current packages in soccer_ws/src/ are the following

Of these folders, only soccer_control, soccer_description, soccer_gazebo, soccer_hardware and soccer_msgs, and team_communication are written by me.

Robot - Simulation


  <!-- these are the arguments you can pass this launch file, for example paused:=true -->

  <arg name="paused" default="true"/>

  <arg name="use_sim_time" default="true"/>

  <arg name="gui" default="true"/>

  <arg name="headless" default="false"/>

  <arg name="debug" default="false"/>

  <env name="GAZEBO_MODEL_PATH" value="$(find soccer_description)"/>

  <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->

  <include file="$(find gazebo_ros)/launch/empty_world.launch">

    <arg name="world_name" value="$(find soccer_gazebo)/worlds/robocup.world"/>

    <arg name="debug" value="$(arg debug)" />

    <arg name="gui" value="$(arg gui)" />

    <arg name="paused" value="$(arg paused)"/>

    <arg name="use_sim_time" value="$(arg use_sim_time)"/>

    <arg name="headless" value="$(arg headless)"/>


  <!-- Load the URDF into the ROS Parameter Server -->

  <param name="robot_description" textfile="$(find soccer_description)/models/soccerbot/model.urdf" />

  <node name="spawn_soccerbot_model" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"

  args="-urdf -model soccerbot -param robot_description -z 0.05 -Y 1.57"/>

  <!-- ros_control soccerbot launch file -->

  <include file="$(find soccer_control)/launch/soccer_control.launch" />

  <!-- Converts SoccerGoal to Gazebo simulation -->

  <node name="robotGoalToGazebo" pkg="soccer_hardware" type="draw_trajectories" />


Robot - Communication

The soccer_hardware folder contains the nodes folder that contains soccer_hardware.py. Which is a ros node that connects between the robot and the microcontroller

To start the robot’s communication type

roslaunch soccer_hardware soccer_hardware.launch

This is a shortcut to launch the python file that sends ros messages of the type RobotState.msg and RobotGoal.msg back and to the robot. The messages are located in soccer_msgs/msg/RobotState.msg etc

Matlab Workspace

Loading the Matlab Code

All the matlab code is stored in soccer-matlab, It contains the submodules for other repositories


To clone the repository. Or use the github url

Git clone https://github.com/utra-robosoccer/soccer-matlab
Git submodule update --init --recursive

After pulling the repository. Generate the ROS messages (see below)

To push to the repository, if you are on windows. Make sure to add the submodules as separate repositories and changed the current branch from DETACHED to MASTER on the second circle.


>> rosgenmsg('soccer_msgs')

Follow the instructions after that

(Note: If this doesn’t work, try uninstalling and reinstalling custom ROS message support)

Understanding the Matlab Repositories

The 3 matlab projects

Running the Matlab/Simulink Code

Before you do anything run the initialize.m to initialize all the matlab paths

Before you run any matlab/simulink code make sure

For Generating matlab code, you need to be on External Mode, change the above to external, and type in the corresponding ROS information

Soccer Vision

There are currently a file called soccer_vision.slx

Overall Computer Vision block diagram

CoverEdge, Cover Above Horizon - Takes the angle of the camera (from the RobotState) and determines the location of the horizon

We only care about what is below the horizon. Anything in the crowd gets removed, making this much easier

LineDetection - Detects the lines based on a threshold. Uses Prewitt edge detector, followed by a Hough Line Transform (Basically similar to a 2D fourier transform but return angles and distances instead). Followed by a local maxima finder.

Filter - Of the lines we have found local minima and maxima. Merge the lines that are too close to each other using kmeans clustering with the distribution among rho and theta

Track Lines - Does a poor kalman filter of the lines what we find on 2D. Removes the lines that randomly appear on the screen out of nowhere. Smooths out the lines that are already on the field. Also identifies which lines are the field and which are the net lines based off of how straight the lines are

Hough Lines - Premade matlab block that takes rho and theta lines and finds the 2 end points on the line. Prepares to draw them on the screen

map2Dto3D - Takes the robotAngle, CameraAngle, focalLength, robotHeight (d is not used here) and finds the 3D locations of the lines on the field

Find Field and Post Intersections - Self explanatory

PlotPointArray - Makes a matlab plot of the points. Only plots the intersections for now.

(To be done) Match field (Uses iterative closest point in a monte-carlo style to match the points we found using vision with the actual field points). Doesn’t work right now because nothing is calibrated

soccerVision.slx - (The main program that gets exported to ROS)

To switch between getting input from Gazebo and getting input from file, right click on the subsystem ‘From File’ and under Variant->Override using-> select the desired option (Figure).

Soccer Strategy

In soccer strategy there is a simulink file called soccerbot.slx. Inside you have this mess

Robot Decision is stateflow state machine

If it falls to the front and the back, it actives a trajectory using trajAction

The basic steps, no kicking atm. Just looking or the ball and preparing to walk

Motion Planner decides between fixed vs dynamic trajectories vs poses

Here is Lukas’s code. All wrapped up in the BipedalRobotSystemObject block. You just need waypoints and trigger to generate the trajectories

Fixed Trajectories just contain a set of fixed trajectories

In IMU Feedback. It uses the IMU sensor to notice small changes in the orientation of the robot. Decides when you fall down forward and backwards. And makes small adjustments to the poses such as swinging your arms forward and bending your hip in forward-backward control blocks and left-right control blocks

The current trajectory goes into corrected trajectory. And then goes through a final calibration before it gets sent on a bus to be published into the /robotGoal message

Soccer - Reinforcement Learning

VNC connection to the main computer (Optional)

A list of IP addresses is provided in Overall System Architecture. If you want to experiment on my Virtual Machine, use the VM IP address

SSH and VNC into the simulation computer

sudo apt-get install vncviewer

# On one tab

ssh -L 5901:localhost:5901 nvidia@ # with password nvidia

vncserver -geometry <WIDTH>x<HEIGHT> :1

# On another tab

vncviewer :1

If you are not using ubuntu, figure it out yourself

From here on your should be able to view the screen of the simulation computer

Setup Matlab

Follow the instructions here to setup the matlab engine for python



Most likely your using tensorflow (or anaconda) so you are going to be installing in a seperate location. (Build in default folder, install in non-default folder)


conda install -n tensorflow matlab_engine

Soccer - Control