From 835767c3abb603908cb38b55670325a3efb8e353 Mon Sep 17 00:00:00 2001 From: Michael Allwright Date: Mon, 6 May 2019 12:35:58 +0200 Subject: [PATCH] Use btStaticPlaneShape for CDynamics3DFloorPlugin Testing shows that btStaticPlaneShape performs better (i.e., it is more stable at lower resolutions) than btBoxShape for the floor. --- .../dynamics3d/dynamics3d_floor_plugin.cpp | 24 ++++--------------- .../dynamics3d/dynamics3d_floor_plugin.h | 6 ++--- .../examples/dynamics3d_magnetism_test.argos | 2 +- .../examples/dynamics3d_multi_body_test.argos | 2 +- .../dynamics3d_single_body_test.argos | 2 +- .../footbot_camera_prototype_example.argos | 2 +- .../examples/prototype_radio_test.argos | 2 +- .../examples/prototype_srocs_system.argos | 2 +- 8 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/plugins/simulator/physics_engines/dynamics3d/dynamics3d_floor_plugin.cpp b/src/plugins/simulator/physics_engines/dynamics3d/dynamics3d_floor_plugin.cpp index 7f14c5ae..6495c893 100644 --- a/src/plugins/simulator/physics_engines/dynamics3d/dynamics3d_floor_plugin.cpp +++ b/src/plugins/simulator/physics_engines/dynamics3d/dynamics3d_floor_plugin.cpp @@ -12,26 +12,12 @@ namespace argos { /****************************************/ void CDynamics3DFloorPlugin::Init(TConfigurationNode& t_tree) { - /* Get the floor height */ - Real fHeight = 0.0f; - GetNodeAttributeOrDefault(t_tree, "height", fHeight, fHeight); - /* Get the arena center and size from the arena node */ - CVector3 cArenaCenter(0.0f, 0.0f, 0.0f); - CVector3 cArenaSize(0.0f, 0.0f, 0.0f); - TConfigurationNode& tArena = GetNode(CSimulator::GetInstance().GetConfigurationRoot(), "arena"); - GetNodeAttribute(tArena, "size", cArenaSize); - GetNodeAttributeOrDefault(tArena, "center", cArenaCenter, cArenaCenter); - /* Configure the floor */ - m_cFloorExtents = btVector3(cArenaSize.GetX(), fHeight, cArenaSize.GetY()); - m_cFloorOrigin = btVector3(cArenaCenter.GetX(), -fHeight * 0.5f, -cArenaCenter.GetY()); /* Get the friction of the floor */ m_fFriction = m_pcEngine->GetDefaultFriction(); GetNodeAttributeOrDefault(t_tree, "friction", m_fFriction, m_fFriction); - /* Call the destructors for the floor components */ + /* Call the destructor for the floor body */ m_cFloor.~btRigidBody(); - m_cFloorShape.~btBoxShape(); - /* Call the constructors for the floor components */ - new (&m_cFloorShape) btBoxShape(m_cFloorExtents * 0.5f); + /* Call the constructor for the floor body */ btRigidBody::btRigidBodyConstructionInfo sConstructionInfo(0, nullptr, &m_cFloorShape); sConstructionInfo.m_friction = m_fFriction; /* Create the floor */ @@ -48,11 +34,9 @@ namespace argos { void CDynamics3DFloorPlugin::Reset() { /* Remove floor from world */ m_pcEngine->GetWorld().removeRigidBody(&m_cFloor); - /* Call the destructors for the floor components */ + /* Call the destructor for the floor body */ m_cFloor.~btRigidBody(); - m_cFloorShape.~btBoxShape(); - /* Call the constructors for the floor components */ - new (&m_cFloorShape) btBoxShape(m_cFloorExtents * 0.5f); + /* Call the constructor for the floor body */ btRigidBody::btRigidBodyConstructionInfo sConstructionInfo(0, nullptr, &m_cFloorShape); sConstructionInfo.m_friction = m_fFriction; /* Create the floor */ diff --git a/src/plugins/simulator/physics_engines/dynamics3d/dynamics3d_floor_plugin.h b/src/plugins/simulator/physics_engines/dynamics3d/dynamics3d_floor_plugin.h index 6a6933b2..d95fd95d 100644 --- a/src/plugins/simulator/physics_engines/dynamics3d/dynamics3d_floor_plugin.h +++ b/src/plugins/simulator/physics_engines/dynamics3d/dynamics3d_floor_plugin.h @@ -19,9 +19,8 @@ namespace argos { class CDynamics3DFloorPlugin : public CDynamics3DPlugin { public: CDynamics3DFloorPlugin() : - m_cFloorExtents(0.0f, 0.0f, 0.0f), m_cFloorOrigin(0.0f, 0.0f, 0.0f), - m_cFloorShape(btVector3(0.0f, 0.0f, 0.0f)), + m_cFloorShape(btVector3(0.0f, 1.0f, 0.0f), 0.0f), m_cFloor(0.0f, nullptr, nullptr) {} ~CDynamics3DFloorPlugin() {} @@ -41,9 +40,8 @@ namespace argos { private: btScalar m_fFriction; - btVector3 m_cFloorExtents; btVector3 m_cFloorOrigin; - btBoxShape m_cFloorShape; + btStaticPlaneShape m_cFloorShape; btRigidBody m_cFloor; }; diff --git a/src/testing/examples/dynamics3d_magnetism_test.argos b/src/testing/examples/dynamics3d_magnetism_test.argos index ffee0313..240c77f7 100644 --- a/src/testing/examples/dynamics3d_magnetism_test.argos +++ b/src/testing/examples/dynamics3d_magnetism_test.argos @@ -57,7 +57,7 @@ - + diff --git a/src/testing/examples/dynamics3d_multi_body_test.argos b/src/testing/examples/dynamics3d_multi_body_test.argos index df83863d..ee08aae9 100644 --- a/src/testing/examples/dynamics3d_multi_body_test.argos +++ b/src/testing/examples/dynamics3d_multi_body_test.argos @@ -91,7 +91,7 @@ - + diff --git a/src/testing/examples/dynamics3d_single_body_test.argos b/src/testing/examples/dynamics3d_single_body_test.argos index a9775097..3250e35c 100644 --- a/src/testing/examples/dynamics3d_single_body_test.argos +++ b/src/testing/examples/dynamics3d_single_body_test.argos @@ -50,7 +50,7 @@ - + diff --git a/src/testing/examples/footbot_camera_prototype_example.argos b/src/testing/examples/footbot_camera_prototype_example.argos index 9cc9ffdf..6e5228e1 100644 --- a/src/testing/examples/footbot_camera_prototype_example.argos +++ b/src/testing/examples/footbot_camera_prototype_example.argos @@ -90,7 +90,7 @@ - + diff --git a/src/testing/examples/prototype_radio_test.argos b/src/testing/examples/prototype_radio_test.argos index 2c2f93a0..b65c5cfe 100644 --- a/src/testing/examples/prototype_radio_test.argos +++ b/src/testing/examples/prototype_radio_test.argos @@ -119,7 +119,7 @@ - + diff --git a/src/testing/examples/prototype_srocs_system.argos b/src/testing/examples/prototype_srocs_system.argos index c6d756d4..c3d91e81 100644 --- a/src/testing/examples/prototype_srocs_system.argos +++ b/src/testing/examples/prototype_srocs_system.argos @@ -352,7 +352,7 @@ - +