Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MulticopterMotorModel uses improper SDF formatting. #1980

Open
bperseghetti opened this issue May 2, 2023 · 0 comments · May be fixed by #1981
Open

MulticopterMotorModel uses improper SDF formatting. #1980

bperseghetti opened this issue May 2, 2023 · 0 comments · May be fixed by #1981
Labels
bug Something isn't working

Comments

@bperseghetti
Copy link
Collaborator

MulticopterMotorModel uses improper SDF formatting:

Examples:

// Get params from SDF
if (sdfClone->HasElement("jointName"))
{
this->dataPtr->jointName = sdfClone->Get<std::string>("jointName");
}
if (this->dataPtr->jointName.empty())
{
gzerr << "MulticopterMotorModel found an empty jointName parameter. "
<< "Failed to initialize.";
return;
}
if (sdfClone->HasElement("linkName"))
{
this->dataPtr->linkName = sdfClone->Get<std::string>("linkName");
}
if (this->dataPtr->linkName.empty())
{
gzerr << "MulticopterMotorModel found an empty linkName parameter. "
<< "Failed to initialize.";
return;
}

if (sdfClone->HasElement("turningDirection"))
{
auto turningDirection =
sdfClone->GetElement("turningDirection")->Get<std::string>();
if (turningDirection == "cw")
this->dataPtr->turningDirection = turning_direction::kCw;
else if (turningDirection == "ccw")
this->dataPtr->turningDirection = turning_direction::kCcw;
else
gzerr << "Please only use 'cw' or 'ccw' as turningDirection.\n";
}
else
{
gzerr << "Please specify a turning direction ('cw' or 'ccw').\n";
}
if (sdfClone->HasElement("motorType"))
{
auto motorType = sdfClone->GetElement("motorType")->Get<std::string>();
if (motorType == "velocity")
this->dataPtr->motorType = MotorType::kVelocity;
else if (motorType == "position")
{
this->dataPtr->motorType = MotorType::kPosition;
gzerr << "motorType 'position' not supported" << std::endl;
}
else if (motorType == "force")
{
this->dataPtr->motorType = MotorType::kForce;
gzerr << "motorType 'force' not supported" << std::endl;
}
else
{
gzerr << "Please only use 'velocity', 'position' or "
"'force' as motorType.\n";
}
}
else
{
gzwarn << "motorType not specified, using velocity.\n";
this->dataPtr->motorType = MotorType::kVelocity;
}
sdfClone->Get<std::string>("commandSubTopic",
this->dataPtr->commandSubTopic, this->dataPtr->commandSubTopic);
sdfClone->Get<double>("rotorDragCoefficient",
this->dataPtr->rotorDragCoefficient,
this->dataPtr->rotorDragCoefficient);
sdfClone->Get<double>("rollingMomentCoefficient",
this->dataPtr->rollingMomentCoefficient,
this->dataPtr->rollingMomentCoefficient);
sdfClone->Get<double>("maxRotVelocity",
this->dataPtr->maxRotVelocity, this->dataPtr->maxRotVelocity);
sdfClone->Get<double>("motorConstant",
this->dataPtr->motorConstant, this->dataPtr->motorConstant);
sdfClone->Get<double>("momentConstant",
this->dataPtr->momentConstant, this->dataPtr->momentConstant);
sdfClone->Get<double>("timeConstantUp",
this->dataPtr->timeConstantUp, this->dataPtr->timeConstantUp);
sdfClone->Get<double>("timeConstantDown",
this->dataPtr->timeConstantDown, this->dataPtr->timeConstantDown);
sdfClone->Get<double>("rotorVelocitySlowdownSim",
this->dataPtr->rotorVelocitySlowdownSim, 10);

@bperseghetti bperseghetti added the bug Something isn't working label May 2, 2023
@osrf-triage osrf-triage added this to Inbox in Core development May 2, 2023
@bperseghetti bperseghetti linked a pull request May 2, 2023 that will close this issue
8 tasks
@azeey azeey removed this from Inbox in Core development May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant