Commit Graph

51 Commits

Author SHA1 Message Date
Tigran Gasparian
68d3fb28e0 Adds support for loading user data from URDF files. 2020-01-17 11:55:42 +01:00
Erwin Coumans
72e0e7c223 fix load_soft_body.py example.
add optional flags in pybullet.resetSimulation.
fix compile issue due to SKIP_DEFORMABLE_WORLD
fix issue in .obj importer (todo: replace with tiny_obj_loader)
todo: replace std::ifstream fs; by fileIO usage.
2019-11-14 21:20:42 -08:00
Erwin Coumans
31688ffb34 fix in multi-endeffector IK, calculate jacobian uses dofs without base, fix premake build of some projects 2019-07-11 22:22:35 -07:00
Chuyuan Fu
4da456054c Update PhysicsServerCommandProcessor and plugins to support render 2019-06-25 17:59:15 -07:00
Chuyuan Fu
229e87c3c9 get mesh data api
fix compile

fix typo
2019-06-17 19:00:53 -07:00
Erwin Coumans
ee3680765e fixes for RemoteGUIHelper 2019-06-14 14:34:56 -07:00
erwincoumans
6951aaf26a implement PyBullet removeState command. Fixes Issue #2163
https://github.com/bulletphysics/bullet3/issues/2163
2019-04-03 20:06:40 -07:00
erwincoumans
85ee4c2934 allow batch creation of objects through PyBullet.createMultiBody, see createMultiBodyBatch.py example.
expose minGraphicsUpdateTimeMs through PyBullet.connect(p.GUI, options="minGraphicsUpdateTimeMs=32000"), by default OpenGL rendering runs at 4000microseconds intervals.
allow a maximum of 128k objects
fix meshScale for PyBullet.createCollisionShape for custom mesh
expose Pybullet.setPhysicsEngineParameter(minimumSolverIslandSize=...), larger minimum batches group solver constraints together in the same island, to reduce calling overhead (even if they are not related)
2019-02-12 10:36:01 -08:00
erwincoumans
ab8f16961e Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files.
make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type.
This commit contains no other changes aside from adding and applying clang-format-all.sh
2018-09-23 14:17:31 -07:00
erwincoumans
9553892770 PyBullet / BulletRobotics:
Implement collisionFilterPlugin, use setCollisionFilterPair to enable or disable collision detection between specific pairs of objects.
Also, expose setCollisionFilterGroupMask as PyBullet API and in urdf using the tag <collision group="1" mask="2"/>.
See examples/pybullet/examples/collisionFilter.py for an example.
PyBullet default: Lower the warmstarting factor, for maximal coordinates rigid bodies for more stable simulation.
Add btCollisionWorld::refreshBroadphaseProxy to easier recreate the broadphase proxy without adding/removing objects to the world.
2018-09-12 19:30:49 -07:00
erwincoumans
0efc67841d allow pybullet to connect to GRPC server. (need to use flag --enable_grpc in premake build system)
add grpcPlugin, it can work in GUI, SHARED_MEMORY_SERVER, DIRECT and other modes.
example script to start server from pybullet:
import pybullet as p
p.connect(p.GUI)
#if statically linked plugin
id = p.loadPlugin("grpcPlugin")
#dynamics loading the plugin
#id = p.loadPlugin("E:/develop/bullet3/bin/pybullet_grpcPlugin_vs2010_x64_debug.dll", postFix="_grpcPlugin")

#start the GRPC server at hostname, port
if (id>=0):
	p.executePluginCommand(id, "localhost:1234")

Only in DIRECT mode, since there is no 'ping' you need to call to handle RCPs:
numRPC = 10
while (1):
	p.executePluginCommand(id, intArgs=[numRPC])
