Skip to content
Snippets Groups Projects
Commit bf8826f4 authored by Mirko Wächter's avatar Mirko Wächter
Browse files

ft sim can now provide multiple sensors

parent 33d96c4f
No related branches found
No related tags found
No related merge requests found
...@@ -32,18 +32,20 @@ using namespace armarx; ...@@ -32,18 +32,20 @@ using namespace armarx;
void ForceTorqueUnitSimulation::onInitForceTorqueUnit() void ForceTorqueUnitSimulation::onInitForceTorqueUnit()
{ {
int intervalMs = getProperty<int>("IntervalMs").getValue(); int intervalMs = getProperty<int>("IntervalMs").getValue();
std::string sensorName = getProperty<std::string>("SensorName").getValue();
sensorNamesList = Split(getProperty<std::string>("SensorNames").getValue(), ",");
for (auto & sensor : sensorNamesList)
{
boost::trim(sensor);
}
//std::vector<std::string> sensorNamesList; //std::vector<std::string> sensorNamesList;
//boost::split(sensorNamesList, sensorNames, boost::is_any_of(",")); //boost::split(sensorNamesList, sensorNames, boost::is_any_of(","));
//for(std::vector<std::string>::iterator s = sensorNamesList.begin(); s != sensorNamesList.end(); s++) for (std::vector<std::string>::iterator s = sensorNamesList.begin(); s != sensorNamesList.end(); s++)
//{ {
// forces[*s] = new armarx::FramedDirection(Eigen::Vector3f(0, 0, 0), *s); forces[*s] = new armarx::FramedDirection(Eigen::Vector3f(0, 0, 0), *s, getProperty<std::string>("AgentName").getValue());
// torques[*s] = new armarx::FramedDirection(Eigen::Vector3f(0, 0, 0), *s); torques[*s] = new armarx::FramedDirection(Eigen::Vector3f(0, 0, 0), *s, getProperty<std::string>("AgentName").getValue());
// } }
forces = new armarx::FramedDirection(Eigen::Vector3f(0, 0, 0), sensorName, getProperty<std::string>("AgentName").getValue());
torques = new armarx::FramedDirection(Eigen::Vector3f(0, 0, 0), sensorName, getProperty<std::string>("AgentName").getValue());
ARMARX_VERBOSE << "Starting ForceTorqueUnitSimulation with " << intervalMs << " ms interval"; ARMARX_VERBOSE << "Starting ForceTorqueUnitSimulation with " << intervalMs << " ms interval";
simulationTask = new PeriodicTask<ForceTorqueUnitSimulation>(this, &ForceTorqueUnitSimulation::simulationFunction, intervalMs, false, "ForceTorqueUnitSimulation"); simulationTask = new PeriodicTask<ForceTorqueUnitSimulation>(this, &ForceTorqueUnitSimulation::simulationFunction, intervalMs, false, "ForceTorqueUnitSimulation");
...@@ -63,7 +65,11 @@ void ForceTorqueUnitSimulation::onExitForceTorqueUnit() ...@@ -63,7 +65,11 @@ void ForceTorqueUnitSimulation::onExitForceTorqueUnit()
void ForceTorqueUnitSimulation::simulationFunction() void ForceTorqueUnitSimulation::simulationFunction()
{ {
listenerPrx->reportSensorValues(getProperty<std::string>("SensorName").getValue(), forces, torques);
for (auto & sensor : sensorNamesList)
{
listenerPrx->reportSensorValues(sensor, forces[sensor], torques[sensor]);
}
//listenerPrx->reportSensorValues(forces); //listenerPrx->reportSensorValues(forces);
//listenerPrx->reportSensorValues(torques); //listenerPrx->reportSensorValues(torques);
......
...@@ -48,8 +48,9 @@ namespace armarx ...@@ -48,8 +48,9 @@ namespace armarx
ForceTorqueUnitSimulationPropertyDefinitions(std::string prefix) : ForceTorqueUnitSimulationPropertyDefinitions(std::string prefix) :
ForceTorqueUnitPropertyDefinitions(prefix) ForceTorqueUnitPropertyDefinitions(prefix)
{ {
defineRequiredProperty<std::string>("SensorName", "simulated sensor name"); defineRequiredProperty<std::string>("SensorNames", "simulated sensor name. seperated by comma");
defineOptionalProperty<int>("IntervalMs", 10, "The time in milliseconds between two calls to the simulation method."); defineRequiredProperty<std::string>("AgentName", "name of the robot agent");
defineOptionalProperty<int>("IntervalMs", 50, "The time in milliseconds between two calls to the simulation method.");
} }
}; };
...@@ -92,9 +93,9 @@ namespace armarx ...@@ -92,9 +93,9 @@ namespace armarx
virtual PropertyDefinitionsPtr createPropertyDefinitions(); virtual PropertyDefinitionsPtr createPropertyDefinitions();
protected: protected:
armarx::FramedDirectionPtr forces; std::map<std::string, armarx::FramedDirectionPtr> forces;
armarx::FramedDirectionPtr torques; std::map<std::string, armarx::FramedDirectionPtr> torques;
Ice::StringSeq sensorNamesList;
PeriodicTask<ForceTorqueUnitSimulation>::pointer_type simulationTask; PeriodicTask<ForceTorqueUnitSimulation>::pointer_type simulationTask;
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment