We use the git source code control system for the robot code and gerrit for code review. You can browse the git code repository by going to https://robotics.mvla.net/gerrit and using your team svn account credentials. Log in to gerrit and add your name and email address to your account. Then, have Austin or Brian add you to the '971 Software Developers' group. Ask one of them to do this at a team meeting or email them. If you don't see the 971-Robot-Code project on gerrit, then you have not been added to the '971 Software Developers' group.
Here's a list of some basic terminology related to the code which is helpful for gaining a basic understanding.
Late breaking news on the build system. I don't know how this works with all of the material below, but I do know that it is important.
2015-11-01: Building code with Bazel + Jessie - From Brian
Ben Fredrickson short cheat sheet of commands is:
<text> means you should type something specific here
Get the code on a new computer:
git clone https://<username>@robotics.mvla.net/gerrit/971-Robot-Code
If you get an "error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://<username>@robotics.mvla.net/gerrit/971-Robot-Code/info/refs" error, turn off GNOME Keyring control with
unset GNOME_KEYRING_CONTROL
You can put this in your ~/.bashrc file if you want to.
If you get "error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://michael@robotics.mvla.net/gerrit/971-Robot-Code/info/refs" error, you can turn off SLL certificate verification for GIT by using
export GIT_SSL_NO_VERIFY=1
This can be put in ~/.bashrc if you want.
Before making any changes in the code, make new branch to work on:
git checkout -b <username>/<project title>
The project title can be anything you want. It is local to your copy of the git project.
Add your new and changed files:
git add <list of file names>
Commit changes locally:
git commit -m "<project title>: <description>"
Push your changes to the server for backup and sharing:
git push origin HEAD:unreviewed/<username>/<project title>
To get these changes from the server to work on,
git fetch origin unreviewed/<username>/<project title>
git co FETCH_HEAD
git checkout -b new_branch_name # where new_branch_name is whatever local name you want to give this branch.
Make sure your master is up to date and you are on your branch.
git co master
git pull origin master
git co -
Rebase all your changes onto master:
git rebase -i master
Here you should squash all your commits into a single commit for review. In the menu that pops up change all the commit line to "squash" except the first line which should be left as "pick".
Now push your commit for review:
git push origin HEAD:refs/for/master
If this works you are done.
If the following command is in the error:
gitdir=$(git rev-parse --git-dir); scp -p -P 29418 <username>@robotics.mvla.net:hooks/commit-msg ${gitdir}/hooks/
you can use it if the network you are on will allow port 29418 access to the school. If it does not work, then run this one instead:
gitdir=$(git rev-parse --git-dir) && curl --insecure -u <username> -o ${gitdir}/hooks/commit-msg https://robotics.mvla.net/gerrit/tools/hooks/commit-msg && chmod +x ${gitdir}/hooks/commit-msg
The first one works for anybody who has a gerrit account and the scp part of the command connects to the gerrit ssh server on port 29418. Port 29418 is not available on some corporate networks and the NASA guest network so use the second option with https for those networks. Jack opened port 29418 for the team to use to on February 7, 2015.
Then run:
git commit --amend
And try the push again:
git push origin HEAD:refs/for/master
Adding changes to existing code review: (TODO this part is incomplete. git rebase master again?)
git checkout <your branch that is in review>
Make your changes.
git add <files>
git commit --amend
git push origin HEAD:refs/for/master
Brian gave me the following command as I was trying to change code on the robot and needed to do a git update.
`git add` any changes you want to keep, then `git stash --keep-index`
Checking out the latest code
Ask Brian or Austin what code you should be using. They will give you a link like
https://robotics.mvla.net/gerrit/#/c/336
Browse to that link and click on the "Download" tab in the upper right hand corner of the page. Then copy the downlaod checkout command by clicking on the copy to clipboard icon on the right. Paste that into your linux terminal. This will "fetch" the version you want and checkout the code.
The outstanding changes can be viewed on Gerrit here.
Building the code
From the top level, run build.sh to compile the code for your laptop running amd64 and the roboRIO running arm.
frc971/prime/build.sh
Running the code on the robot
Parker and Michael suspect that you run
frc971/prime/build.sh deploy
to copy the code to the robot. We think there might be some options to choose which robot to compile and download code to. Once the code is deployed, the robot will restart itself If the "Robot Code" light on the driver's station turns red, reboot the roborio (that's a known issue that Brian will work on some time).
If the code does not start up when the robot is turned on, Austin says "You need to run the frcEnableTBLStartupApp.sh
script in /usr/local/frc/bin". It will enable starting code when the robot is turned on.
"Then copy the aos/config/robotCommand script to /home/lvuser"
The robot code can be started by hand with:
ssh admin@roboRIO-9971.local PATH=$PATH:robot_code starter_exe robot_code/start_list.txt
To restart the robot code run:
touch /home/admin/robot_code/core
Running the code
Create a fresh log file on the robot with
touch ~/robot_code/binary_log_writer
Use this to rebot the robot:
shutdown -r now
Commands for looking at the robot logs
cd /media/sda1 # Use "mount" to figure out where the external USB drive for logs is mounted.
~/robot_code/log_displayer -f -l DEBUG -n fridge | fgrep .Position
# actually, you probably want something from .Status . Depends if you want encoder value, potetiometer value, zeroed value, or something else. I used the following to check the elevator height zeroing. The elevator timing belt teeth are 0.009 m apart (9 mm). Errors in the elevator height that are multiples of this are due to the timing belt skipping.
~/robot_code/log_displayer -f -l DEBUG -n fridge | fgrep .Status
# Use the following to see a list of flags for the log_displayer routine.
~/robot_code/log_displayer --help
~/robot_code/log_displayer -f # Shows the log file.
# log_displayer -f will show you edges on the buttons
# The "-f" says to follow the log file as it is being generated. This is useful for seeing what is going on on the robot as you are view the log file output. If the 2014 shooter is e-stopped, the output will say so repeatedly in the "-f" output.
# If you want to see the current state of the buttons every time it gets read, then run
log_displayer -f -l DEBUG -n wpilib_interface.DSReader | joystick_state
# We use PNY Turbo 64GB USB 3.0 Flash Drive - P-FD64GTBOP-GE for the log files. They cost $20 each.
Working with and Changing robot code
To change the height of the fridge after the robot deposits a stack on the platform or make some other such change. Looking in files like frc971/joystick_reader.cc and/or frc971/actors/score_actor.cc. The first one passes parameters (i.e. the ending height of the elevator) to the score_actor.cc code which uses them to move the robot elevator and arm around.
To be able to connect to the 2015 robot, the router must be running mdns (bonjour) also called zero-conf according to Phil.
The Bonjour Support page says to install it with
sudo apt-get install avahi-daemon libavahi-compat-libdnssd1 mdns-scan
# Use mdns-scan to search the network for devices.
mdns-scan
# Use ssh to connect to the admin user on the robot. The password is blank.
ssh admin@roboRIO-9971.local
# To configure the computer so that the wireless network is the default network, add the line "never-default=true" to the IPV4 section of the file
/etc/NetworkManager/system-connections/Wired\ connection\ 1
Restart the network with
/etc/init.d/network-manager restart
This will put the 10.0.0.10 entry at the bottom of the resolv.conf file:
cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 172.20.253.2
nameserver 172.20.253.6
nameserver 10.0.0.10
I found this approach described in the Setting Default Ubuntu eth port post.
In a pinch, the default route can be set by hand. Check the default route with
ip route default
default via 172.20.252.1 dev wlan0 proto static
10.0.0.0/24 dev eth0 proto kernel scope link src 10.0.0.22
172.20.0.0/16 dev wlan0 proto kernel scope link src 172.20.101.20
Change the default route by deleting it and then remaking it.
ip route del default
ip route add default via 172.20.252.1
Use the following command to set up the eth0 network:
sudo /sbin/ifconfig ethp 10.89.71.20.20 netmask 255.0.0.0
To let Brian login to a laptop that is behind a firewall, run
ssh -R 2222:localhost:22 mich...@robotics.mvla.net -f -N
This will start a connection that will stay active as long as the network stays up. Brian can then login to robotics.mvla.net and connect to his "brian" account on the laptop behind the firewall with:
ssh -p 2222 brian@localhost
It appears that there needs to be a DHCP server running for the networking to work. Parker and Michael were able to do this on 3/23/15 by using the National Instruments Bridge Configuration Utility and setting the SSID to 9971 and the password to Axxxxx15. We set the router to have the same settings using AES only and Wireless N only. The driver station was set to use DHCP too.
This year the NI updates have been reconfigured into a single standalone installer. This means that the FRC Driver Station, cRIO Imaging Tool and other utilities such as the Camera Configuration Tool will all be bundled into a single installer which will not require any components from the DVD. The LabVIEW update is also included in this installer and will install if a LabVIEW installation is detected. To use the DS and Imaging tool all teams must install the 2014 NI Update.
The 2013 FRC Bridge Configuration Tool software to configure your robot's wireless bridge for use outside of FRC events. This WPI page talks about it and tells how to download it. It appears that they are using the 2013 tool for the 2014 season. It said the tool should be in the Start menu, but I did not find it there. I did find it at C:\Program Files\National Instruments\LabVIEW 2013\project\FRC Bridge Tool\FRC Bridge Configuration Utility.exe. When I ran it the first time, it took me to the Java download page and so I installed Java. I made a link to this tool on the desktop.