2018-09-05 17:58:14 -07:00
Tigran Gasparian
35a55b2056 Changes tickPlugins to reportNotifications and only calls the processNotifications function on the plugins when there are actually notifications available. tickPlugins will to into a separate PR. 2018-07-25 14:47:34 +02:00
Tigran Gasparian
c59afb88c4 Notify plugins on certain events (e.g. body added).
This also adds a periodic tick function to plugins, giving them periodically control over the simulation thread, even when the simulation is paused.
2018-07-24 14:12:16 +02:00
Tigran Gasparian
b84eb8af74 Several fixes for the parallel raycasts
- Limits the maximum number of threads to 64, since btThreadSupportPosix
and btThreadsupportWin32 don't support more than 64 bits at this moment,
due to the use of UINT64 bitmasks. This could be fixed by using
std::bitset or some other alternative.
- Introduces a threadpool class, b3ThreadPool, which is a simple wrapper
around btThreadSupportInterface and uses this instead of the global task
scheduler for parallel raycasting. This is actually quite a bit faster
than the task scheduler (~10-15% in my tests for parallel raycasts),
since the advanced features (parallelFor) are not necessary for the
parallel raycasts.
- Puts 16*1024 of MAX_RAY_INTERSECTION_MAX_SIZE_STREAMING in
parentheses, since it otherwise causes problems with other operators
of equal precedence and introduces a smaller constant for Apple targets.
- Refactors the parallel raycasts code and adds some more profiling.
2018-06-19 18:41:42 +02:00
erwincoumans
42c9d9aa3c lazy creation of batch scheduler, it causes issues with the physics. 2018-06-16 13:59:03 -07:00
erwincoumans
b6120e760a PyBullet.addUserData / getUserData / removeUserData / getUserDataId / getNumUserData / getUserDataInfo
See examples/pybullet/examples/userData.py how to use it. TODO: add to PyBullet Quickstart Guide.
Thanks to Tigran Gasparian for the contribution!
2018-06-02 13:40:08 -07:00
YunfeiBai
de3b8bf3c9
Merge branch 'master' into master 2018-01-08 18:13:03 -08:00
yunfeibai
d077bdec07 Change the API names for loading softbody. 2018-01-07 19:24:37 -08:00
Erwin Coumans
9523df2519 warning fix (param name different in header/cpp) 2018-01-04 15:48:59 -08:00
Erwin Coumans
79d78a325a Start of a urdfEditor.py, limited support to extract a URDF from a PyBullet body.
Use btCylinderShapeZ for URDF cylinder, instead of converting it to a btConvexHullShape.
Implement PyBullet.getCollisionShapeData
Extend PyBullet.getDynamicsInfo / b3GetDynamicsInfo, remove flag (don't rely on API returning a fixed number of elements in a list!)
Extend PyBullet.getJointInfo: add parentIndex
2018-01-03 19:17:28 -08:00
Erwin Coumans
35b44f8a85 implement pybullet.saveState command, for in-memory storage of state.
bump up pybullet API version (SHARED_MEMORY_MAGIC_NUMBER) to 201801010
2017-12-31 15:37:16 -08:00
Erwin Coumans
97547eda0d preliminary work towards saveState/restoreState and saveRestoreState.py example (not implemented yet)
allow multiple options in connect, for example: p.connect(p.GUI, options="--width=640, --height=480")
2017-12-28 10:05:51 -08:00
erwincoumans
a9b59b4511 Finally refactored the PhysicsServerCommandProcessor::processCommand switch statements into over 50 separate functions.
Over time, some of those functions can be moved into separate plugins, similar to vrSyncPlugin (either statically/dynamically linked plugins or dynamically loaded at run-time)
2017-11-17 16:14:18 -08:00
erwincoumans
8e496036c6 More work on the C/C++ plugin system for pybullet/C-API:
Add preTickPluginCallback/postTickPluginCallback
User pointer for b3PluginContext, to store objects (class/struct instances)
Pass ints and floats as optional argument for plugin executePluginCommand
2017-09-23 18:05:23 -07:00
Erwin Coumans
aafaa7e33e Expose optional "globalScaling" factor to pybullet.loadURDF and pybullet.loadSDF. This will scale the visual, collision shapes and transform locations.
Fix two_cubes.sdf (was lacking collision shape for second cube)
2017-08-14 14:59:41 -07:00
Erwin Coumans
2e6f8c271e allow to disable/enable default keyboard shortcuts ('w', 'd' 's' etc) and default mouse picking
pybullet.getMouseEvents / b3RequestMouseEventsCommandInit
2017-06-17 13:29:14 -07:00
Erwin Coumans
030d723db6 fix some warnings 2017-06-01 16:48:07 -07:00
erwincoumans
83f910711a Prepare/allow for non-Bullet2-based physics command processor in pybullet/Bullet-C-API
!!! Make sure to add examples/SharedMemory/PhysicsServerExampleBullet2.cpp to your build system, if needed
Bump up pybullet to version 1.0.9
2017-05-30 19:54:55 -07:00
erwincoumans
5436b8f048 print better error warning, in case the physics client/server version mismatch.
fix in b3HashString
remove many unused dependencies from kuka_grasp_block_playback.py (time,math, datetime ,numpy,pylab ,sys, os, fnmatch,argparse were not used!)
move block_grasp_log.bin from Bullet3/data to Bullet3/examples/pybullet/examples/data folder.
PhysicsServerCommandProcessor, derive from CommandProcessorInterface to prepare for different back-end implementation
2017-05-28 17:05:18 -07:00
Erwin Coumans
db008ab3c2 Improve debug text/line rendering, can be use to draw frames and text in local coordinate of an object / link.
example:
kuka = p.loadURDF("kuka_iiwa/model.urdf")
p.getNumJoints(kuka)
pybullet.addUserDebugLine([0,0,0],[0,0,0.1],[0,0,1],trackObjectUniqueId=2,trackLinkIndex=6)
pybullet.addUserDebugText("tip", [0,0,0.1],textColorRGB=[1,0,0],trackObjectUniqueId=2,trackLinkIndex=6)
Also allow to render text using a given orientation (instead of pointing to the camera), example:
pybullet.addUserDebugText("tip", [0,0,0.1],textColorRGB=[1,0,0],textOrientation=[0,0,0,1], trackObjectUniqueId=2,trackLinkIndex=6)
Add drawTexturedTriangleMesh, for drawing 3d text.
Expose readSingleInstanceTransformToCPU, to extract position/orientation from graphics index.
updateTexture: allow to not flip texels around up axis
2017-05-23 22:05:26 -07:00
Erwin Coumans
433d11d8cf Add a btIDEbugDraw::clearLines, helps multi-threaded rendering of lines (while updating those lines in a dynamics world in a different thread)
Expose COV_ENABLE_VR_RENDER_CONTROLLERS, to enable/disable rendering of controllers (and some frames) in VR
Expose COV_ENABLE_RENDERING to enable/disable rendering.
Fix some multi-threading issues (potential crashes), related to debug drawing/rendering in one thread, while changing the dynamics world/removing/resetSimulation in a different thread.
2017-05-16 12:19:03 -07:00
Erwin Coumans
2a2c18e959 add more tinyaudio preparation, some test wav files, play sound on collision events. Will expose this in the C-API to pick wav files and collision threshold levels etc. Use the premake --audio flag to try it out. The TinyAudio example in the ExampleBrowser works on Mac, Linux and Windows, you can play notes by pressing keys. 2017-04-29 10:32:30 -07:00
Erwin Coumans
4911916937 Expose 'flags' option for loadURDF, to allow customization of the URDF loading process while maintaining backward compatibility.
For example: URDF_USE_INERTIA_FROM_FILE flag. By default, URDF2Bullet will re-compute the inertia tensor based on mass and volume, because most URDF files have bogus Inertia values.
2017-03-27 08:30:20 -07:00
Erwin Coumans
34fc2fb589 create premake/cmake file for Bullet/Extras/obj2sdf
add missing 1.sdf for Bullet/data/kitchens/1.sdf
add support for getting keyboard events (pybullet.getKeyboardEvents and b3RobotSimulatorClientAPI::getKeyboardEvents)
2017-03-02 12:33:22 -08:00
Erwin Coumans
a4f1e34899 expose timeout in pybullet/shared memory API
add RobotSimulator, a C++ API similar to pybullet. (work-in-progress, only part of API implemeted)
2017-02-24 15:34:11 -08:00
Erwin Coumans
cfd35840f0 initial implementation of state logging.
see examples/pybullet/logMinitaur.py for example. Other state logging will include general robot states and VR controllers state.
2017-02-17 14:25:53 -08:00
Erwin Coumans
34c3fca8d5 prepare state logging system (log state of robot, vr controllers after each stepSimulation) 2017-02-17 10:47:55 -08:00
Erwin Coumans
c940f0ec47 update pybullet quickstart quide PDF
hook up the loadMJCF importing MuJoCo xml files in pybullet and shared memory API b3LoadMJCFCommandInit
2016-12-31 14:43:15 -08:00
Erwin Coumans
826c5854a8 See also pybullet quickstart guide here: https://docs.google.com/document/d/10sXEhzFRSnvFcl3XxNGhnD4N2SedqwdAvK3dsihxVUA/edit#
vrevent.py: add a Tiltbrush-style drawing example using pybullet
Expose getVREvents to pybullet / shared memory API, access to any VR controller state & state changes.
Improve performance of user debug lines (pybullet/shared memory API) by batching lines with same color/width
expose rayTest to pybullet/shared memory API (single ray for now)
add pybullet getMatrixFromQuaterion
2016-12-26 19:40:09 -08:00
Erwin Coumans
17570c4700 tweak color of quadruped robot URDF, tweak quadruped.py script to make it more compatible with VR demo
allow VR physics server to run with or without 'realTimeSimulation'
2016-12-11 09:28:36 -08:00
Erwin Coumans
746c4d0d2a add a tray, similar to those ones:
https://research.googleblog.com/2016/03/deep-learning-for-robots-learning-from.html

tune the VR demo a bit, to make it more user friendly.
2016-11-29 17:08:47 -08:00
erwincoumans
9708392322 work-in-progress
add UDP network connection for physics client <-> server.
also set spinning friction in rolling friction demo (otherwise objects may keep on spinning forever)
2016-11-04 13:15:10 -07:00
erwincoumans
c2ca88bf44 added b3PhysicsParamSetInternalSimFlags command, and pybullet setInternalSimFlags API.
//Use at own risk: magic things may or my not happen when calling this API.

This allows to enable/disable robot assets (samurai world, gripper, KUKA robot etc) in Physics Server (and App_PhysicsServerVR etc)
1 = create robot assets
2 = create experimental box-vr-gui

Add optional command-line parameter for App_PhysicsServerVR, --norobotassets, to start with an empty world, no assets in VR (no gripper, no kuka)
2016-10-23 07:14:50 -07:00
yunfeibai
591f922d97 Support loading Urdf as btRigidBody with RobotSimAPI. Loading Sdf as btRigidBody is work in progress. 2016-08-16 17:56:30 -07:00
erwin coumans
a9b1544a9f Add premake support to build pybullet, Windows and Linux tested, will enable Mac in next commit.
Expose inverse dynamics to Bullet shared memory API, through b3CalculateInverseDynamicsCommandInit and
b3GetStatusInverseDynamicsJointForces command/status. See PhysicsClientExeample or pybullet for usage.
Add option for Windows and Linux to set python_lib_dir and python_include_dir for premake and --enable_pybullet option
Expose inverse dynamics to pybullet: [force] = p.calculateInverseDynamics(objectIndex,[q],[qdot],[acc])
Thanks to Jeff Bingham for the suggestion.
2016-08-09 18:40:12 -07:00
erwin coumans
c28cd03fbd OpenVR controller can pick/drag objects. Instructions, Windows only:
Compile using premake+visual studio, and compile App_SharedMemoryPhysics_VR
Compile pybullet using cmake using cmake -DBUILD_PYBULLET=OFF -DCMAKE_BUILD_TYPE=Release ..
Create a symbolic link from c:\python\dlls\pybullet.pyd to C:\develop\bullet3\cmp\lib\Release\pybullet.dll
App_SharedMemoryPhysics_VR
Run Python. Here are some Python lines to get going:
import pybullet as p
p.connect(p.SHARED_MEMORY)
p.loadURDF("cube.urdf")
p.setGravity(0,0,-10)
p.setRealTimeSimulation(1)

Allow real-time simulation in physics server, add pybullet command setRealTimeSimulation to control it
Mesh decimation (reduce number of triangles/vertices) using a Blender modifier for Kuka IIWA and Husky
Disabled the 'glFlush' commands in GLInstancingRenderer.
Add VR controller methods to examples\CommonInterfaces\CommonExampleInterface.h
Use the ANSI version in Windows file/string operations instead of unicode, hope this doesn't break builds.
2016-07-17 23:50:11 -07:00
Erwin Coumans
456c844a6b work-in-progress send object/joint information after loading SDF file 2016-06-14 18:41:19 -07:00
erwincoumans
6523df336e Fix pybullet Windows build errors: C99 requires variables to be defined at the start of the function.
Improve CMake Windows support to build PyBullet (BUILD_PYBULLET)
Implement b3LoadSdfCommandInit in shared memory API
Implement pybullet SDF loading binding, in loadSDF API
TODO for SDF support is provide way to query object/link/joint information.
2016-06-13 10:11:28 -07:00
Erwin Coumans
0ca56e756f add joint damping in PhysicsServerCommandProcessor 2016-04-13 17:21:43 -07:00
Erwin Coumans
59b32b7af1 re-enable command log and playback in physics server
report applied motor torque in physics server
2016-04-08 18:17:17 -07:00