-
Notifications
You must be signed in to change notification settings - Fork 0
2015 software.html
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://software.frc971.org/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.
- commit (git) = A snapshot of all of the source code with an author, commit message, data, and some other metadata.
- Commits are commonly refererred to by their SHA1 hash, which is unique for each. These look like 4a644e44e66ec7af982d145cdc861338d02de462 (complete) or 4a644e4 (abbreviated; any unique prefix works most places that want a commit ID).
- repository (git) = A folder with git commits and branches, and possibly a "currently checked out" copy of the code.
- This "currently checked out" version of the code is called a "working tree".
- One unique part of git is that the repository on each person's computer that they work from is
- branch (git) = A "sticky note" referring to a commit.
- Many of the git tools default to your "currently checked out" branch. This means they do things like update it when you make new commits.
- gerrit:master is the branch we generally work off of.
- Each repository has its own set of branches, possibly with overlapping names, so in order to uniquely identify a branch you have to identify the repository it's in too. gerrit/master and gerrit:master are two common ways to do that.
- Branches under the gerrit:/unreviewed/{username}/ namespace are "scratch" branches by each user that have not necessarily been reviewed or anything. These are useful for sharing work-in-progress code.
- patch/diff = The differences between two sets of files.
- This is generally between two commits, often different patch sets of the same change.
- change (Gerrit) = A single logical modification to the code. This will eventually end up as a single commit in the git history.
- A change has one or more patch sets (see below).
- Each change has an ID, which shows up in the commit message for each patch set and looks like I8ee4ac19705aeba179124c44f9b53d53b450ca49.
- They also have a number, which increases by 1 for each new one (like 336).
- Accessible with URLs like https://software.frc971.org/gerrit/#/c/336/.
- patch set (Gerrit) = A git commit (see above) representing a specific version of a change (see above).
- Each patch set for a single change is a whole new version; they do not build on top of each other.
- The change ID needs to be in the message of each commit because this is how Gerrit knows that they are part of the same change.
- Each one has a number which starts at 1.
- You can access a specific one with a URL like https://software.frc971.org/gerrit/#/c/336/8. The version without the last number goes to the latest one.
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>@software.frc971.org/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>@software.frc971.org/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@software.frc971.org/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>@software.frc971.org: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://software.frc971.org/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://software.frc971.org/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 michael@software.frc971.org -f -N
This will start a connection that will stay active as long as the network stays up. Brian can then login to software.frc971.org 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.
- The Installing the 2014 FRC NI Update (for ALL TEAMS) page explains that all that is needed is the NI Update. We don't have to install anything else to program the robot in C++, run the driver station, flash the cRIO, or run the FRC Bridge configuration tool. I installed the NI "FRC 2014 Update Suite, Download Only" only from http://ni.com/frc. Installed it on a Windows 7 machine and it worked fine. Use 00303x87M bkwds.
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 Programming your radio for home use guide shows how to use the 2013 FRC Bridge Configuration Tool software to configure your robot's wireless bridge for use outside of FRC events. b It appears that they are using the 2013 tool for the 2014 season. Somewhere 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.
Here are my notes from installing the FRC software before I figured out that I don't need to install the National Instruments or WPI Lib software (see my notes above).
- Uninstall the 2013 NI and WindRiver software. The NI uninstaller is obvious but the WindRiver one is not. The WindRiver uninstaller has the name "Maintenance Tool" and the WindRiver icon. Some people recognize the icon. If you can't find it, go to Start/WindRiver and use the uninstaller located there.
- Install the "Vision" only half of the NI software from the DVD they sent us in the kit of parts. I installed this software with the computer connected to the internet so that the software key would be validated. Use the software key that is printed on the back of the envelope the software was shipped in. I ran the update tool that came up automatically. I installed the NI "FRC 2014 Update Suite, Download Only" only from http://ni.com/frc. Installed it on Win XP Pro machine and it worked fine. If you only install the FRC 2014 Update Suite without installing the "Vision" software from the DVD, the cRIO imaging tool will see the cRIO and appear to be working but not get past the "Rebooting the cRIO" screen. Again, use the software key that is printed on the back of the envelope that the software was shipped in for the update.
- This WPI lib page has a link to the software update for WPILib Workbench http://first.wpi.edu/FRC/c/update/Release/ . The WindRiver software installs the FRC_2014_v52.zip image in /WindRiver/WPILib/cRIO_Images. I copied it to my desktop. On Aug 23, 2014, I downloaded WorkbenchUpdate20140325rev3887.exe with March 25, 2014 date.
- I set the IP address to the download computer to 10.99.97.201 and the netmask to 255.0.0.0 and turned the firewall off so that the cRIO imaging software would find the cRIO. The imaging tool was able to find the cRIO at 10.99.97.2 with the computer at 10.9.97.201 but could not communicate enough to get set up for the download. It did show the IP address on the cRIO so I was able to reset the computer's network to the same subnet.
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.