Log in

No account? Create an account
18 June 2013 @ 01:12 pm
Installing the Robot Operating System on a MAC using homebrew  
Because I have just spent a day and a half doing this and I need to vent my frustrations somehow. Also, I will need to do this on my work machine at some point and so I need to type my notes out neatly somewhere while I still vaguely recall what all the increasingly frustrated scrawls actually mean. In theory this might also help others but I suspect that a) the problems were specific to my setup and b) since I didn't save the actual error messages no one will ever find this on a Google.

The below is probably not for the faint hearted, but feel free to come along for the ride and assume actually I didn't know much more about what I was doing than you do.

The Robot Operating System is a generic operating system for robots, it runs on a variety of devices, as well as PCs, and is intended to help people put together functioning robot systems with multiple components that all need to talk to each other. We want to use it in the Reconfigurable Autonomy project as an underlying layer that will support communication between various components while we do fancy stuff on top of involving reconfiguration.

The Robot Operating System (ROS) is fascinating in all sorts of ways. It is a bit of a christmas tree piece of software (i.e., all sorts of shiny baubles have been hung off it). It very widely used, at least in academia, which given it has a reputation for being difficult to install is quite surprising and shows that it doesn't really have any competitors in the open source arena. It is primarily targetted at Ubuntu Linux so I knew before I started that installing it on a Mac was not going to be easy. The fall back plan, incidentally, was to buy a linux box on the grant, but I didn't much want to go back to linux if I could stick with MacOS. I had, in fact, attempted with mixed success, installing ROS on my Mac's earlier this year but this had stalled when my boss decided I urgently needed to spend several weeks writing technical reports. In the meantime ROS brought out a new version that was, allegedly, more Mac friendly. ROS versions all have funky names like electric, fuerte or, in this case, groovy.

So on Monday morning I sat down to install groovy ROS.

There are a couple of systems designed to help people install software on Macs of which MacPorts is the most widely used. In my previous attempt to install ROS, I had had two switch from MacPorts to something called homebrew which delights in an alcoholic metaphor - it has kegs, and bottles, and cellars and you have to tap and brew things. I'm not really sure the metaphor clarifies much but somebody, somewhere, is clearly being kept amused. Groovy ROS advertised that it could be used with either MacPorts or homebrew so I initially started looking to see if I could switch back to MacPorts with which I was both happy and familiar and which never invited me to imagine software as a kind of alcoholic beverage. It seems one does not do this. I could find lots of information online on switching from MacPorts to homebrew but none on moving the other way. I decided I would make do with all the bottles and kegs and pressed on.

I then looked to see if I could uninstall my previous ROS versions and start from a clean slate. It appeared one did not do this either.

So I bravely "tapped" ros/groovy and immediately got some warnings about things that were installed in places they weren't expected to be installed. I decided to assume this wouldn't be a problem and pressed on. In, I think, the last break I had, this assumption proved to be correct.

ROS, the documentation informed me, had two different mechanisms for building the shiny objects (henceforth sometimes referred to as packages) on the ROS christmas tree and I was going to need to use both of them (Oh Joy!). I was to start with "catkin".

I think I spent the next four hours trying to make shiny objects with catkin. I'm 90% sure something was wrong with the mechanism for ensuring everything needed to install packages was present on my PC. During the course of the day I had to install the following: poco, eigen, tiny.xml, uuid, colladadom, assimp, ogre. Luckily, they all installed easily with homebrew, but given the catkin thing took quite a while to run it was a slow process of running catkin, squinting at the error message, installing something and then running catkin again.

I should note here, because it becomes relevant later, that catkin is reasonably intelligent and if a package had already been created, it didn't try to create it again every single time I ran the thing, though it did spend a certain amount of time double checking it had been built.

Eventually I ran into a set of errors that could not, apparently, be solved by installing something new. These revolved around a python library called PyQt4. After a lot of messing around I discovered I was using the wrong version of python, because really early on in the whole process homebrew had tried and failed to install the correct version. I installed python3 which installed quite happily but was also the wrong version. In the end I had to go into the Mac libraries, delete a directory called python2.7 by hand and then reinstall python2.7. Then I had to install pyqt. Then I reran catkin install again.

The next error was actually listed in the troubleshooting section of the installation instructions. My version of yaml-cpp was too advanced and I needed to go back a version. Again this was easy to do via homebrew once I had the magic commands. Then I reran catkin install again.

The next error happened when trying to build something called cv_bridge - this was also mentioned in the troubleshooting section, but it was a different error. Google came to my rescue (via answers.ros.org (which proved an absolute lifesaver several times)). It turned out my version of cmake was also too advanced. I had a suspicion this was pretty serious since cmake was being used to create all sorts of stuff and I had a hunch changing my cmake version was going to have knock on effects. I was not wrong. I tried running catkin with a flag --force_cmake but... errors.

Eventually I had to delete everything and start over from scratch. Yippee!

I spent most of monday afternoon faffing around unnecessarily with header files for something called collada (copying them from some source files I had found for collada into the directories for a ROS package called collada_parser), until I figured out that it would all be sorted out if I... installed colladadom (which I'd done but it hadn't appeared to help), deleted everything and started over from scratch.

The next error was also listed in troubleshooting (Yay!) but to find the solution I was directed to a Git Pull Request - so thank goodness that working for DreamWidth has given me some experience reading those things. I modified the relevant setup file accordingly.

At this point, give or take a couple more delete everything and start overs so that libraries would be picked up correctly, catkin finally successfully completed! Yay!

Onto method two for building ROS shiny things. This was called rosmake. However before I could run rosmake I had to run a few simple programs, known as shell scripts. I googled the ensuing error and found another ROS answers page. This one was really scary since most people recommended installing a new version of bash. Bash underpins a lot of what I do, not just on ROS, and I wasn't exactly excited at the prospect of messing around with it. Fortunately, down the bottom of the page someone said "or change this one line in the shell script". So I did that.

I then encountered, in no particular order, problems 14-16 in the troubleshooting section of the installation instructions. Which involved everything from editing set up files, to installing newer versions of certain bits of ROS from github. I deleted everything, started again from scratch, making sure I edited the various setup files as necessary. This happened enough times that I now have copies of most of the edited set up files to save myself the endless editing effort.

Then I decided that supper needed to be cooked and gave up for the day.

Moving on to this morning. I deleted everything and started from scratch again, just to make sure I was on a clean slate.

The build was still failing and it was failing with error 16 from the troubleshooting section, but this time the error was occurring in a different package from those mentioned on the web page (rviz_plugin_tutorials in case anyone is interested). The fix for this error in other packages involved installing newer versions from github, but that wasn't going to work here because this package didn't have the fix on github. So I then started looking through the discussion on github, and the logs (again grateful that DW has given me some github experience). The fix seemed to involve a couple of edits to some header files, so I made the edits.

For reference I changed

#include <ros/ros.h>

in teleop_panel.h to

#ifndef Q_MOC_RUN
#include <ros/ros.h>

The build process got a bit further but then failed because it couldn't find certain symbols - for the uninitiated header files are often used to declare other libraries used by a bit of code, since I'd removed (sort of) pieces from the header files, the source code now mentioned functions from libraries it didn't know anything about. Cue much head scratching, googling, and experimentation. Eventually I hit upon the idea of telling the system to include these libraries separately, not just mentioning them in the header files. For various reasons this involved editing a set up file called CMakeLists.txt. The magic additional lines I eventually hit on were

find_package(ROS REQUIRED COMPONENTS roslib roscpp rostime rosconsole tf)
find_package(catkin REQUIRED COMPONENTS roslib roscpp rostime rosconsole tf)
find_package(Boost REQUIRED COMPONENTS signals)

include_directories(include ${Boost_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})

and at the bottom of the file

target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${Boost_LIBRARIES} ${catkin_LIBRARIES})

I worked the lines out by looking at CMakeLists.txt files in other packages, and looking at the sort of symbols the compiler was complaining it didn't know about. The rest was guesswork.

