Skip to content

Commit

Permalink
Merge pull request #87 from NASA-Tensegrity-Robotics-Toolkit/NullGround
Browse files Browse the repository at this point in the history
Merging in tgEmptyGround and associated files. Cleanup of comments in the terrain library generally. Closes #86
  • Loading branch information
brtietz committed Oct 8, 2014
2 parents 08e0b93 + eebeb1c commit e65ab57
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/core/terrain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ project(terrain)
add_library( ${PROJECT_NAME} SHARED
tgBulletGround.cpp
tgBoxGround.cpp
tgEmptyGround.cpp
tgPlaneGround.cpp
#tgCraterGround.cpp
tgCraterGround.cpp
tgHillyGround.cpp
)

Expand Down
2 changes: 1 addition & 1 deletion src/core/terrain/tgBoxGround.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ class tgBoxGround : public tgBulletGround
};


#endif // TG_WORLDIMPL_H
#endif // TG_BOX_GROUND_H
7 changes: 0 additions & 7 deletions src/core/terrain/tgCraterGround.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@
* $Id$
*/

/**
* \dir core/terrain
* @brief The terrain library gives terrain options for the world.
*
* Allows for a variety of terrain. As of version 1.0.0, a box ground
* which can be rotated into a slope is supported in tgCraterGround
*/
#include "tgBulletGround.h"

#include "LinearMath/btScalar.h"
Expand Down
49 changes: 49 additions & 0 deletions src/core/terrain/tgEmptyGround.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright © 2012, United States Government, as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All rights reserved.
*
* The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
* under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

/**
* @file tgEmptyGround.cpp
* @brief Contains the implementation of class tgBoxGround
* @author Brian Mirletz
* $Id$
*/

//This Module
#include "tgEmptyGround.h"

//Bullet Physics
#include "BulletDynamics/Dynamics/btRigidBody.h"

// The C++ Standard Library
#include <cassert>

tgEmptyGround::tgEmptyGround()
{

}

btRigidBody* tgEmptyGround::getGroundRigidBody() const
{
btRigidBody* const pGroundBody = NULL;

// This should never be called
assert(false);

return pGroundBody;
}

61 changes: 61 additions & 0 deletions src/core/terrain/tgEmptyGround.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright © 2012, United States Government, as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All rights reserved.
*
* The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
* under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

#ifndef TG_EMPTY_GROUND_H
#define TG_EMPTY_GROUND_H

/**
* @file tgEmptyGround.h
* @brief Contains the definition of class tgEmptyGround.
* @author Brian Mirletz
* $Id$
*/

#include "tgBulletGround.h"

// Forward declarations
class btRigidBody;

/**
* An empty ground implementation. tgWorldBulletPhysicsImpl checks if
* this class is present with a tgCast call, and skips calling
* getGroundRigidBody if it is.
*/
class tgEmptyGround : public tgBulletGround
{
public:

/**
* Default construction that uses the default values of config
* Does nothing
*/
tgEmptyGround();

/** Clean up the implementation. The base class holds nothing. */
virtual ~tgEmptyGround() { }

/**
* This should never be called. Will fail an assertation
* @todo consider making it an exception instead.
*/
virtual btRigidBody* getGroundRigidBody() const;

};


#endif // TG_EMPTY_GROUND_H
7 changes: 0 additions & 7 deletions src/core/terrain/tgHillyGround.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@
* $Id$
*/

/**
* \dir core/terrain
* @brief The terrain library gives terrain options for the world.
*
* Allows for a variety of terrain. As of version 1.0.0, a box ground
* which can be rotated into a slope is supported in tgHillyGround
*/
#include "tgBulletGround.h"

#include "LinearMath/btScalar.h"
Expand Down
7 changes: 0 additions & 7 deletions src/core/terrain/tgPlaneGround.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@
* $Id$
*/

/**
* \dir core/terrain
* @brief The terrain library gives terrain options for the world.
*
* Allows for a variety of terrain. As of version 1.0.0, a box ground
* which can be rotated into a slope is supported in tgBoxGround
*/
#include "tgBulletGround.h"

#include "LinearMath/btScalar.h"
Expand Down
11 changes: 8 additions & 3 deletions src/core/tgWorldBulletPhysicsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#include "tgWorldBulletPhysicsImpl.h"
// This application
#include "tgWorld.h"
#include "tgCast.h"
#include "terrain/tgBulletGround.h"
#include "terrain/tgEmptyGround.h"
// The Bullet Physics library
#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
#include "BulletCollision/BroadphaseCollision/btDbvtBroadphase.h"
Expand Down Expand Up @@ -109,9 +111,12 @@ tgWorldBulletPhysicsImpl::tgWorldBulletPhysicsImpl(const tgWorld::Config& config
// Gravitational acceleration is down on the Y axis
const btVector3 gravityVector(0, -config.gravity, 0);
m_pDynamicsWorld->setGravity(gravityVector);

m_pDynamicsWorld->addRigidBody(ground->getGroundRigidBody());


if (!tgCast::cast<tgBulletGround, tgEmptyGround>(ground) && ground != NULL)
{
m_pDynamicsWorld->addRigidBody(ground->getGroundRigidBody());
}

#if (1) /// @todo This is a line from the old BasicLearningApp.cpp that we're not using. Investigate further
m_pDynamicsWorld->getSolverInfo().m_splitImpulse = true;
#endif
Expand Down
3 changes: 3 additions & 0 deletions src/core/tgWorldBulletPhysicsImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class tgWorldBulletPhysicsImpl : public tgWorldImpl
/**
* The only constructor.
* @param[in] gravity the gravitational acceleration in m/sec^2
* @param[in] ground - a container class that holds a rigid body and
* collsion object for the ground. tgEmptyGround can be used to create
* a ground free simulation
*/
tgWorldBulletPhysicsImpl(const tgWorld::Config& config,
tgBulletGround* ground);
Expand Down
5 changes: 4 additions & 1 deletion src/dev/btietz/boxFeet/AppNestedBoxTetrahedrons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "core/tgSimViewGraphics.h"
#include "core/tgSimulation.h"
#include "core/tgWorld.h"
#include "core/terrain/tgEmptyGround.h"
// The C++ Standard Library
#include <iostream>

Expand All @@ -45,9 +46,11 @@ int main(int argc, char** argv)
{
std::cout << "AppNestedBoxTest" << std::endl;

tgEmptyGround* ground = new tgEmptyGround();

// First create the world
const tgWorld::Config config(981); // gravity, cm/sec^2
tgWorld world(config);
tgWorld world(config, ground);

// Second create the view
const double stepSize = 1.0/1000.0; //Seconds
Expand Down

0 comments on commit e65ab57

Please sign in to comment.