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

HeightMap : Collision and Visual Aspect mismatch #1658

Open
ibrahiminfinite opened this issue Mar 22, 2022 · 0 comments
Open

HeightMap : Collision and Visual Aspect mismatch #1658

ibrahiminfinite opened this issue Mar 22, 2022 · 0 comments
Labels
help wanted Indicates wanting help on an issue or pull request type: bug Indicates an unexpected problem or unintended behavior

Comments

@ibrahiminfinite
Copy link

ibrahiminfinite commented Mar 22, 2022

Environment

Select the following information.

  • DART version: 6.13.0
  • OS name and version name(or number): Ubuntu 20.04
  • Compiler name and version number: gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04)

Description

Collision Engine used : ODE

When creating a heightmap of a given size , the visual and collision aspects are not aligned as one would expect.
Below is an image with a HeightMapShape (blue) of width = depth = 2, and a BoxShape (Green) with width = depth = 2 and balls spaced at even distance dropped on them.(Gravity is enabled and the balls are in contact with the surface)
The BoxShape is translated by 1 unit in the -z direction

Expected behaviour would be ,visual and collision aspect of heightmap should be aligned.

image

image

The observed result is as seen, the visual aspect seem to be translated with respect to the collision aspect for the heightmap.

This is the code for my HeightMap

/*
  "heightmap" :
  {
    "origin" : [0.0, 0.0, 0.0],
    "width" : 2.0,
    "depth" : 2.0,
    "minZ" : 0.0,
    "maxZ" : 0.0,
    "scale" : 2.0
  }
*/


struct TerrainConfig
{
    Eigen::Vector3f terrain_origin;
    float tWidth;
    float tDepth;
    float minZ;
    float maxZ;
    float tScale;
};

dynamics::SkeletonPtr createHeightMap(TerrainConfig& tConfig)
{

    dynamics::SkeletonPtr terrainSkel = dynamics::Skeleton::create("terrain");

    dynamics::BodyNodePtr terrainBody
            = terrainSkel->createJointAndBodyNodePair<dynamics::WeldJoint>(nullptr)
                    .second;

    Eigen::Isometry3d tf_trans = Eigen::Isometry3d::Identity();
    tf_trans.translation() = Eigen::Vector3d{tConfig.terrain_origin[0],tConfig.terrain_origin[1],
                                             tConfig.terrain_origin[2]};
    terrainBody->getParentJoint()->setTransformFromParentBodyNode(tf_trans);

    auto terrainShape = std::make_shared<dynamics::HeightmapShape<float>>();
    std::vector<float> heights{} ;
    for(auto i=0; i < tConfig.tWidth * tConfig.tDepth ; i++)
    {
        heights.emplace_back(math::Random::uniform(tConfig.minZ, tConfig.maxZ));
    }
    std::cout<< "HEIGHTS " << heights.size();
    terrainShape->setHeightField(tConfig.tWidth, tConfig.tDepth, heights);
    terrainShape->setScale(Eigen::Vector3f(tConfig.tScale, tConfig.tScale, 1.0));


    terrainBody->createShapeNodeWith<
            dynamics::CollisionAspect,
            dynamics::DynamicsAspect,
            dynamics::VisualAspect>(terrainShape);

    return terrainSkel;

}

I am not sure if this is really a bug , or if it is just me doing something wrong here.
Would be great if someone with expertise on the matter could guide me with this.

Thanks in advance.

@ibrahiminfinite ibrahiminfinite added the type: bug Indicates an unexpected problem or unintended behavior label Mar 22, 2022
@jslee02 jslee02 added the help wanted Indicates wanting help on an issue or pull request label Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Indicates wanting help on an issue or pull request type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants