Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

RoboDK C API Item_SetJoints() Ignores joints after 6th

#1
Pretty much the title. For a 6DoF robot, this prevents any external axes from being set using the C API.

Current code for reference:
Code:
void Item_SetJoints(const struct Item_t* inst, struct Joints_t jnts) {
    double angles[6];
    angles[0] = jnts._Values[0];
    angles[1] = jnts._Values[1];
    angles[2] = jnts._Values[2];
    angles[3] = jnts._Values[3];
    angles[4] = jnts._Values[4];
    angles[5] = jnts._Values[5];
    _RoboDK_check_connection(inst->_RDK);
    _RoboDK_send_Line(inst->_RDK, "S_Thetas");
    _RoboDK_send_Array(inst->_RDK, angles, jnts._nDOFs);
    _RoboDK_send_Item(inst->_RDK, inst);
    _RoboDK_check_status(inst->_RDK);
}

I tried just changing it in robodk_api_c.c and it seems to have worked:
Code:
void Item_SetJoints(const struct Item_t* inst, struct Joints_t jnts) {
    double angles[7];
    angles[0] = jnts._Values[0];
    angles[1] = jnts._Values[1];
    angles[2] = jnts._Values[2];
    angles[3] = jnts._Values[3];
    angles[4] = jnts._Values[4];
    angles[5] = jnts._Values[5];
    angles[6] = jnts._Values[6];
    _RoboDK_check_connection(inst->_RDK);
    _RoboDK_send_Line(inst->_RDK, "S_Thetas");
    _RoboDK_send_Array(inst->_RDK, angles, jnts._nDOFs);
    _RoboDK_send_Item(inst->_RDK, inst);
    _RoboDK_check_status(inst->_RDK);
}

It worked in the one test I did, but I have no way of knowing this isn't overwriting beyond the allocated memory when RoboDK receives it, so it would be good to get confirmation from you that this is well-supported before I commit it.

Additionally, if `struct Joints_t` supports up to `RDK_SIZE_JOINTS_MAX`, then `Item_SetJoints` should also support up to `RDK_SIZE_JOINTS_MAX` joints. If that is not the case, it should be loudly documented. Issues like this can cost users hours of pointless debugging...
#2
Good point, this was a strange constrain of just focing 6-axis on any mechanism. Thank you for pointing this out.

I just pushed an updated version of the C API of RoboDK to fix the 6-axis constrain for setJoints and setJointsHome functions:
https://github.com/RoboDK/RoboDK-API/com...0b0c350465

In short, the setJoints function should look like this:
Code:
void Item_SetJoints(const struct Item_t* inst, struct Joints_t jnts) {
    _RoboDK_check_connection(inst->_RDK);
    _RoboDK_send_Line(inst->_RDK, "S_Thetas");
    _RoboDK_send_Array(inst->_RDK, jnts._Values, jnts._nDOFs);
    _RoboDK_send_Item(inst->_RDK, inst);
    _RoboDK_check_status(inst->_RDK);
}
  




Users browsing this thread:
1 Guest(s)