Skip to content
Snippets Groups Projects
Commit f095d0af authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

add heartbeat component plugin user

parent 4f1e8aea
No related branches found
No related tags found
No related merge requests found
......@@ -7,50 +7,58 @@
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::configureHeartbeatChannel(const std::string& channel, const std::string& message)
void
HeartbeatComponentPlugin::configureHeartbeatChannel(const std::string& channel,
const std::string& message)
{
auto args = heartbeatArgs;
args.message = message;
configureHeartbeatChannel(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())
// {
......@@ -59,35 +67,50 @@ namespace armarx::plugins
// parent<Component>().offeringTopic(topicName);
}
void HeartbeatComponentPlugin::postOnInitComponent()
void
HeartbeatComponentPlugin::postOnInitComponent()
{
}
void HeartbeatComponentPlugin::preOnConnectComponent()
void
HeartbeatComponentPlugin::preOnConnectComponent()
{
// 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->topic(robotHealthTopic, topicName, topicPropertyName,
properties->topic(robotHealthTopic,
topicName,
topicPropertyName,
"Name of the topic the DebugObserver listens on");
}
if (not properties->hasDefinition(makePropertyName(maximumCycleTimeWarningMSPropertyName)))
{
properties->required(heartbeatArgs.maximumCycleTimeWarningMS, maximumCycleTimeWarningMSPropertyName,
properties->required(heartbeatArgs.maximumCycleTimeWarningMS,
maximumCycleTimeWarningMSPropertyName,
"maximum cycle time before warning is emitted");
}
if (not properties->hasDefinition(makePropertyName(maximumCycleTimeErrorMSPropertyName)))
{
properties->required(heartbeatArgs.maximumCycleTimeErrorMS, maximumCycleTimeErrorMSPropertyName,
properties->required(heartbeatArgs.maximumCycleTimeErrorMS,
maximumCycleTimeErrorMSPropertyName,
"maximum cycle time before error is emitted");
}
}
} // namespace armarx::plugins
namespace armarx
{
HeartbeatComponentPluginUser::HeartbeatComponentPluginUser()
{
addPlugin(heartbeat);
}
} // namespace armarx
......@@ -22,6 +22,7 @@
#pragma once
#include <ArmarXCore/core/ComponentPlugin.h>
#include <ArmarXCore/core/ManagedIceObject.h>
#include <RobotAPI/interface/components/RobotHealthInterface.h>
......@@ -95,3 +96,18 @@ namespace armarx::plugins
std::unordered_map<std::string, RobotHealthHeartbeatArgs> channelHeartbeatConfig;
};
} // namespace armarx::plugins
namespace armarx
{
/**
* @brief Provides a ready-to-use ArViz client `arviz` as member variable.
*/
class HeartbeatComponentPluginUser : virtual public ManagedIceObject
{
public:
HeartbeatComponentPluginUser();
protected:
armarx::plugins::HeartbeatComponentPlugin* heartbeat = nullptr;
};
} // namespace armarx
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