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

Unable to obtain feedback information #185

Open
xh16166 opened this issue Aug 29, 2023 · 1 comment
Open

Unable to obtain feedback information #185

xh16166 opened this issue Aug 29, 2023 · 1 comment

Comments

@xh16166
Copy link

xh16166 commented Aug 29, 2023

I want to use the high level mode to send speed to the robot and simultaneously obtain feedback information on the robot's joint position, speed, and torque. I used the Async method, but my program encountered the following error:
Robot connection successful
[libprotobuf FATAL /home/robot/kortex-XH/api_cpp/examples/kortex_api/include/google/protobuf/repeated_field.h:1522] CHECK failed: (index) < (current_size_):
terminate called after throwing an instance of 'google::protobuf::FatalException'
what(): CHECK failed: (index) < (current_size_):

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

When sending speed, the robot does indeed move, and the program does not enter the while loop, so joint information is not printed. I want to know how to solve this problem. Here is my program. I hope someone can help me check it. Thank you very much for your reply.

#include "kortex_api/include/common/KortexRobot.h"
#include "iostream"
#include "utilities.h"
#if defined(_MSC_VER)
#include <Windows.h>
#else
#include <unistd.h>
#endif
#include <time.h>

#include //pinocchio

#include
#include <boost/asio.hpp>
#include
#include
#include
#include
#include

int main(int argc, char **argv)
{

KortexRobot robot = KortexRobot("192.168.1.10");


int num = robot.GetNbDof();


if (robot.IsConnected())
{

    std::cout << "Robot connection successful" << std::endl;

    //Subscription notifications
    robot.SubscribeToNotifications();

    // Asynchronous thread sending speed and running for two seconds
    auto async_task = std::async(std::launch::async, [&robot]() {

        std::vector<float> speeds{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f};
        robot.SetJointSpeeds(speeds);
        std::this_thread::sleep_for(std::chrono::milliseconds(2000));
        //Unsubscribe Notifications
        robot.UnsubscribeToNotifications();
        robot.stop();
    });

    // Main thread refresh feedback
    while (async_task.wait_for(std::chrono::milliseconds(1)) != std::future_status::ready) {
        robot.RefreshFeedback();
        std::vector<float> jointPositions = robot.GetJointPositions();
        std::vector<float> jointVelocities = robot.GetJointVelocities();
        std::vector<float> jointTorques = robot.GetJointTorques();

        cout << "Print joint information " << endl;

        for (int i = 0; i < robot.GetNbDof(); i++)
        {
            std::cout <<"Joint" << i <<"\t Position" << jointPositions[i] <<"\t Velocity" << jointVelocities[i] << "\t Torque" << jointTorques[i] << std::endl;
        }

        std::this_thread::sleep_for(std::chrono::milliseconds(1));

    }


}

std::cout << "End of example" << std::endl;

}

@martinleroux
Copy link
Collaborator

Hi @xh16166 ,

I don't have enough information with the code you provided to identify the cause of this issue.
Can you tell me which line is triggering the fault?
I would also need to see the implementation of your KortexRobot class.

In the meantime, you can just make sure that your baseCyclic client is using a router real-time, with UDP transport via port 10001.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants