Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the gravity vector #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@
### PIP installation
To install for the first time:
```
pip install git+https://github.com/petrikvladimir/pyphysx.git@master
pip install git+https://github.com/StanislavPetrovV/pyphysx.git@master
```
To update if its already installed:
```
pip install --upgrade git+https://github.com/petrikvladimir/pyphysx.git@master
pip install --upgrade git+https://github.com/StanislavPetrovV/pyphysx.git@master
```

Optionally, you can install in anaconda
```
conda create -n py38 python=3.8
conda activate py38
conda install -c anaconda gcc_linux-64 gxx_linux-64
pip install git+https://github.com/petrikvladimir/pyphysx.git@master
```


### Build from source
If pip install fails, build the library from source.
Expand All @@ -36,7 +30,7 @@ pip install --upgrade numpy
pip install codecov pyrender imageio imageio_ffmpeg trimesh networkx numba numpy_quaternion matplotlib scipy anytree meshcat pytest-cov

# Clone and build from source:
git clone https://github.com/petrikvladimir/pyphysx.git
git clone https://github.com/StanislavPetrovV/pyphysx.git
python setup.py install --user
```

Expand Down
5 changes: 3 additions & 2 deletions include/Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ class Scene : public BasePhysxPointer<physx::PxScene> {
const physx::PxBroadPhaseType::Enum &broad_phase_type,
const std::vector<physx::PxSceneFlag::Enum> &scene_flags,
size_t gpu_max_num_partitions,
float gpu_dynamic_allocation_scale
float gpu_dynamic_allocation_scale,
physx::PxVec3 gravity
) : BasePhysxPointer() {
physx::PxSceneDesc sceneDesc(Physics::get().physics->getTolerancesScale());
sceneDesc.cpuDispatcher = Physics::get().dispatcher;
sceneDesc.cudaContextManager = Physics::get().cuda_context_manager;
sceneDesc.filterShader = physx::PxDefaultSimulationFilterShader;
sceneDesc.gravity = physx::PxVec3(0.0f, 0.0f, -9.81f);
sceneDesc.gravity = gravity;
for (const auto &flag : scene_flags) {
sceneDesc.flags |= flag;
}
Expand Down
5 changes: 3 additions & 2 deletions src/pyphysx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,13 @@ PYBIND11_MODULE(_pyphysx, m) {
.def_static("init_gpu", &Physics::init_gpu);

py::class_<Scene>(m, "Scene")
.def(py::init<physx::PxFrictionType::Enum, physx::PxBroadPhaseType::Enum, std::vector<physx::PxSceneFlag::Enum>, size_t, float>(),
.def(py::init<physx::PxFrictionType::Enum, physx::PxBroadPhaseType::Enum, std::vector<physx::PxSceneFlag::Enum>, size_t, float, physx::PxVec3>(),
arg("friction_type") = physx::PxFrictionType::ePATCH,
arg("broad_phase_type") = physx::PxBroadPhaseType::eABP,
arg("scene_flags") = std::vector<physx::PxSceneFlag::Enum>(),
arg("gpu_max_num_partitions") = 8,
arg("gpu_dynamic_allocation_scale") = 1.
arg("gpu_dynamic_allocation_scale") = 1.,
arg("gravity") = physx::PxVec3(0.0, 0.0, -9.81)
)
.def("simulate", &Scene::simulate,
arg("dt") = 1. / 60.
Expand Down