# ROS Groovy simulator_gazebo on OSX

Hello everyone,

I am trying to install gazebo in the ROS (groovy) stack (simulator_gazebo), which I believe is still 1.3. I am compiling using clang 3.2 (actually it is based on 3.2).

At first it failed to find TBB and libxml2, which I fixed by adding their .pc files so that pkg-config could find them. Then it complained about -DMACOSX_VERSION not being set, so I added

add_definitions(-DMAC_OS_X_VERSIONS=1080)


In the CMakeLists.txt. After that I believe I had some problems with gazebo using CLOCK_REALTIME, which isn't available on OSX so I replaced that with the OSX equivalent.

I have gotten a long way but now I am stuck with linking dependencies for gazebo_sensors and gazebo_physics. gazebo_sensors depends on gazebo_physics, however gazebo_physics seems to also depend on gazebo_sensors, causing a circular dependency. The dependency on gazebo_sensors for gazebo_physics did not exist, without this I was getting linking errors. Adding this link causes a circular dependency. Removing the dependency on gazebo_physics in gazebo_sensors allows it to compile gazebo_physics, but then it gets stuck with linking errors for gazebo_sensors because it is missing things from gazebo_physics there then.

I also tried compiling with gcc (4.2 and 4.7), but this gave me a whole set of different errors.

I had a similar problem with gazebo_physics and gazebo_physics_ode, gazebo_physics_ode needed to link against gazebo_physics, however gazebo_physics did not need to link against gazebo_physics_ode so I could just add the link to gazebo_physics in gazebo_physics_ode.

What can I try next? I can't seem to resolve the circular dependency that I apparently have. How come this compiles fine on Ubuntu (I assume)? Should I actually be asking this on ROS answers? I tried version 1.4 from gazebosim.org but it seems to give me the same problems.

edit retag close merge delete

Sort by » oldest newest most voted

With pull requests from @Hansg91 and help from William at OSRF, I've made a homebrew formula for gazebo. It's still experimental. To try it:

Install homebrew: ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" Install XQuartz Run the following commands: brew tap ros/groovy brew tap scpeters/gazebo brew install gazebo source /usr/local/share/gazebo/setup.sh gazebo more ## Comments Sounds great :) I don't think you really need XQuartz, you might only need it because somewhere the CMakeLists.txt checks if you have it, its not building against it I believe. ( 2013-04-03 04:58:14 -0500 )edit Works perfectly so far! Thank you so much! I wish I could upvote, but I don't have enough karma for that... ( 2013-04-05 11:17:44 -0500 )edit Has anybody tried getting drcsim to work on OSX by the way? ( 2013-04-05 11:37:10 -0500 )edit XQuartz is needed to build OGRE using the home-brew formula given by the ros/groovy tap. I haven't tried building drcsim yet. There's still a problem with plugins being hard-coded as '.so' files when they're actually '.dylib' files on the mac. Also, it crashes when I insert cameras. So there's still some work left to do. I just started a wiki page to track status on OS X, feel free to add any answers threads to the list at the bottom of this page. ( 2013-04-05 17:32:25 -0500 )edit XQuartz is needed to build OGRE using the home-brew formula given by the ros/groovy tap. I haven't tried building drcsim yet. There's still a problem with plugins being hard-coded as '.so' files when they're actually '.dylib' files on the mac. Also, it crashes when I insert cameras. So there's still some work left to do. I just started a wiki page to track status on OS X, feel free to add any answers threads to the list at the bottom of this page. ( 2013-04-05 17:32:49 -0500 )edit XQuartz is needed to build OGRE using the home-brew formula given by the ros/groovy tap. I haven't tried building drcsim yet. There's still a problem with plugins being hard-coded as '.so' files when they're actually '.dylib' files on the mac. Also, it crashes when I insert cameras. So there's still some work left to do. I just started a wiki page to track status on OS X, feel free to add any answers threads to the list at the bottom of this page. ( 2013-04-05 17:33:10 -0500 )edit XQuartz is needed to build OGRE using the home-brew formula given by the ros/groovy tap. I haven't tried building drcsim yet. There's still a problem with plugins being hard-coded as '.so' files when they're actually '.dylib' files on the mac. Also, it crashes when I insert cameras. So there's still some work left to do. I just started a wiki page to track status on OS X, feel free to add any answers threads to the list at the bottom of this page. ( 2013-04-05 17:33:32 -0500 )edit Well it is very nice to see that you picked up this task, I don't need gazebo anymore at the moment (intended to use it for navigation, but I am using Stage at the moment) but I have no doubt that for some future feature I will need it and be loving it on OSX :) ( 2013-04-08 05:36:24 -0500 )edit Note that these instructions are now out of date. I think the current homebrew steps are: brew tap osrf/homebrew-simulation ; brew install gazebo ( 2014-03-28 15:43:32 -0500 )edit We incorporated the changes from a pull request by @Hansg91 and I've managed to get it compiling on my machine. I used homebrew to resolve most of the dependencies. brew install qt protobuf-c brew tap ros/groovy && brew install ogre tinyxml mac already has a system install of curl, but it doesn't have a pkg-config file. a workaround: brew install curl then add the following to your bashrc (actually called .bash_profile on mac): export PKG_CONFIG_PATH=/usr/local/opt/curl/lib/pkgconfig:$PKG_CONFIG_PATH

then in just needs libtar. i had to install this from source

I've managed to get the code building in branch osx_compile_hack

more

Did you get any further than two windows that cannot be interacted with? ps. I did not need your compile hack commit to compile, why is that?

( 2013-03-15 06:23:48 -0500 )edit

I didn't try to run gazebo; I was just running gzserver, but fails to find all the correct libraries. I think we need to remove references to X11 and glx in RengerEngine.cc and also link against Cocoa so that it will run natively in OSX.

( 2013-03-19 19:22:02 -0500 )edit

Yes that would be a much better solution, but I never worked with Cocoa so I have no idea how to do this, do you? If so, that would be perfect. Do you have the gzserver running by the way? For me it is stuck on Waiting for master, so I run the server on a Parallels Ubuntu and connect to that one ...

( 2013-03-20 03:47:01 -0500 )edit

We experimented with Gazebo on OSX a while back too, but ran out of time. You can enable weak linking as follows: In the top CMakeLists.txt, change

# OS Specific initialization
if (UNIX)
gz_setup_unix()
else (WIN32)
gz_setup_windows()
else (APPLE)
gz_setup_apple()
endif()


to

# OS Specific initialization
if (UNIX)
gz_setup_unix()
else (WIN32)
gz_setup_windows()
endif()
if (APPLE)
gz_setup_apple()
endif()


This is necessary because OSX is considered a UNIX system too!

more

Ok I appear to have resolved this by using static libraries instead, not sure if that is the most elegant solution, but I finally got it to compile at least...

more

Here is all the things I needed to do to get it to compile (not work) for OSX :

Do the change as described by tkoolen

set_property(TARGET ${OGRE_PROJECT_NAME} PROPERTY MACOSX_BUNDLE TRUE)  to the gzaddexecutable macro Add : ${Boost_LIBRARIES}


#if __APPLE__
int isinf( double x ) { return x == x - 1; }
#endif


to gazebo/common/PID.cc

Change the following in gazebo/common/Time.h

 29 #ifdef __MACH__
30 #include <mach/clock.h>
31 #include <mach/mach.h>
32 #include <unistd.h>
33 #endif

49 #ifdef __MACH__
50   clock_resolution.tv_sec = 1 / sysconf(_SC_CLK_TCK);
51 #else
52   clock_getres(CLOCK_REALTIME, &clock_resolution);
53 #endif

98 #ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
99   clock_serv_t cclock;
100   mach_timespec_t mts;
101   host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
102   clock_get_time(cclock, &mts);
104   tv.tv_sec = mts.tv_sec;
105   tv.tv_nsec = mts.tv_nsec;
106 #else
107   clock_gettime(0, &tv);
108 #endif

186 #ifdef __MACH__
187     if (nanosleep(&nsleep, &remainder) == -1)
188 #else
189     if (clock_nanosleep(CLOCK_REALTIME, 0, &nsleep, &remainder) == -1)
190 #endif

216 #ifdef __MACH__
217     if (nanosleep(&nsleep, &remainder) == -1)
218 #else
219     if (clock_nanosleep(CLOCK_REALTIME, 0, &nsleep, &remainder) == -1)
220 #endif


Removed rt from linking library in gazebo/common/CMakeLists.txt

There are some conflicts with generated files and existing files that have the same name but different capitals, which gives conflicts on OSX, therefore you must rename the following files :

gazebo/transport/Transport.hh -> gazebo/transport/Transport.h

Also change in :
gazebo/transport/CMakeLists.txt
gazebo/transport/Transport.cc

gazebo/physics/Physics.hh -> gazebo/physics/Physics.h

Also change in :
gazebo/physics/CMakeLists.txt
gazebo/physics/Physics.cc

gazebo/common/Common.hh -> gazebo/common/Common.h

Also change in :
gazebo/common/CMakeLists.txt
gazebo/common/Common.cc

gazebo/sensors/Sensors.hh -> gazebo/sensors/Sensors.h

Also change in :
gazebo/sensors/CMakeLists.txt
gazebo/sensors/Common.cc

gazebo/rendering/Rendering.hh -> gazebo/rendering/Rendering.h

Also change in :
gazebo/rendering/CMakeLists.txt
gazebo/rendering/Rendering.cc


Add the following include and link directories in the main CMakeLists.txt (perhaps better to place these in the parts that actually need them, got lazy)

 include_directories(/opt/X11/include)


Assuming X11 is located there.

 add_dependencies(gzlog gtest)


Disable gz_log from tools/test/CMakeLists.txt

Change the following line in gazebui/gui/GLWidget.cc

 718 #if defined(WIN32) || defined(__APPLE__)


Replace google::protobuf::FieldDescriptor::TYPE_BOOL with 1 in gazebo/gui/ModelListWidget.cc

But, now I am stuck on segfaults :)

EDIT: Ok, no segfaults, however I can't seem to process any input :( I get two windows of gazebo but nothing happens if I click on them.

more

I have created a branch called osx on bitbucket that incorporates these changes(https://bitbucket.org/osrf/gazebo/commits/5e426ea16079b93e7ffe1c55f996676e123bc0c7). It would be great if you interested parties could work out of this branch. Thanks for the great effort!

( 2013-03-07 10:11:38 -0500 )edit

Well it is good to see my sweat and tears were not for nothing :) I'm not sure how much more time I want to spend on gazebo on OSX though, at the moment I am stuck with 2 gazebo windows who cannot seem to receive any mouse/keyboard input. You can't even click on them to get focus (only on their title bars).

( 2013-03-07 11:38:35 -0500 )edit

Yes, thank you very much for your efforts and for the writeup!

( 2013-03-08 21:45:24 -0500 )edit