UTRA Robosoccer

Software Documentation

08 / 30 / 2018


Meetings

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

People

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

https://drive.google.com/open?id=0B8OHQTLVTR6GTnlfRkFGZk5EQVU

Matlab (Must use Matlab 2018b)

License Number: 40764755

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

Required Addons

https://www.mathworks.com/help/robotics/ug/ros-custom-message-support.html

http://petercorke.com/wordpress/toolboxes/robotics-toolbox

http://petercorke.com/wordpress/toolboxes/machine-vision-toolbox

When your done run initialize.m to set everything up

Other Passwords (Website, Mailchimp, Locker Combos)

https://docs.google.com/document/d/1eJVmYDuQD8JyMIl4DCIleO53GXAQwRqBPCAXFO6W6mQ/edit#

* Please request access from a lead to view stuff

Room

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

http://catkin-tools.readthedocs.io/en/latest/installing.html

Git

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

https://drive.google.com/open?id=0B8OHQTLVTR6GV18ybVBVMEltWkE

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


Git Information

Submodules

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

https://github.com/utra-robosoccer/soccer_ws/tree/master/src

How do do submodules

Add a submodule

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

Update Recursive submodules

git submodule update --init --recursive

Branchesq

There are only 2 branches

Robot is the branch for robots, master is for development

Switch branches

git checkout robot

Pushing

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 '127.0.0.1')

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

<launch>

  <!-- 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)"/>

  </include>

  <!-- 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" />

</launch>



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

https://github.com/utra-robosoccer/soccer-matlab

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.

https://www.mathworks.com/help/robotics/ug/ros-custom-message-support.html

>> 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

70.31.169.157

SSH and VNC into the simulation computer

sudo apt-get install vncviewer

# On one tab

ssh -L 5901:localhost:5901 nvidia@70.31.169.157 # 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

https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.htm

l

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)

https://www.mathworks.com/help/matlab/matlab_external/install-matlab-engine-api-for-python-in-nondefault-locations.html

conda install -n tensorflow matlab_engine


Soccer - Control