Creating a slope (angled floor)

I create a floor in one of my simulations, but would like to create a situation for a robot to travel up an angled slope… I haven’t had too much luck on finding how to do this! I do have the transform for the x, y, and z, but unfortunately nothing to do with orientation… Hope you can help. The below is my floor code.

  void _add_floor(double friction = 1.0)
    {
        // We do not want 2 floors!
        if (_world->getSkeleton("floor") != nullptr)
            return;

    dart::dynamics::SkeletonPtr floor = dart::dynamics::Skeleton::create("floor");

    // Give the floor a body
    dart::dynamics::BodyNodePtr fbody = floor->createJointAndBodyNodePair<dart::dynamics::WeldJoint>(nullptr).second;
    fbody->setFrictionCoeff(friction);

    // Give the body a shape
    double floor_width = 50.0;
    double floor_height = 0.1;

    auto box = std::make_shared<dart::dynamics::BoxShape>(Eigen::Vector3d(floor_width, floor_width, floor_height));

    auto box_node = fbody->createShapeNodeWith<dart::dynamics::VisualAspect, dart::dynamics::CollisionAspect, dart::dynamics::DynamicsAspect>(box);

    box_node->getVisualAspect()->setColor(dart::Color::Gray());

    // Put the body into position
    Eigen::Isometry3d tf(Eigen::Isometry3d::Identity());
    tf.translation() = Eigen::Vector3d(0.0, 0.0, -floor_height / 2.0);
    fbody->getParentJoint()->setTransformFromParentBodyNode(tf);

    _world->addSkeleton(floor);

}

You are almost there. The orientation can be set using Eigen::Isometry3d::linear() like you did to set the position using Eigen::Isometry3d::translation():

    // Put the body into position
    Eigen::Isometry3d tf(Eigen::Isometry3d::Identity());
    tf.translation() = Eigen::Vector3d(0.0, 0.0, -floor_height / 2.0);

    // using quaternion
    tf.linear() = Eigen::Quaterniond(w, x, y, z).toRotationMatrix();
    // or using Euler angles
    tf.linear() 
        = (Eigen::AngleAxisd(alpha, Eigen::Vector3d::UnitX()) *
           Eigen::AngleAxisd(beta,  Eigen::Vector3d::UnitY()) *
           Eigen::AngleAxisd(gamma, Eigen::Vector3d::UnitZ())).toRotationMatrix();

    fbody->getParentJoint()->setTransformFromParentBodyNode(tf);

Great! I will try this later. Thanks for the quick response.

This works pretty good.

Using Quaternion works, but it does not seem to update collisions e.g. My robot will walk through the slope.

Euler angles work like a charm.

To clarify, do you mean that the collision issue is fine with Euler angles or it doesn’t work for both rotation representations? In any case, it would be easier to help if you share the entire code or minimal code that reproduces the issue.