diff --git a/.ci/docker/ubuntu-artful b/.ci/docker/ubuntu-artful deleted file mode 100644 index 5e0a6bde8e623..0000000000000 --- a/.ci/docker/ubuntu-artful +++ /dev/null @@ -1,27 +0,0 @@ -FROM ubuntu:artful - -RUN apt-get update -qq -RUN apt-get install -y \ - sudo \ - build-essential \ - cmake \ - pkg-config \ - libassimp-dev \ - libboost-all-dev \ - libccd-dev \ - libeigen3-dev \ - libfcl-dev \ - freeglut3-dev \ - libxi-dev \ - libxmu-dev \ - libbullet-dev \ - libode-dev \ - libflann-dev \ - libnlopt-dev \ - coinor-libipopt-dev \ - libtinyxml2-dev \ - liburdfdom-dev \ - liburdfdom-headers-dev \ - libopenscenegraph-dev \ - clang-format-3.8 \ - lcov diff --git a/.ci/docker/ubuntu-bionic b/.ci/docker/ubuntu-bionic index e563db667e674..b174e92ff3bd2 100644 --- a/.ci/docker/ubuntu-bionic +++ b/.ci/docker/ubuntu-bionic @@ -7,7 +7,9 @@ RUN apt-get install -y \ cmake \ pkg-config \ libassimp-dev \ - libboost-all-dev \ + libboost-filesystem-dev \ + libboost-regex-dev \ + libboost-system-dev \ libccd-dev \ libeigen3-dev \ libfcl-dev \ @@ -23,5 +25,5 @@ RUN apt-get install -y \ liburdfdom-dev \ liburdfdom-headers-dev \ libopenscenegraph-dev \ - clang-format-3.8 \ + # clang-format-3.8 \ # Disable until higher version is supported lcov diff --git a/.ci/docker/ubuntu-xenial b/.ci/docker/ubuntu-xenial index ee3a43597ff38..d63ea15f508f9 100644 --- a/.ci/docker/ubuntu-xenial +++ b/.ci/docker/ubuntu-xenial @@ -7,7 +7,9 @@ RUN apt-get install -y \ cmake \ pkg-config \ libassimp-dev \ - libboost-all-dev \ + libboost-filesystem-dev \ + libboost-regex-dev \ + libboost-system-dev \ libccd-dev \ libeigen3-dev \ libfcl-dev \ diff --git a/.ci/install_linux.sh b/.ci/install_linux.sh index 5750a50bc31aa..9ed61822c32ce 100755 --- a/.ci/install_linux.sh +++ b/.ci/install_linux.sh @@ -9,7 +9,9 @@ sudo apt-get -qq update APT=' cmake libassimp-dev -libboost-all-dev +libboost-filesystem-dev +libboost-regex-dev +libboost-system-dev libccd-dev libeigen3-dev libfcl-dev diff --git a/.ci/script.sh b/.ci/script.sh index 813050375daa7..cc8cf8a6c3036 100755 --- a/.ci/script.sh +++ b/.ci/script.sh @@ -6,7 +6,7 @@ if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_OS_NAME" = "linux" ] && [ mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DDART_VERBOSE=ON -DDART_TREAT_WARNINGS_AS_ERRORS=ON -DDART_CODECOV=$CODECOV .. if [ "$TRAVIS_OS_NAME" = "linux" ]; then make -j4 tutorials examples tests; else make -j4 tests; fi -if [ "$TRAVIS_OS_NAME" = "linux" ]; then make check-format; fi +if [ "$TRAVIS_OS_NAME" = "linux" ] && [ $(lsb_release -sc) = "trusty" ]; then make check-format; fi if [ $CODECOV = ON ]; then make -j4 codecov; else ctest --output-on-failure -j4; fi # Make sure we can install with no issues diff --git a/.travis.yml b/.travis.yml index ee3ac6abf0ca0..189b25bd418e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,9 +24,6 @@ matrix: - os: linux env: DOCKER_FILE="ubuntu-xenial" BUILD_TYPE=Release CODECOV=OFF COMPILER=GCC services: docker - - os: linux - env: DOCKER_FILE="ubuntu-artful" BUILD_TYPE=Release CODECOV=OFF COMPILER=GCC - services: docker - os: linux env: DOCKER_FILE="ubuntu-bionic" BUILD_TYPE=Release CODECOV=OFF COMPILER=GCC services: docker diff --git a/CHANGELOG.md b/CHANGELOG.md index 156623054007a..08dc248a2e6f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,16 @@ ## DART 6 +### DART 6.5.0 (201X-XX-XX) + +* GUI + + * Added FOV API to OSG viewer: [#1048](https://github.com/dartsim/dart/pull/1048) + +* Simulation + + * Added World::hasSkeleton(): [#1050](https://github.com/dartsim/dart/pull/1050) + ### [DART 6.4.0 (2018-03-26)](https://github.com/dartsim/dart/milestone/39?closed=1) * Common diff --git a/CMakeLists.txt b/CMakeLists.txt index 1497e34a8784d..30db1d910ad18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,7 @@ if(TARGET dart) add_subdirectory(unittests EXCLUDE_FROM_ALL) # Add example subdirectories and an "examples" target. - add_subdirectory(examples) + add_subdirectory(examples EXCLUDE_FROM_ALL) get_property(examples GLOBAL PROPERTY DART_EXAMPLES) add_custom_target(examples DEPENDS ${examples}) @@ -291,7 +291,7 @@ if(TARGET dart) endif(DART_VERBOSE) # Add a "tutorials" target to build tutorials. - add_subdirectory(tutorials) + add_subdirectory(tutorials EXCLUDE_FROM_ALL) get_property(tutorials GLOBAL PROPERTY DART_TUTORIALS) add_custom_target(tutorials DEPENDS ${tutorials}) diff --git a/dart/gui/osg/Viewer.cpp b/dart/gui/osg/Viewer.cpp index aa4c2abcc014c..3696c6370fc28 100644 --- a/dart/gui/osg/Viewer.cpp +++ b/dart/gui/osg/Viewer.cpp @@ -843,6 +843,68 @@ const ::osg::ref_ptr<::osg::Group>& Viewer::getRootGroup() const return mRootGroup; } +//============================================================================== +void Viewer::setVerticalFieldOfView(const double fov) +{ + double fovy; + double aspectRatio; + double zNear; + double zFar; + + auto* camera = getCamera(); + + if (!camera) + { + dtwarn << "[Viewer::setMasterCameraFieldOfView] This viewer doesn't have " + << "any cameras. Ignoring this request.\n"; + return; + } + + const bool result = camera->getProjectionMatrixAsPerspective( + fovy, aspectRatio, zNear, zFar); + + if (!result) + { + dtwarn << "[Viewer::setMasterCameraFieldOfView] Attemping to set vertical " + << "field of view while the camera isn't perspective view. " + << "Ignoring this request.\n"; + return; + } + + camera->setProjectionMatrixAsPerspective(fov, aspectRatio, zNear, zFar); +} + +//============================================================================== +double Viewer::getVerticalFieldOfView() const +{ + double fovy; + double aspectRatio; + double zNear; + double zFar; + + const auto* camera = getCamera(); + + if (!camera) + { + dtwarn << "[Viewer::getMasterCameraFieldOfView] This viewer doesn't have " + << "any cameras. Returning 0.0.\n"; + return 0.0; + } + + const bool result = camera->getProjectionMatrixAsPerspective( + fovy, aspectRatio, zNear, zFar); + + if (!result) + { + dtwarn << "[Viewer::getMasterCameraFieldOfView] Vertical field of view is " + << "requested while the camera isn't perspective view. " + << "Returning 0.0.\n"; + return 0.0; + } + + return fovy; +} + } // namespace osg } // namespace gui } // namespace dart diff --git a/dart/gui/osg/Viewer.hpp b/dart/gui/osg/Viewer.hpp index 817d15272bfd6..47109d99d6c41 100644 --- a/dart/gui/osg/Viewer.hpp +++ b/dart/gui/osg/Viewer.hpp @@ -293,6 +293,15 @@ class Viewer : public osgViewer::Viewer, public dart::common::Subject /// Get the root ::osg::Group of this Viewer const ::osg::ref_ptr<::osg::Group>& getRootGroup() const; + /// Sets the vertical field of view of the master camera of the view. + /// \param[in] fov Vertical field of view in degrees. + void setVerticalFieldOfView(double fov); + + /// Returns the vertical field of view of the master camera of the view. + /// \return Vertical field of view in degrees if the camera is perspective + /// view, 0.0 otherwise. + double getVerticalFieldOfView() const; + protected: friend class SaveScreen; diff --git a/dart/simulation/World.cpp b/dart/simulation/World.cpp index db31e47066f30..51ff870a224ce 100644 --- a/dart/simulation/World.cpp +++ b/dart/simulation/World.cpp @@ -391,6 +391,13 @@ std::set World::removeAllSkeletons() return ptrs; } +//============================================================================== +bool World::hasSkeleton(const dynamics::ConstSkeletonPtr& skeleton) const +{ + return std::find(mSkeletons.begin(), mSkeletons.end(), skeleton) + != mSkeletons.end(); +} + //============================================================================== int World::getIndex(int _index) const { diff --git a/dart/simulation/World.hpp b/dart/simulation/World.hpp index 90e840bede515..026743f3949fe 100644 --- a/dart/simulation/World.hpp +++ b/dart/simulation/World.hpp @@ -149,6 +149,9 @@ class World : public virtual common::Subject /// pointers to them, in case you want to recycle them std::set removeAllSkeletons(); + /// Returns wether this World contains a Skeleton. + bool hasSkeleton(const dynamics::ConstSkeletonPtr& skeleton) const; + /// Get the dof index for the indexed skeleton int getIndex(int _index) const; diff --git a/unittests/comprehensive/test_World.cpp b/unittests/comprehensive/test_World.cpp index f15268343a203..bdbdd22b1b051 100644 --- a/unittests/comprehensive/test_World.cpp +++ b/unittests/comprehensive/test_World.cpp @@ -95,9 +95,16 @@ TEST(World, AddingAndRemovingSkeletons) for (int i = 0; i < nSteps; ++i) world->step(); + EXPECT_FALSE(world->hasSkeleton(skeleton1)); + EXPECT_FALSE(world->hasSkeleton(skeleton2)); + EXPECT_FALSE(world->hasSkeleton(skeleton3)); + EXPECT_FALSE(world->hasSkeleton(skeleton4)); + // Add skeleton1, skeleton2 world->addSkeleton(skeleton1); + EXPECT_TRUE(world->hasSkeleton(skeleton1)); world->addSkeleton(skeleton2); + EXPECT_TRUE(world->hasSkeleton(skeleton2)); EXPECT_TRUE(world->getNumSkeletons() == 2); for (int i = 0; i < nSteps; ++i) world->step(); @@ -119,7 +126,9 @@ TEST(World, AddingAndRemovingSkeletons) // Add skeleton3, skeleton4 world->addSkeleton(skeleton3); + EXPECT_TRUE(world->hasSkeleton(skeleton3)); world->addSkeleton(skeleton4); + EXPECT_TRUE(world->hasSkeleton(skeleton4)); EXPECT_TRUE(world->getNumSkeletons() == 3); for (int i = 0; i < nSteps; ++i) world->step();