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

There's not a generic way to loop over differently named elements. You will need to specifically address them individually.

If you want to loop across elements you can store them in an array. But as these elements appear to be quite specific and different. Aka they're not representing multiple instances of a type the separate variables makes more sense. The temperature and amperage are not interchangeable. And some elements are even of different types which makes iterating even less likely. If you have those 45 things to assign specifically you're going to need to actually assign them individually. This way the compiler will know exactly what you want to do and anyone reading the code will also know what you're doing. Trying to save lines of code to avoid this sort of thing is likely not worth it. If you're assigning into it from a similar data struct in several different places a helper function is the best way to do this.