From 93a324cd1a03f0ee4d980576de84a88a0f1fc9ca Mon Sep 17 00:00:00 2001 From: Simon Ottenhaus <simon.ottenhaus@kit.edu> Date: Fri, 6 Jun 2014 15:10:57 +0200 Subject: [PATCH] Modifications to HapticUnit ice interface --- .gitignore | 1 + interface/slice/units/HapticUnit.ice | 3 ++- .../WeissHapticSensorListener.cpp | 2 +- .../WeissHapticSensorListener.h | 3 ++- .../WeissHapticSensor/WeissHapticSensor.cpp | 4 +++- source/RobotAPI/units/HapticObserver.cpp | 21 ++++++++++--------- source/RobotAPI/units/HapticObserver.h | 2 +- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index c53649ddd..36b9b1d57 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,5 @@ data/dbdump/ # Generated Scenario Files scenarios/*/startScenario.sh scenarios/*/stopScenario.sh +scenarios/*/startGui.sh diff --git a/interface/slice/units/HapticUnit.ice b/interface/slice/units/HapticUnit.ice index 51be7139e..adcba8650 100644 --- a/interface/slice/units/HapticUnit.ice +++ b/interface/slice/units/HapticUnit.ice @@ -29,6 +29,7 @@ #include <core/BasicTypes.ice> #include <observers/VariantBase.ice> #include <observers/Matrix.ice> +#include <observers/Timestamp.ice> #include <observers/ObserverInterface.ice> #include <robotstate/RobotState.ice> @@ -40,7 +41,7 @@ module armarx interface HapticUnitListener { - void reportSensorValues(string type, MatrixFloatBase values); + void reportSensorValues(string device, string name, MatrixFloatBase values, TimestampBase timestamp); }; interface HapticUnitObserverInterface extends ObserverInterface, HapticUnitListener diff --git a/source/RobotAPI/armarx-objects/WeissHapticSensorListener/WeissHapticSensorListener.cpp b/source/RobotAPI/armarx-objects/WeissHapticSensorListener/WeissHapticSensorListener.cpp index 80bd04d05..5e2ddaeb4 100644 --- a/source/RobotAPI/armarx-objects/WeissHapticSensorListener/WeissHapticSensorListener.cpp +++ b/source/RobotAPI/armarx-objects/WeissHapticSensorListener/WeissHapticSensorListener.cpp @@ -57,7 +57,7 @@ PropertyDefinitionsPtr WeissHapticSensorListener::createPropertyDefinitions() getConfigIdentifier())); } -void armarx::WeissHapticSensorListener::reportSensorValues(const std::string& type, const armarx::MatrixFloatBasePtr& values, const Ice::Current&) +void armarx::WeissHapticSensorListener::reportSensorValues(const std::string& device, const std::string& name, const armarx::MatrixFloatBasePtr& values, const armarx::TimestampBasePtr& timestamp, const Ice::Current&) { ARMARX_LOG << deactivateSpam(1) << "WeissHapticSensorListener::reportSensorValues" << MatrixFloatPtr::dynamicCast(values)->toEigen(); diff --git a/source/RobotAPI/armarx-objects/WeissHapticSensorListener/WeissHapticSensorListener.h b/source/RobotAPI/armarx-objects/WeissHapticSensorListener/WeissHapticSensorListener.h index 2287e9060..11b773cb2 100644 --- a/source/RobotAPI/armarx-objects/WeissHapticSensorListener/WeissHapticSensorListener.h +++ b/source/RobotAPI/armarx-objects/WeissHapticSensorListener/WeissHapticSensorListener.h @@ -30,6 +30,7 @@ #include <Core/util/variants/eigen3/MatrixVariant.h> #include <Core/util/variants/eigen3/VariantObjectFactories.h> + namespace armarx { /** @@ -68,7 +69,7 @@ namespace armarx return "WeissHapticSensorListener"; } - virtual void reportSensorValues(const ::std::string& type, const ::armarx::MatrixFloatBasePtr& values, const ::Ice::Current& = ::Ice::Current()); + virtual void reportSensorValues(const ::std::string& device, const ::std::string& name, const ::armarx::MatrixFloatBasePtr& values, const ::armarx::TimestampBasePtr& timestamp, const ::Ice::Current& = ::Ice::Current()); protected: /** diff --git a/source/RobotAPI/drivers/WeissHapticSensor/WeissHapticSensor.cpp b/source/RobotAPI/drivers/WeissHapticSensor/WeissHapticSensor.cpp index e36601868..35af9bd41 100644 --- a/source/RobotAPI/drivers/WeissHapticSensor/WeissHapticSensor.cpp +++ b/source/RobotAPI/drivers/WeissHapticSensor/WeissHapticSensor.cpp @@ -1,5 +1,6 @@ #include "WeissHapticSensor.h" #include <Core/util/variants/eigen3/MatrixVariant.h> +#include <Core/observers/variant/TimestampVariant.h> using namespace armarx; @@ -85,7 +86,8 @@ void WeissHapticSensor::readAndReportSensorValues() (*matrix)(y, x) = val; } } - listenerPrx->reportSensorValues(tag, matrix); + TimestampVariantPtr timestamp = new TimestampVariant(0); + listenerPrx->reportSensorValues(device, tag, matrix, timestamp); } cout << this << ": stopPeriodicFrameAcquisition" << endl; diff --git a/source/RobotAPI/units/HapticObserver.cpp b/source/RobotAPI/units/HapticObserver.cpp index 2867e505a..2964cb2ff 100644 --- a/source/RobotAPI/units/HapticObserver.cpp +++ b/source/RobotAPI/units/HapticObserver.cpp @@ -40,28 +40,29 @@ void HapticObserver::onConnectObserver() { } -void HapticObserver::reportSensorValues(const std::string &type, const MatrixFloatBasePtr &values, const Ice::Current &) +void HapticObserver::reportSensorValues(const std::string& device, const std::string& name, const armarx::MatrixFloatBasePtr& values, const armarx::TimestampBasePtr& timestamp, const Ice::Current&) { ScopedLock lock(dataMutex); MatrixFloatPtr matrix = MatrixFloatPtr::dynamicCast(values); Eigen::MatrixXf eigenMatrix = matrix->toEigen(); float max = eigenMatrix.maxCoeff(); float mean = eigenMatrix.mean(); - if(!existsChannel(type)) + if(!existsChannel(device)) { - offerChannel(type, "Force and Torque vectors on specific parts of the robot."); - offerDataFieldWithDefault(type, "matrix", matrix, "Raw tactile matrix data"); - offerDataFieldWithDefault(type, "max", Variant(max), "Maximum value"); - offerDataFieldWithDefault(type, "mean", Variant(mean), "Mean value"); + offerChannel(device, "Haptic data"); + offerDataFieldWithDefault(device, "name", Variant(name), "Name of the tactile sensor"); + offerDataFieldWithDefault(device, "matrix", matrix, "Raw tactile matrix data"); + offerDataFieldWithDefault(device, "max", Variant(max), "Maximum value"); + offerDataFieldWithDefault(device, "mean", Variant(mean), "Mean value"); } else { - setDataField(type, "matrix", matrix); - setDataField(type, "max", Variant(max)); - setDataField(type, "mean", Variant(mean)); + setDataField(device, "matrix", matrix); + setDataField(device, "max", Variant(max)); + setDataField(device, "mean", Variant(mean)); } - updateChannel(type); + updateChannel(device); } PropertyDefinitionsPtr HapticObserver::createPropertyDefinitions() diff --git a/source/RobotAPI/units/HapticObserver.h b/source/RobotAPI/units/HapticObserver.h index f3cbc18eb..9eb13fcf4 100644 --- a/source/RobotAPI/units/HapticObserver.h +++ b/source/RobotAPI/units/HapticObserver.h @@ -56,7 +56,7 @@ namespace armarx void onInitObserver(); void onConnectObserver(); - void reportSensorValues(const std::string &type, const ::armarx::MatrixFloatBasePtr &values, const ::Ice::Current& = ::Ice::Current()); + void reportSensorValues(const ::std::string& device, const ::std::string& name, const ::armarx::MatrixFloatBasePtr& values, const ::armarx::TimestampBasePtr& timestamp, const ::Ice::Current& = ::Ice::Current()); /** * @see PropertyUser::createPropertyDefinitions() -- GitLab