Unpacking ROS messages
Any suggestions to reduce this repetitive code:
SendLowROS.motorCmd[FR_0].Kp = msg.Kp[0];
SendLowROS.motorCmd[FR_1].Kp = msg.Kp[1];
SendLowROS.motorCmd[FR_2].Kp = msg.Kp[2];
SendLowROS.motorCmd[FL_0].Kp = msg.Kp[0];
SendLowROS.motorCmd[FL_1].Kp = msg.Kp[1];
SendLowROS.motorCmd[FL_2].Kp = msg.Kp[2];
SendLowROS.motorCmd[RR_0].Kp = msg.Kp[0];
SendLowROS.motorCmd[RR_1].Kp = msg.Kp[1];
SendLowROS.motorCmd[RR_2].Kp = msg.Kp[2];
SendLowROS.motorCmd[RL_0].Kp = msg.Kp[0];
SendLowROS.motorCmd[RL_1].Kp = msg.Kp[1];
SendLowROS.motorCmd[RL_2].Kp = msg.Kp[2];
I am trying to use strucutred binding/similar unpacking concepts like std::tie and std::tuple but unfortunatley no success so far.
auto [SendLowROS.motorCmd[FR_0].Kp, SendLowROS.motorCmd[FR_1].Kp, SendLowROS.motorCmd[FR_2].Kp,
SendLowROS.motorCmd[FL_0].Kp, SendLowROS.motorCmd[FL_1].Kp, SendLowROS.motorCmd[FL_2].Kp,
SendLowROS.motorCmd[RR_0].Kp, SendLowROS.motorCmd[RR_1].Kp, SendLowROS.motorCmd[RR_2].Kp,
SendLowROS.motorCmd[RL_0].Kp, SendLowROS.motorCmd[RL_1].Kp, SendLowROS.motorCmd[RL_2].Kp] = msg.Kd;
and another approach
std::tie(SendLowROS.motorCmd[FR_0].Kp, SendLowROS.motorCmd[FR_1].Kp, SendLowROS.motorCmd[FR_2].Kp,
SendLowROS.motorCmd[FL_0].Kp, SendLowROS.motorCmd[FL_1].Kp, SendLowROS.motorCmd[FL_2].Kp,
SendLowROS.motorCmd[RR_0].Kp, SendLowROS.motorCmd[RR_1].Kp, SendLowROS.motorCmd[RR_2].Kp,
SendLowROS.motorCmd[RL_0].Kp, SendLowROS.motorCmd[RL_1].Kp, SendLowROS.motorCmd[RL_2].Kp) = std::tuple(msg.Kd);