Skip to content

Commit

Permalink
Fixed the loading of sensors/actuators and changed logic of adding sc…
Browse files Browse the repository at this point in the history
…ene objects
  • Loading branch information
adnanmunawar committed Feb 4, 2021
1 parent 2004363 commit f6fa550
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 74 deletions.
16 changes: 10 additions & 6 deletions adf_loader/version_1_0/adf_loader_1_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,8 @@ bool ADFLoader_1_0::loadRayTracerSensorAttribs(YAML::Node *a_node, afRayTracerSe
return 0;
}

attribs->m_sensorType = afSensorType::RAYTRACER;

bool result = true;
// Declare all the yaml parameters that we want to look for
YAML::Node parentNameNode = node["parent"];
Expand Down Expand Up @@ -1695,6 +1697,8 @@ bool ADFLoader_1_0::loadResistanceSensorAttribs(YAML::Node *a_node, afResistance
bool result = false;
result = loadRayTracerSensorAttribs(a_node, attribs);

attribs->m_sensorType = afSensorType::RESISTANCE;

if (result){

YAML::Node resistiveFrictionNode = node["friction"];
Expand Down Expand Up @@ -2146,14 +2150,14 @@ bool ADFLoader_1_0::loadModelAttribs(YAML::Node *a_node, afModelAttributes *attr
afSensorType senType = ADFUtils::getSensorTypeFromString(senNode["type"].as<string>());
switch (senType) {
case afSensorType::RAYTRACER:{
afRayTracerSensorAttributes senAttribs;
loadRayTracerSensorAttribs(&senNode, &senAttribs);
afRayTracerSensorAttributes* senAttribs = new afRayTracerSensorAttributes();
loadRayTracerSensorAttribs(&senNode, senAttribs);
attribs->m_sensorAttribs.push_back(senAttribs);
break;
}
case afSensorType::RESISTANCE:{
afResistanceSensorAttributes senAttribs;
loadResistanceSensorAttribs(&senNode, &senAttribs);
afResistanceSensorAttributes* senAttribs = new afResistanceSensorAttributes();
loadResistanceSensorAttribs(&senNode, senAttribs);
attribs->m_sensorAttribs.push_back(senAttribs);
break;
}
Expand All @@ -2174,8 +2178,8 @@ bool ADFLoader_1_0::loadModelAttribs(YAML::Node *a_node, afModelAttributes *attr
// Check if this is a constraint sensor
switch (actType) {
case afActuatorType::CONSTRAINT:{
afConstraintActuatorAttributes acAttribs;
loadConstraintActuatorAttribs(&actNode, &acAttribs);
afConstraintActuatorAttributes* acAttribs = new afConstraintActuatorAttributes();
loadConstraintActuatorAttribs(&actNode, acAttribs);
attribs->m_actuatorAttribs.push_back(acAttribs);
break;
}
Expand Down
12 changes: 6 additions & 6 deletions ambf_framework/afAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,8 @@ struct afModelAttributes: public afBaseObjectAttributes, public afFileObjectAttr
std::vector <afSoftBodyAttributes> m_softBodyAttribs;
std::vector <afVehicleAttributes> m_vehicleAttribs;
std::vector <afJointAttributes> m_jointAttribs;
std::vector <afSensorAttributes> m_sensorAttribs;
std::vector <afActuatorAttributes> m_actuatorAttribs;
std::vector <afSensorAttributes*> m_sensorAttribs;
std::vector <afActuatorAttributes*> m_actuatorAttribs;

bool m_ignoreInterCollision;

Expand All @@ -848,11 +848,11 @@ struct afModelAttributes: public afBaseObjectAttributes, public afFileObjectAttr
}

for (int i = 0 ; i < m_sensorAttribs.size() ; i++){
m_sensorAttribs[i].resolveRelativeNamespace(a_parentNamespace);
m_sensorAttribs[i]->resolveRelativeNamespace(a_parentNamespace);
}

for (int i = 0 ; i < m_actuatorAttribs.size() ; i++){
m_actuatorAttribs[i].resolveRelativeNamespace(a_parentNamespace);
m_actuatorAttribs[i]->resolveRelativeNamespace(a_parentNamespace);
}

m_namespaceResolved = true;
Expand All @@ -877,11 +877,11 @@ struct afModelAttributes: public afBaseObjectAttributes, public afFileObjectAttr
}

for (int i = 0 ; i < m_sensorAttribs.size() ; i++){
m_sensorAttribs[i].resolveRelativePathAttribs(a_parentPath);
m_sensorAttribs[i]->resolveRelativePathAttribs(a_parentPath);
}

for (int i = 0 ; i < m_actuatorAttribs.size() ; i++){
m_actuatorAttribs[i].resolveRelativePathAttribs(a_parentPath);
m_actuatorAttribs[i]->resolveRelativePathAttribs(a_parentPath);
}

m_pathsResolved = true;
Expand Down
Loading

0 comments on commit f6fa550

Please sign in to comment.