Dynamically creating topic names [closed]
ROS Melodic 1.14.3 & rosserial_arduino
I'm dealing with a crazy bug. I want to name my topic dynamically, concatenating "imu" with an int, but rosserial_server crash launching an exception: "what(): Character [] is not valid as the first character in Graph Resource Name []. Valid characters are a-z, A-Z, / and in some cases ~." The topic name seems to be ok, but I can't understand why rosserial_server is crashing (if I put the same topic name, but hardcoded, it doesn't crash).
pub.push_back(new ros::Publisher(("imu" + std::to_string(i)).c_str(), str_msgs[i]));