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

JointPositionController: Improve misleading error message #1098

Merged
merged 8 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/rendering/SceneManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ rendering::MaterialPtr SceneManager::LoadMaterial(
}
else
{
const sdf::PbrWorkflow *specular=
pbr->Workflow(sdf::PbrWorkflowType::SPECULAR);
auto specular = pbr->Workflow(sdf::PbrWorkflowType::SPECULAR);
if (specular)
{
ignerr << "PBR material: currently only metal workflow is supported. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <ignition/msgs/double.pb.h>

#include <string>
#include <unordered_set>

#include <ignition/common/Profiler.hh>
#include <ignition/math/PID.hh>
Expand Down Expand Up @@ -206,21 +207,24 @@ void JointPositionController::PreUpdate(
_ecm.CreateComponent(
this->dataPtr->jointEntity, components::JointPosition());
}
if (jointPosComp == nullptr)
// We just created the joint position component, give one iteration for the
// physics system to update its size
if (jointPosComp == nullptr || jointPosComp->Data().empty())
return;

// Sanity check: Make sure that the joint index is valid.
if (this->dataPtr->jointIndex >= jointPosComp->Data().size())
{
static bool invalidJointReported = false;
if (!invalidJointReported)
static std::unordered_set<Entity> reported;
if (reported.find(this->dataPtr->jointEntity) == reported.end())
{
ignerr << "[JointPositionController]: Detected an invalid <joint_index> "
<< "parameter. The index specified is ["
<< this->dataPtr->jointIndex << "] but the joint only has ["
<< this->dataPtr->jointIndex << "] but joint ["
<< this->dataPtr->jointName << "] only has ["
<< jointPosComp->Data().size() << "] index[es]. "
<< "This controller will be ignored" << std::endl;
invalidJointReported = true;
reported.insert(this->dataPtr->jointEntity);
}
return;
}
Expand Down
3 changes: 1 addition & 2 deletions src/systems/physics/Physics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2207,8 +2207,7 @@ void PhysicsPrivate::UpdateSim(EntityComponentManager &_ecm)
if (auto jointPhys = this->entityJointMap.Get(_entity))
{
_jointPos->Data().resize(jointPhys->GetDegreesOfFreedom());
for (std::size_t i = 0; i < jointPhys->GetDegreesOfFreedom();
++i)
for (std::size_t i = 0; i < jointPhys->GetDegreesOfFreedom(); ++i)
{
_jointPos->Data()[i] = jointPhys->GetPosition(i);
}
Expand Down