roboticslibrary / rl

The Robotics Library (RL) is a self-contained C++ library for rigid body kinematics and dynamics, motion planning, and control.
https://www.roboticslibrary.org/
BSD 2-Clause "Simplified" License
940 stars 217 forks source link

Moving non-kinematic scene objects & #62

Open Sebastian-Schroder opened 1 year ago

Sebastian-Schroder commented 1 year ago

Hey I was just wondering if there is an easy way to move scene models in 0.7.0. This is my attempt where we set the frame of each body and then step the rl::hal::Coach ptr, however this doesn't seem to update the

for (::std::size_t i = 0; i < model->getBodies(); ++i) // This sets all the axis models to the position of the arm transforms
        {
            auto t = model->getFrame(i);
            scene.getModel(2)->getBody(i)->setFrame(t); //! This should happen wheneve the model moves instead
        }
        sim_Controller->step();

is there any way to do this? also is it possible to have scene models that don't have collision or remove scene models from the arm's collision using idref. these would be just used for visualising. for example adding axes onto each joint to demonstrate rotation etc etc. Thank you

rickertm commented 1 year ago

The rl::hal::Coach class only acts as an axis controller, with interfaces for joint positions, velocities, and torques. The step() function therefore only exchanges these messages. The socket interface in the rlCoachKin and rlCoachMdl demo applications however have additional message types for receiving updates to body frames and shape transforms.

Update frame of body j in model i (angles are EulerZYX in radians):

0 i j x y z a b c\n

Update transform of shape k in body j in model i (angles are EulerZYX in radians):

1 i j k x y z a b c\n

Update joint positions of model i (angles in radians), provided via rl::hal::Coach::setJointPosition():

2 i q0 q1 q2 ... qn\n

Request joint positions of model i (angles in radians), provided via rl::hal::Coach::getJointPosition():

6 i\n

For visualising axes, you can for instance use IndexedLineSet shapes, as these are ignored by the collision engines (see rl-examples/rlsg/frame.wrl). You can also use completely different geometry models for visualization and collision detection (see the optimized convex hull folders in rl-examples/rlsg/*.convex).