Can’t we build motors like this?
Is the sequence of Motor constructor execution?
code:
readSDcard(&_chassisPram, “/usd/chassis.txt”, “chassis”);
for (auto it = _chassisPram.begin(); it != _chassisPram.end(); it += 2)
{
if (it->first.find(“motor”) != std::string::npos)
{
_motorList.push_back(pros::Motor(stringToNum<uint8_t>(it->second), stringToNum<uint8_t>((it + 1)->second)));
std::cout << _name << “port:” << stringToNum<uint8_t>(it->second) << “isRevase:” << stringToNum<uint8_t>((it + 1)->second) << std::endl;
}
}
This can be done in previous versions.
After the update, I correctly read the value on the SD card, STD:: COUT can see. But no device can succeed.
I’m not sure why. Because I modified the stringToNum function.
But the strange test “std:: cout “means that he read the correct value” explicit pros:: Motor”" class determines the parameters before the link occurs?
i use “std::vector<std::pairstd::string,std::string>” to save sd card data;
use
template
T stringToNum(const std::string &str)
{
std::istringstream iss(str);
T num;
iss >> num;
return num;b
}
to change string to nums;
but "pros::Motor pros::ADI " can’t be constructed;
Other common parameters can be read normally.