diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.cpp b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.cpp index d0c7371051effc8f00a007687723ece0e2fa5cb9..fc83132850cfb652359c0ef7cca81d89e3ff3aac 100644 --- a/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.cpp +++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.cpp @@ -7,92 +7,79 @@ namespace armarx::plugins { - void - HeartbeatComponentPlugin::configureHeartbeatChannel(const std::string& channel, - const RobotHealthHeartbeatArgs& args) + void HeartbeatComponentPlugin::configureHeartbeatChannel(const std::string& channel, + const RobotHealthHeartbeatArgs& args) { channelHeartbeatConfig.emplace(channel, args); } - void - HeartbeatComponentPlugin::heartbeat() + void HeartbeatComponentPlugin::heartbeat() { if (robotHealthTopic) { robotHealthTopic->heartbeat(componentName, heartbeatArgs); - } - else + } else { ARMARX_WARNING << "No robot health topic available!"; } } - void - HeartbeatComponentPlugin::heartbeat(const std::string& channel) + void HeartbeatComponentPlugin::heartbeat(const std::string& channel) { const auto argsIt = channelHeartbeatConfig.find(channel); - ARMARX_CHECK(argsIt != channelHeartbeatConfig.end()) - << "heartbeat() called for unknown channel '" << channel << "'." - << "You must register the config using configureHeartbeatChannel(channel) first!"; + ARMARX_CHECK(argsIt != channelHeartbeatConfig.end()) << "heartbeat() called for unknown channel '" << channel + << "'." + << "You must register the config using configureHeartbeatChannel(channel) first!"; const auto& args = argsIt->second; if (robotHealthTopic) { robotHealthTopic->heartbeat(componentName + "_" + channel, args); - } - else + } else { ARMARX_WARNING << "No robot health topic available!"; } } - void - HeartbeatComponentPlugin::preOnInitComponent() + void HeartbeatComponentPlugin::preOnInitComponent() { - if (topicName.empty()) - { - parent<Component>().getProperty(topicName, makePropertyName(topicPropertyName)); - } - parent<Component>().offeringTopic(topicName); + // if (topicName.empty()) + // { + // parent<Component>().getProperty(topicName, makePropertyName(topicPropertyName)); + // } + // parent<Component>().offeringTopic(topicName); } - void - HeartbeatComponentPlugin::postOnInitComponent() + void HeartbeatComponentPlugin::postOnInitComponent() { } - void - HeartbeatComponentPlugin::preOnConnectComponent() + void HeartbeatComponentPlugin::preOnConnectComponent() { - robotHealthTopic = parent<Component>().getTopic<RobotHealthInterfacePrx>(topicName); + // robotHealthTopic = parent<Component>().getTopic<RobotHealthInterfacePrx>(topicName); componentName = parent<Component>().getName(); } - void - HeartbeatComponentPlugin::postCreatePropertyDefinitions(PropertyDefinitionsPtr& properties) + void HeartbeatComponentPlugin::postCreatePropertyDefinitions(PropertyDefinitionsPtr& properties) { if (!properties->hasDefinition(makePropertyName(topicPropertyName))) { - properties->defineOptionalProperty<std::string>( - makePropertyName(topicPropertyName), - "DebugObserver", - "Name of the topic the DebugObserver listens on"); + properties->topic(robotHealthTopic, topicName, topicPropertyName, + "Name of the topic the DebugObserver listens on"); } if (not properties->hasDefinition(makePropertyName(maximumCycleTimeWarningMSPropertyName))) { - properties->defineRequiredProperty<std::string>( - makePropertyName(maximumCycleTimeWarningMSPropertyName), - "TODO: maximumCycleTimeWarningMS"); + properties->required(heartbeatArgs.maximumCycleTimeWarningMS, maximumCycleTimeWarningMSPropertyName, + "maximum cycle time before warning is emitted"); } if (not properties->hasDefinition(makePropertyName(maximumCycleTimeErrorMSPropertyName))) { - properties->defineRequiredProperty<std::string>( - makePropertyName(maximumCycleTimeErrorMSPropertyName), - "TODO: maximumCycleTimeErrorMS"); + properties->required(heartbeatArgs.maximumCycleTimeErrorMS, maximumCycleTimeErrorMSPropertyName, + "maximum cycle time before error is emitted"); } } diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.h b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.h index 6a4a6c2bd692484c94bbd42bdfff399b0f5a0aa9..80cf546726085b6ca03406a7dc1abc91e647c11c 100644 --- a/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.h +++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HeartbeatComponentPlugin.h @@ -66,7 +66,7 @@ namespace armarx::plugins private: //! heartbeat topic name (outgoing) - std::string topicName; + std::string topicName{"DebugObserver"}; //! name of this component used as identifier for heartbeats std::string componentName; diff --git a/source/RobotAPI/libraries/core/observerfilters/OffsetFilter.cpp b/source/RobotAPI/libraries/core/observerfilters/OffsetFilter.cpp index d8a3246de16fa15282559204e96f45f516567d7c..6830dbc16972143111bdacecaf52907bf99d8427 100644 --- a/source/RobotAPI/libraries/core/observerfilters/OffsetFilter.cpp +++ b/source/RobotAPI/libraries/core/observerfilters/OffsetFilter.cpp @@ -38,6 +38,11 @@ namespace armarx::filters int newValue = dataHistory.rbegin()->second->getInt() - initialValue->getInt(); newVariant = new Variant(newValue); } + else if (type == VariantType::Long) + { + long newValue = dataHistory.rbegin()->second->getLong() - initialValue->getLong(); + newVariant = new Variant(newValue); + } else if (type == VariantType::Float) { float newValue = dataHistory.rbegin()->second->getFloat() - initialValue->getFloat(); @@ -80,6 +85,7 @@ namespace armarx::filters { ParameterTypeList result; result.push_back(VariantType::Int); + result.push_back(VariantType::Long); result.push_back(VariantType::Float); result.push_back(VariantType::Double); result.push_back(VariantType::FramedDirection);