enable planar reflection in MinitaurGymEnv
enable follow cam in other Gym locomotion environments add testing assets for multi-material obj files -> sdf conversion. Also use ER_NO_SEGMENTATION_MASK flag for TinyRenderer/EGL plugin renderer
This commit is contained in:
@@ -1311,6 +1311,7 @@ void BulletURDFImporter::convertLinkVisualShapes2(int linkIndex, int urdfIndex,
|
||||
UrdfLink* const* linkPtr = model.m_links.getAtIndex(urdfIndex);
|
||||
if (linkPtr)
|
||||
{
|
||||
m_data->m_customVisualShapesConverter->setFlags(m_data->m_flags);
|
||||
m_data->m_customVisualShapesConverter->convertVisualShapes(linkIndex, pathPrefix, localInertiaFrame, *linkPtr, &model, colObj->getBroadphaseHandle()->getUid(), bodyUniqueId, m_data->m_fileIO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3748,6 +3748,10 @@ bool PhysicsServerCommandProcessor::processRequestCameraImageCommand(const struc
|
||||
m_data->m_pluginManager.getRenderInterface()->setProjectiveTexture(false);
|
||||
}
|
||||
|
||||
if ((flags & ER_NO_SEGMENTATION_MASK) != 0)
|
||||
{
|
||||
segmentationMaskBuffer = 0;
|
||||
}
|
||||
|
||||
m_data->m_pluginManager.getRenderInterface()->copyCameraImageData(pixelRGBA, numRequestedPixels,
|
||||
depthBuffer, numRequestedPixels,
|
||||
|
||||
@@ -820,7 +820,7 @@ enum eURDF_Flags
|
||||
URDF_USE_SELF_COLLISION_INCLUDE_PARENT = 8192,
|
||||
URDF_PARSE_SENSORS = 16384,
|
||||
URDF_USE_MATERIAL_COLORS_FROM_MTL = 32768,
|
||||
URDF_USE_MATERIAL_TRANSPARANCY_FROM_MTL = 64738,
|
||||
URDF_USE_MATERIAL_TRANSPARANCY_FROM_MTL = 65536,
|
||||
};
|
||||
|
||||
enum eUrdfGeomTypes //sync with UrdfParser UrdfGeomTypes
|
||||
|
||||
@@ -270,13 +270,14 @@ void EGLRendererVisualShapeConverter::setLightSpecularCoeff(float specularCoeff)
|
||||
}
|
||||
|
||||
///todo: merge into single file with TinyRendererVisualShapeConverter
|
||||
static void convertURDFToVisualShape2(const UrdfShape* visual, const char* urdfPathPrefix, const btTransform& visualTransform, btAlignedObjectArray<GLInstanceVertex>& verticesOut, btAlignedObjectArray<int>& indicesOut, btAlignedObjectArray<MyTexture3>& texturesOut, b3VisualShapeData& visualShapeOut, struct CommonFileIOInterface* fileIO)
|
||||
static void convertURDFToVisualShape2(const UrdfShape* visual, const char* urdfPathPrefix, const btTransform& visualTransform, btAlignedObjectArray<GLInstanceVertex>& verticesOut, btAlignedObjectArray<int>& indicesOut, btAlignedObjectArray<MyTexture3>& texturesOut, b3VisualShapeData& visualShapeOut, struct CommonFileIOInterface* fileIO, int flags)
|
||||
{
|
||||
visualShapeOut.m_visualGeometryType = visual->m_geometry.m_type;
|
||||
visualShapeOut.m_dimensions[0] = 0;
|
||||
visualShapeOut.m_dimensions[1] = 0;
|
||||
visualShapeOut.m_dimensions[2] = 0;
|
||||
memset(visualShapeOut.m_meshAssetFileName, 0, sizeof(visualShapeOut.m_meshAssetFileName));
|
||||
#if 0
|
||||
if (visual->m_geometry.m_hasLocalMaterial)
|
||||
{
|
||||
visualShapeOut.m_rgbaColor[0] = visual->m_geometry.m_localMaterial.m_matColor.m_rgbaColor[0];
|
||||
@@ -284,6 +285,7 @@ static void convertURDFToVisualShape2(const UrdfShape* visual, const char* urdfP
|
||||
visualShapeOut.m_rgbaColor[2] = visual->m_geometry.m_localMaterial.m_matColor.m_rgbaColor[2];
|
||||
visualShapeOut.m_rgbaColor[3] = visual->m_geometry.m_localMaterial.m_matColor.m_rgbaColor[3];
|
||||
}
|
||||
#endif
|
||||
|
||||
GLInstanceGraphicsShape* glmesh = 0;
|
||||
|
||||
@@ -412,6 +414,23 @@ static void convertURDFToVisualShape2(const UrdfShape* visual, const char* urdfP
|
||||
b3ImportMeshData meshData;
|
||||
if (b3ImportMeshUtility::loadAndRegisterMeshFromFileInternal(visual->m_geometry.m_meshFileName, meshData, fileIO))
|
||||
{
|
||||
if (flags&URDF_USE_MATERIAL_COLORS_FROM_MTL)
|
||||
{
|
||||
if (meshData.m_flags & B3_IMPORT_MESH_HAS_RGBA_COLOR)
|
||||
{
|
||||
visualShapeOut.m_rgbaColor[0] = meshData.m_rgbaColor[0];
|
||||
visualShapeOut.m_rgbaColor[1] = meshData.m_rgbaColor[1];
|
||||
visualShapeOut.m_rgbaColor[2] = meshData.m_rgbaColor[2];
|
||||
|
||||
if (flags&URDF_USE_MATERIAL_TRANSPARANCY_FROM_MTL)
|
||||
{
|
||||
visualShapeOut.m_rgbaColor[3] = meshData.m_rgbaColor[3];
|
||||
} else
|
||||
{
|
||||
visualShapeOut.m_rgbaColor[3] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meshData.m_textureImage1)
|
||||
{
|
||||
MyTexture3 texData;
|
||||
@@ -752,7 +771,7 @@ void EGLRendererVisualShapeConverter::convertVisualShapes(
|
||||
visualShape.m_rgbaColor[3] = rgbaColor[3];
|
||||
{
|
||||
B3_PROFILE("convertURDFToVisualShape2");
|
||||
convertURDFToVisualShape2(vis, pathPrefix, localInertiaFrame.inverse() * childTrans, vertices, indices, textures, visualShape, fileIO);
|
||||
convertURDFToVisualShape2(vis, pathPrefix, localInertiaFrame.inverse() * childTrans, vertices, indices, textures, visualShape, fileIO, m_data->m_flags);
|
||||
}
|
||||
m_data->m_visualShapes.push_back(visualShape);
|
||||
|
||||
|
||||
@@ -182,13 +182,14 @@ void TinyRendererVisualShapeConverter::setLightSpecularCoeff(float specularCoeff
|
||||
m_data->m_hasLightSpecularCoeff = true;
|
||||
}
|
||||
|
||||
static void convertURDFToVisualShape(const UrdfShape* visual, const char* urdfPathPrefix, const btTransform& visualTransform, btAlignedObjectArray<GLInstanceVertex>& verticesOut, btAlignedObjectArray<int>& indicesOut, btAlignedObjectArray<MyTexture2>& texturesOut, b3VisualShapeData& visualShapeOut, struct CommonFileIOInterface* fileIO)
|
||||
static void convertURDFToVisualShape(const UrdfShape* visual, const char* urdfPathPrefix, const btTransform& visualTransform, btAlignedObjectArray<GLInstanceVertex>& verticesOut, btAlignedObjectArray<int>& indicesOut, btAlignedObjectArray<MyTexture2>& texturesOut, b3VisualShapeData& visualShapeOut, struct CommonFileIOInterface* fileIO, int flags)
|
||||
{
|
||||
visualShapeOut.m_visualGeometryType = visual->m_geometry.m_type;
|
||||
visualShapeOut.m_dimensions[0] = 0;
|
||||
visualShapeOut.m_dimensions[1] = 0;
|
||||
visualShapeOut.m_dimensions[2] = 0;
|
||||
memset(visualShapeOut.m_meshAssetFileName, 0, sizeof(visualShapeOut.m_meshAssetFileName));
|
||||
#if 0
|
||||
if (visual->m_geometry.m_hasLocalMaterial)
|
||||
{
|
||||
visualShapeOut.m_rgbaColor[0] = visual->m_geometry.m_localMaterial.m_matColor.m_rgbaColor[0];
|
||||
@@ -196,6 +197,7 @@ static void convertURDFToVisualShape(const UrdfShape* visual, const char* urdfPa
|
||||
visualShapeOut.m_rgbaColor[2] = visual->m_geometry.m_localMaterial.m_matColor.m_rgbaColor[2];
|
||||
visualShapeOut.m_rgbaColor[3] = visual->m_geometry.m_localMaterial.m_matColor.m_rgbaColor[3];
|
||||
}
|
||||
#endif
|
||||
|
||||
GLInstanceGraphicsShape* glmesh = 0;
|
||||
|
||||
@@ -322,8 +324,26 @@ static void convertURDFToVisualShape(const UrdfShape* visual, const char* urdfPa
|
||||
{
|
||||
//glmesh = LoadMeshFromObj(fullPath,visualPathPrefix);
|
||||
b3ImportMeshData meshData;
|
||||
|
||||
if (b3ImportMeshUtility::loadAndRegisterMeshFromFileInternal(visual->m_geometry.m_meshFileName, meshData, fileIO))
|
||||
{
|
||||
if (flags&URDF_USE_MATERIAL_COLORS_FROM_MTL)
|
||||
{
|
||||
if (meshData.m_flags & B3_IMPORT_MESH_HAS_RGBA_COLOR)
|
||||
{
|
||||
visualShapeOut.m_rgbaColor[0] = meshData.m_rgbaColor[0];
|
||||
visualShapeOut.m_rgbaColor[1] = meshData.m_rgbaColor[1];
|
||||
visualShapeOut.m_rgbaColor[2] = meshData.m_rgbaColor[2];
|
||||
|
||||
if (flags&URDF_USE_MATERIAL_TRANSPARANCY_FROM_MTL)
|
||||
{
|
||||
visualShapeOut.m_rgbaColor[3] = meshData.m_rgbaColor[3];
|
||||
} else
|
||||
{
|
||||
visualShapeOut.m_rgbaColor[3] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (meshData.m_textureImage1)
|
||||
{
|
||||
MyTexture2 texData;
|
||||
@@ -665,9 +685,14 @@ void TinyRendererVisualShapeConverter::convertVisualShapes(
|
||||
|
||||
{
|
||||
B3_PROFILE("convertURDFToVisualShape");
|
||||
convertURDFToVisualShape(vis, pathPrefix, localInertiaFrame.inverse() * childTrans, vertices, indices, textures, visualShape, fileIO);
|
||||
convertURDFToVisualShape(vis, pathPrefix, localInertiaFrame.inverse() * childTrans, vertices, indices, textures, visualShape, fileIO, m_data->m_flags);
|
||||
}
|
||||
|
||||
rgbaColor[0] = visualShape.m_rgbaColor[0];
|
||||
rgbaColor[1] = visualShape.m_rgbaColor[1];
|
||||
rgbaColor[2] = visualShape.m_rgbaColor[2];
|
||||
rgbaColor[3] = visualShape.m_rgbaColor[3];
|
||||
|
||||
if (vertices.size() && indices.size())
|
||||
{
|
||||
TinyRenderObjectData* tinyObj = new TinyRenderObjectData(m_data->m_rgbColorBuffer, m_data->m_depthBuffer, &m_data->m_shadowBuffer, &m_data->m_segmentationMaskBuffer, bodyUniqueId, linkIndex);
|
||||
|
||||
@@ -111,6 +111,16 @@ class MJCFBaseBulletEnv(gym.Env):
|
||||
# backwards compatibility for gym >= v0.9.x
|
||||
# for extension of this class.
|
||||
def step(self, *args, **kwargs):
|
||||
if self.isRender:
|
||||
base_pos=[0,0,0]
|
||||
if (hasattr(self,'robot')):
|
||||
if (hasattr(self.robot,'body_xyz')):
|
||||
base_pos = self.robot.body_xyz
|
||||
# Keep the previous orientation of the camera set by the user.
|
||||
#[yaw, pitch, dist] = self._p.getDebugVisualizerCamera()[8:11]
|
||||
self._p.resetDebugVisualizerCamera(3,0,0, base_pos)
|
||||
|
||||
|
||||
return self._step(*args, **kwargs)
|
||||
|
||||
if parse_version(gym.__version__)>=parse_version('0.9.6'):
|
||||
|
||||
@@ -271,7 +271,7 @@ class MinitaurGymEnv(gym.Env):
|
||||
"%s/plane.urdf" % self._urdf_root)
|
||||
if (self._reflection):
|
||||
self._pybullet_client.changeVisualShape(self._ground_id,-1,rgbaColor=[1,1,1,0.8])
|
||||
#self._pybullet_client.configureDebugVisualizer(self._pybullet_client.COV_ENABLE_PLANAR_REFLECTION,1)
|
||||
self._pybullet_client.configureDebugVisualizer(self._pybullet_client.COV_ENABLE_PLANAR_REFLECTION,self._ground_id)
|
||||
self._pybullet_client.setGravity(0, 0, -10)
|
||||
acc_motor = self._accurate_motor_model_enabled
|
||||
motor_protect = self._motor_overheat_protection
|
||||
|
||||
Reference in New Issue
Block a user