Skip to content

Commit 137a3aa

Browse files
committed
Implemented Contact Sensors and GhostObject ROS Comm
1 parent 89a50f7 commit 137a3aa

29 files changed

+1089
-86
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## June 26 2024
2+
1. Removed setting forces and torques in the Ghost Object update
3+
2. Added ROS Communication Support for Ghost Objects
4+
3. Create Contact Sensors and implemented their ROS communication
5+
4. Created CHANGELOG file

adf_loader/version_1_0/adf_loader_1_0.cpp

+56-1
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ afSensorType ADFUtils::getSensorTypeFromString(const string &a_str)
475475
else if (a_str.compare("Resistance") == 0 || a_str.compare("resistance") == 0 || a_str.compare("RESISTANCE") == 0){
476476
type = afSensorType::RESISTANCE;
477477
}
478+
else if (a_str.compare("Contact") == 0 || a_str.compare("contact") == 0 || a_str.compare("CONTACT") == 0){
479+
type = afSensorType::CONTACT;
480+
}
478481

479482
return type;
480483
}
@@ -1982,6 +1985,9 @@ bool ADFLoader_1_0::loadSensorAttribs(YAML::Node *a_node, afSensorAttributes *at
19821985
}
19831986
case afSensorType::RESISTANCE:{
19841987
return loadResistanceSensorAttribs(a_node, (afResistanceSensorAttributes*)attribs);
1988+
}
1989+
case afSensorType::CONTACT:{
1990+
return loadContactSensorAttribs(a_node, (afContactSensorAttributes*)attribs);
19851991
}
19861992
break;
19871993
default:{
@@ -2117,7 +2123,7 @@ bool ADFLoader_1_0::loadResistanceSensorAttribs(YAML::Node *a_node, afResistance
21172123
{
21182124
YAML::Node& node = *a_node;
21192125
if (node.IsNull()){
2120-
cerr << "ERROR! ACTUATOR'S YAML CONFIG DATA IS NULL\n";
2126+
cerr << "ERROR! SENSOR'S YAML CONFIG DATA IS NULL\n";
21212127
return 0;
21222128
}
21232129
ADFUtils::saveRawData(a_node, attribs);
@@ -2163,6 +2169,51 @@ bool ADFLoader_1_0::loadResistanceSensorAttribs(YAML::Node *a_node, afResistance
21632169
return result;
21642170
}
21652171

2172+
bool ADFLoader_1_0::loadContactSensorAttribs(YAML::Node *a_node, afContactSensorAttributes *attribs)
2173+
{
2174+
YAML::Node& node = *a_node;
2175+
if (node.IsNull()){
2176+
cerr << "ERROR! SENSOR'S YAML CONFIG DATA IS NULL\n";
2177+
return 0;
2178+
}
2179+
ADFUtils::saveRawData(a_node, attribs);
2180+
2181+
bool result = true;
2182+
2183+
YAML::Node nameNode = node["name"];
2184+
YAML::Node namespaceNode = node["namespace"];
2185+
YAML::Node parentNameNode = node["parent"];
2186+
YAML::Node visibleNode = node["visible"];
2187+
YAML::Node visibleSizeNode = node["visible size"];
2188+
YAML::Node publishFrequencyNode = node["publish frequency"];
2189+
YAML::Node distanceThresholdNode = node["distance threshold"];
2190+
YAML::Node processContactDetailsNode = node["process contact details"];
2191+
2192+
ADFUtils::getIdentificationAttribsFromNode(a_node, &attribs->m_identificationAttribs);
2193+
ADFUtils::getHierarchyAttribsFromNode(a_node, &attribs->m_hierarchyAttribs);
2194+
ADFUtils::getCommunicationAttribsFromNode(a_node, &attribs->m_communicationAttribs);
2195+
ADFUtils::getPluginAttribsFromNode(a_node, &attribs->m_pluginAttribs);
2196+
2197+
2198+
if (visibleNode.IsDefined()){
2199+
attribs->m_visible = visibleNode.as<bool>();
2200+
}
2201+
2202+
if (visibleSizeNode.IsDefined()){
2203+
attribs->m_visibleSize = visibleSizeNode.as<double>();
2204+
}
2205+
2206+
if (distanceThresholdNode.IsDefined()){
2207+
attribs->m_distanceThreshold = distanceThresholdNode.as<double>();
2208+
}
2209+
2210+
if (processContactDetailsNode.IsDefined()){
2211+
attribs->m_processContactDetails = processContactDetailsNode.as<bool>();
2212+
}
2213+
2214+
return result;
2215+
}
2216+
21662217
bool ADFLoader_1_0::loadActuatorAttribs(YAML::Node *a_node, afActuatorAttributes *attribs)
21672218
{
21682219
YAML::Node& node = *a_node;
@@ -2729,6 +2780,10 @@ bool ADFLoader_1_0::loadModelAttribs(YAML::Node *a_node, afModelAttributes *attr
27292780
senAttribs = new afResistanceSensorAttributes();
27302781
break;
27312782
}
2783+
case afSensorType::CONTACT:{
2784+
senAttribs = new afContactSensorAttributes();
2785+
break;
2786+
}
27322787
default:
27332788
break;
27342789
}

adf_loader/version_1_0/adf_loader_1_0.h

+3
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ class ADFLoader_1_0: public ADFLoaderBase{
151151
// Load joint from a YAML::Node
152152
virtual bool loadResistanceSensorAttribs(YAML::Node* a_node, afResistanceSensorAttributes* attribs);
153153

154+
// Load joint from a YAML::Node
155+
virtual bool loadContactSensorAttribs(YAML::Node* a_node, afContactSensorAttributes* attribs);
156+
154157
// Load actuator from a YAML::Node
155158
virtual bool loadActuatorAttribs(YAML::Node* a_node, afActuatorAttributes* attribs);
156159

ambf_framework/afAttributes.h

+16
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,22 @@ struct afResistanceSensorAttributes: public afRayTracerSensorAttributes{
11041104
};
11051105

11061106

1107+
struct afContactSensorAttributes: public afSensorAttributes{
1108+
public:
1109+
afContactSensorAttributes(){
1110+
m_distanceThreshold = 0.0;
1111+
m_processContactDetails = true;
1112+
m_visible = false;
1113+
m_visibleSize = 10;
1114+
}
1115+
1116+
double m_distanceThreshold; // Distance threshold between objects for contact to count
1117+
bool m_processContactDetails; // If true, process contact ponits, normals, etc. Otherwise just names of objects in contact
1118+
bool m_visible;
1119+
double m_visibleSize;
1120+
};
1121+
1122+
11071123
struct afFileObjectAttributes{
11081124
public:
11091125
afFileObjectAttributes(){}

ambf_framework/afEnums.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ enum class afSensorType{
174174
RAYTRACER = 0,
175175
RANGE = 1,
176176
RESISTANCE = 2,
177-
INVALID = 3
177+
CONTACT = 3,
178+
INVALID = 4
178179
};
179180

180181

0 commit comments

Comments
 (0)