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

send_joint_speeds does not work as expected #3

Closed
Achllle opened this issue Feb 20, 2019 · 3 comments
Closed

send_joint_speeds does not work as expected #3

Achllle opened this issue Feb 20, 2019 · 3 comments

Comments

@Achllle
Copy link
Contributor

Achllle commented Feb 20, 2019

Description

send_joint_speeds action doesn't work using code based on examples provided in api_cpp and api_python and using the auto-generated documentation as a reference

Side note: issue template didn't load automatically.

Version

KortexAPI : 1.1.3
Kortex Device : Jaco GEN3 7DOF

Steps to reproduce

Python

  1. edit the move angular example
  2. replace the joint angles example in angular movement with joint speeds code, see below
  3. set angle_value variable to an array of non-zero values (e.g. [0,0,0,0,0,0,5]) for 5deg/s for the 7th DOF.

c++

Same as Python steps, except with the api_cpp example.

Code example

Note: I didn't change the names of the variables

Python

When I convert any joint angle reference to joint speed references 1:1, i.e.

for joint_id in range(7):
    joint_angle = action.send_joint_speeds.joint_angles.joint_speeds.add()
    # joint_angle = action.send_joint_speeds.joint_speeds.add()
    joint_angle.joint_identifier = joint_id
    joint_angle.value = angle_value[joint_id]
    joint_angle.duration = 5

I get an AttributeError: 'JointSpeeds' object has no attribute 'joint_angles'. When I comment out the second line in the example above and replace it with the commented line right below it, I don't get the AttributeError (which I believe shouldn't have happened in the first place) and the code executes but doesn't move the last joint.

c++

in angularMovement():

    auto action = k_api::Base::Action();
    action.set_name("Example angular movement");
    action.set_application_data("");

    auto reachJointAngles = action.mutable_send_joint_speeds();
    auto jointAngles = reachJointAngles->mutable_joint_speeds();

    std::vector<float> angles = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.0f};
    for(size_t i = 0 ; i < angles.size(); ++i)
    {
        auto jointAngle = jointAngles->add_joint_speeds();
        // auto jointAngle = reachJointAngles->add_joint_speeds();
        jointAngle->set_joint_identifier(i);
        jointAngle->set_value(angles.at(i));
    }

This results in

error: ‘class google::protobuf::RepeatedPtrField<Kinova::Api::Base::JointSpeed>’ has no member named ‘add_joint_speeds’
         auto jointAngle = jointAngles->add_joint_speeds();

Again, commenting out the first line in the for-loop and replacing with the commented line results in a successful build, but results in a segfault during execution on the robot.

Expected behavior

The final joint rotates at ~5 deg/s for 5 seconds

@sjhansen3
Copy link

@nsaif-kinova Here is the issue we referenced earlier.

@alexvannobel
Copy link
Contributor

alexvannobel commented Feb 21, 2019

Hi @Achllle !

Thanks for filling the issue template, it really helps troubleshooting your problem!

It seems the SendJointSpeedsCommand RPC call was not implemented inside the arm, although it is not documented as such. Hence, the ExecuteAction call you make will not work either. I will make sure the documentation gets updated to include this detail.
The SendJointSpeedsCommand function will be implemented in a future release.

Although the function is unsupported for now, I can explain the solution to the build problem you are facing. I'll explain it for the C++ example but it naturally works for the Python too.

Basically, the reach_joint_angles and send_joint_speeds Actions are not built the same way.

  • The reach_joint_angles Action has a ConstrainedJointAngles field, which you get a reference to with
    auto reachJointAngles = action.mutable_reach_joint_angles();
    The ConstrainedJointAngles field, in turn, has a JointAngles field, which you get a reference to with
    auto jointAngles = reachJointAngles->mutable_joint_angles();
    This is the array in which we add individual angles with the add_joint_angles() method.

  • The send_joint_speeds Action has a JointSpeeds field, which you could get a reference to with
    auto jointSpeeds = action.mutable_send_joint_speeds();. This is the array in which we add individual joint speeds with the add_joint_speeds() method.

The C++ code snippet to control the arm with a send_joint_speeds Action would look like :

auto jointSpeeds = action.mutable_send_joint_speeds();

std::vector<float> speeds = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.0f}; // Actuator 7 rotates at 5deg/s for 5s
for(size_t i = 0 ; i < speeds.size(); ++i)
{
    auto jointSpeed = jointSpeeds->add_joint_speeds();
    jointSpeed->set_joint_identifier(i);
    jointSpeed->set_value(speeds.at(i));
    jointSpeed->set_duration(5);
}

but again, won't work until the function is implemented inside the arm.

Sorry for the inconvenience and I will make sure to update this issue when the arm's software package will include this functionality.

Cheers,

Alex

@alexvannobel
Copy link
Contributor

Hi @Achllle ,

The SendJointSpeedsCommand function is now available with the 2.0 release.
I'll close this issue, but feel free to open a new one if there is anything with the functionality.

Best,
Alex

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

No branches or pull requests

3 participants