ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assuming FR_0 = 0, FR_1 = 1, FR_2 = 2, FL_0 = 3, FL_1 = 4, and so on

int j=0;
    for(int i=0; i<4;i++)
    {    
        j = 3*i;    
        SendLowROS.motorCmd[j].Kp = msg.Kp[0];
        SendLowROS.motorCmd[j+1].Kp = msg.Kp[1];
        SendLowROS.motorCmd[j+2].Kp = msg.Kp[2];
    }

Note: for higher optimization you can remove the j and modify the loop's condition.

If you can supply the values for the: FR_0, FR_1, FR_2, FL_0, FL_1, ..., a more reasonable solution can be found.