Skip to content

Commit

Permalink
Added Simulation Features (#168)
Browse files Browse the repository at this point in the history
* added features

Signed-off-by: Lobotuerk <[email protected]>

Co-authored-by: Jorge Perez <[email protected]>
Signed-off-by: Jorge Perez <[email protected]>
  • Loading branch information
Lobotuerk and Blast545 committed Feb 12, 2021
1 parent a4f75cc commit e737f60
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 2 deletions.
40 changes: 40 additions & 0 deletions bullet/src/SimulationFeatures.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
*
* 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.
*
*/

#include "SimulationFeatures.hh"

namespace ignition {
namespace physics {
namespace bullet {

void SimulationFeatures::WorldForwardStep(
const Identity &_worldID,
ForwardStep::Output & /*_h*/,
ForwardStep::State & /*_x*/,
const ForwardStep::Input & _u)
{
const WorldInfoPtr &worldInfo = this->worlds.at(_worldID);

auto *dtDur =
_u.Query<std::chrono::steady_clock::duration>();
std::chrono::duration<double> dt = *dtDur;
worldInfo->world->stepSimulation(dt.count());
}

}
}
}
49 changes: 49 additions & 0 deletions bullet/src/SimulationFeatures.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
*
* 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 IGNITION_PHYSICS_BULLET_SRC_SIMULATIONFEATURES_HH_
#define IGNITION_PHYSICS_BULLET_SRC_SIMULATIONFEATURES_HH_

#include <vector>
#include <ignition/physics/ForwardStep.hh>

#include "Base.hh"

namespace ignition {
namespace physics {
namespace bullet {

using SimulationFeatureList = FeatureList<
ForwardStep
>;

class SimulationFeatures :
public virtual Base,
public virtual Implements3d<SimulationFeatureList>
{
public: void WorldForwardStep(
const Identity &_worldID,
ForwardStep::Output &_h,
ForwardStep::State &_x,
const ForwardStep::Input &_u) override;
};

}
}
}

#endif
7 changes: 5 additions & 2 deletions bullet/src/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@

#include "Base.hh"
#include "EntityManagementFeatures.hh"
#include "SimulationFeatures.hh"

namespace ignition {
namespace physics {
namespace bullet {

struct BulletFeatures : FeatureList <
EntityManagementFeatureList
EntityManagementFeatureList,
SimulationFeatureList
> { };

class Plugin :
public virtual Implements3d<BulletFeatures>,
public virtual Base,
public virtual EntityManagementFeatures {};
public virtual EntityManagementFeatures,
public virtual SimulationFeatures {};

IGN_PHYSICS_ADD_PLUGIN(Plugin, FeaturePolicy3d, BulletFeatures)

Expand Down

0 comments on commit e737f60

Please sign in to comment.