robotology / assistive-rehab

Assistive and Rehabilitative Robotics
https://robotology.github.io/assistive-rehab/doc/mkdocs/site
BSD 3-Clause "New" or "Revised" License
20 stars 11 forks source link

Add projection of step metrics on skeleton planes, decrease connections load and move console connections to yarp application #321

Closed mfussi66 closed 2 years ago

mfussi66 commented 2 years ago

This PR restores the original plan of projecting the step metrics (such as length, width) along the planes defined by the human body (sagittal, coronal, transverse). This is now possible after fixing the getters for the planes, see the commit: https://github.com/robotology/assistive-rehab/commit/75aa76954fe73309d7fd32f026d08620f7451a8 The getters included a gaze2base transformation that was already embedded in the skeleton keypoints postions. This can be seen in the following piece of code in https://github.com/robotology/assistive-rehab/blob/master/lib/src/skeleton.cpp:

void Skeleton::update()
{
    Vector p(4,1.0);
    for (auto &k:keypoints)
    {
        if (k->isUpdated())
        {
            auto v=k->getPoint();
            auto px=k->getPixel();
            p[0]=v[0];
            p[1]=v[1];
            p[2]=v[2];
+            k->setPoint((T*p).subVector(0,2),px);
        }
    }

+    update_planes();
}

The Keypoints are transformed through the T matrix, then the update_planes() function is called. The function updates coronal, sagittal, and transverse planes with the newly evaluated keypoints. Using the getter in the form of:

Vector Skeleton::getCoronal() const
{
    return (T.submatrix(0,2,0,2)*coronal);
}

would cause the transformation T to be applied twice.

Note: The transformation T is only used to transform the Keypoints.


Some other changes:

For debugging purposes, step length and width are now plotted thanks to a dedicated port /motionAnalyzer/scopeRaw.

Fixes made to lower the load on the machines:

cc @ste93 @elandini84 @randaz81

pattacini commented 2 years ago

Seems there's an ongoing dev on this. Put in draft.

mfussi66 commented 2 years ago

Seems there's an ongoing dev on this. Put in draft.

Yes sorry about that, we noticed that the modifications in the latest 3 commits were necessary for the demo. I'll update the PR description.

mfussi66 commented 2 years ago

would you please trace back the parts in the code where the transformation is done? This is for the record.

@pattacini The transformation matrix is computed by the skeletonRetriever, which computes the matrix from gaze to base, by taking info from the gaze controller and the navigation controller. Then the update() function of the skeleton (in skeleton.cpp) updates the keypoints position by transforming the position in the gaze frame to the base frame. The update() also is tasked with updating the skeleton planes.