I'm not sure all those lines are needed (particularly not the first one) but at this point I was just so happy that the whole thing had compiled that I couldn't be bothered to work out the precise piece of magic that had made it happen.

This left one error when the system tried to build something called simple_navigation_goals_tutorial a bit of googling revealed someone pointing out the package contained a file called ROS_BUILD_BLACKLIST_OSX with the suggestion that that meant no one had ever got this to compile on a Mac. That was good enough for me, I figured I could live without a tutorial on simple navigation goals - assuming that that is what the package was.

Then I stopped for lunch on the second day.

After lunch it was, of course, necessary to see if anything actually did anything. I found the ROS tutorials and started at the beginning.

Shortly I had a turtle:

This is, I should point out, a simulation of a robot turtle. By opening up a new window I could drive it from my keyboard with the arrow keys using a program called teleop_turtle.

I tried to rename the turtle - and everything crashed throwing a Segmentation Fault. Some fruitless googling later, I decided that I could live without renaming turtles.

I then tried to visualise the system (i.e., the teleoperation terminal and the turtle) using something called rqt_graph and got a load of errors complaining about pydot. Pydot it appeared, had not installed, because my version of pyparsing was too advanced. But the internet had the relevant magic incantation. I installed pydot and then visualised my system.

Look the teleoperation is talking to the turtle! OK, so not so impressive but I can imagine this tool is pretty useful if you have more complicated systems of components. Notice there are no labels on several of the buttons - that is going to be fund (some of those buttons are things like "Save this File") - I know because I can see screenshots of this tool as it is supposed to look.

I could even give the turtle a friend.

And I'm done for the day. I shall leave figuring out what to actually do with ROS for tomorrow.

I'm trying to work out of this is the worst installation experience I've been through. It's certainly the worst for at least a decade I should say. I'm moderately impressed that I actually managed to figure my way through to the end of it, although Google, the ROS troubleshooting hints, and answers.ros.org were definitely my friends.

This entry was originally posted at http://purplecat.dreamwidth.org/99625.html.
wellinghallwellinghall on June 18th, 2013 02:34 pm (UTC)
Um *hugs*, and some real beer next time we meet.
louisedennislouisedennis on June 18th, 2013 04:25 pm (UTC)
I'm dithering over whether there should be alcohol this evening...
wellinghallwellinghall on June 18th, 2013 04:30 pm (UTC)
Dithering about this does not entirely tie in with the picture I have of you as a highly intelligent person ... ;-)
louisedennislouisedennis on June 18th, 2013 05:56 pm (UTC)
Well B is away so I didn't particularly want to open anything. I have settled on a wee dram.
wellinghallwellinghall on June 18th, 2013 07:18 pm (UTC)
Oh for the day when G will be old enough to join you.
reggietate: matrixreggietate on June 18th, 2013 04:02 pm (UTC)
You are indeed a computer genius of the highest order :-D
louisedennislouisedennis on June 18th, 2013 04:26 pm (UTC)
Thanks! Though I suspect it would have been easier if I was more familiar with some of the underlying tools.
foradanforadan on June 18th, 2013 04:25 pm (UTC)
Wow, I would have given up long before getting it running, and tried installing it on linux. You don't need to have a separate computer. Ubuntu works fine on VirtualBox (www.virtualbox.org) running on a mac. I have run several things that were difficult to install on mac os that way.
louisedennislouisedennis on June 18th, 2013 04:27 pm (UTC)
Thanks! That's worth knowing since it wouldn't surprise me in the slightest if something vital isn't broken!
athene: wet!connordeinonychus_1 on June 18th, 2013 05:34 pm (UTC)
Wow! My brain is hurting just reading that lot! I think you deserve chocolate, at the very least!
louisedennislouisedennis on June 18th, 2013 05:58 pm (UTC)
Chocolate is an excellent idea! I can't think why I didn't think of it earlier!!
knitekatknitekat on June 18th, 2013 05:41 pm (UTC)
Um, well done for the turtles.
louisedennislouisedennis on June 18th, 2013 05:58 pm (UTC)
The turtles are very cute!