Skip to content

Commit

Permalink
Add World::setGravity(double x, double y, double z) (#1642)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 authored Jan 4, 2022
1 parent eeac11b commit 0bbc551
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions dart/simulation/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ void World::setGravity(const Eigen::Vector3d& _gravity)
}
}

//==============================================================================
void World::setGravity(double x, double y, double z)
{
setGravity(Eigen::Vector3d(x, y, z));
}

//==============================================================================
const Eigen::Vector3d& World::getGravity() const
{
Expand Down
3 changes: 3 additions & 0 deletions dart/simulation/World.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class World : public virtual common::Subject
/// Set gravity
void setGravity(const Eigen::Vector3d& _gravity);

/// Set gravity
void setGravity(double x, double y, double z);

/// Get gravity
const Eigen::Vector3d& getGravity() const;

Expand Down
3 changes: 1 addition & 2 deletions examples/deprecated_examples/glut_biped_stand/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ int main(int argc, char* argv[])
= dart::utils::SkelParser::readWorld("dart://sample/skel/fullbody1.skel");
assert(myWorld != nullptr);

Eigen::Vector3d gravity(0.0, -9.81, 0.0);
myWorld->setGravity(gravity);
myWorld->setGravity(0.0, -9.81, 0.0);

dart::dynamics::SkeletonPtr biped = myWorld->getSkeleton("fullbody1");

Expand Down
11 changes: 9 additions & 2 deletions python/dartpy/simulation/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,16 @@ void World(py::module& m)
::py::return_value_policy::reference_internal)
.def(
"setGravity",
+[](dart::simulation::World* self, const Eigen::Vector3d& _gravity)
-> void { return self->setGravity(_gravity); },
::py::overload_cast<const Eigen::Vector3d&>(
&dart::simulation::World::setGravity),
::py::arg("gravity"))
.def(
"setGravity",
::py::overload_cast<double, double, double>(
&dart::simulation::World::setGravity),
::py::arg("x"),
::py::arg("y"),
::py::arg("z"))
.def(
"getGravity",
+[](const dart::simulation::World* self) -> const Eigen::Vector3d& {
Expand Down

0 comments on commit 0bbc551

Please sign in to comment.