Skip to content
Snippets Groups Projects
Commit 24830cf8 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Add component MemoryPlotter (WIP)

parent 6884e491
No related branches found
No related tags found
No related merge requests found
add_subdirectory(ExampleMemoryClient)
add_subdirectory(GraspProviderExample)
add_subdirectory(MemoryPlotter)
add_subdirectory(ObjectInstanceToIndex)
add_subdirectory(RobotStatePredictionClientExample)
add_subdirectory(SimpleVirtualRobot)
......
armarx_component_set_name(MemoryPlotter)
set(COMPONENT_LIBS
ArmarXCore
ArmarXCoreComponentPlugins
ArmarXGuiComponentPlugins
RobotAPICore RobotAPIInterfaces
armem
)
set(SOURCES
MemoryPlotter.cpp
)
set(HEADERS
MemoryPlotter.h
)
armarx_add_component("${SOURCES}" "${HEADERS}")
armarx_generate_and_add_component_executable()
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::ArmarXObjects::MemoryPlotter
* @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
* @date 2023
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#include "MemoryPlotter.h"
#include <ArmarXCore/core/time/Frequency.h>
#include <ArmarXCore/core/time/Metronome.h>
namespace armarx
{
armarx::PropertyDefinitionsPtr
MemoryPlotter::createPropertyDefinitions()
{
armarx::PropertyDefinitionsPtr defs =
new ComponentPropertyDefinitions(getConfigIdentifier());
return defs;
}
std::string
MemoryPlotter::getDefaultName() const
{
return "MemoryPlotter";
}
void
MemoryPlotter::onInitComponent()
{
}
void
MemoryPlotter::onConnectComponent()
{
createRemoteGuiTab();
RemoteGui_startRunningTask();
task = new RunningTask<MemoryPlotter>(this, &MemoryPlotter::run);
task->start();
}
void
MemoryPlotter::onDisconnectComponent()
{
task->stop();
}
void
MemoryPlotter::onExitComponent()
{
}
void
MemoryPlotter::run()
{
Frequency frequency = Frequency::Hertz(30);
Metronome metronome(frequency);
while (not task->isStopped())
{
metronome.waitForNextTick();
}
}
void
MemoryPlotter::createRemoteGuiTab()
{
using namespace armarx::RemoteGui::Client;
if (tab.queryResult)
{
}
VBoxLayout root = {tab.queryResultGroup, VSpacer()};
RemoteGui_createTab(getName(), root, &tab);
}
void
MemoryPlotter::RemoteGui_update()
{
if (tab.rebuild.exchange(false))
{
createRemoteGuiTab();
}
}
} // namespace armarx
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::ArmarXObjects::MemoryPlotter
* @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
* @date 2023
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
#include <ArmarXCore/core/Component.h>
#include <ArmarXCore/interface/observers/ObserverInterface.h>
#include <ArmarXCore/libraries/ArmarXCoreComponentPlugins/DebugObserverComponentPlugin.h>
#include <ArmarXCore/util/tasks.h>
#include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h>
#include <RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h>
#include <RobotAPI/libraries/armem/client/Reader.h>
#include <RobotAPI/libraries/armem/client/plugins/PluginUser.h>
#include <RobotAPI/libraries/armem/core/wm/memory_definitions.h>
namespace armarx
{
/**
* @defgroup Component-MemoryPlotter MemoryPlotter
* @ingroup RobotAPI-Components
*
* Transfers data from the memory system to the DebugObserver, allowing to visualize them in
* the LivePlotter.
*
* @class MemoryPlotter
* @ingroup Component-MemoryPlotter
* @brief Implementation of \ref Component-MemoryPlotter.
*/
class MemoryPlotter :
virtual public armarx::Component,
virtual public armarx::armem::ClientPluginUser,
virtual public armarx::DebugObserverComponentPluginUser,
virtual public armarx::LightweightRemoteGuiComponentPluginUser
{
public:
/// @see armarx::ManagedIceObject::getDefaultName()
std::string getDefaultName() const override;
// LightweightRemoteGuiComponentPluginUser interface
public:
void createRemoteGuiTab();
void RemoteGui_update() override;
protected:
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override;
void onInitComponent() override;
void onConnectComponent() override;
void onDisconnectComponent() override;
void onExitComponent() override;
void run();
private:
struct Properties
{
};
Properties p;
std::map<armem::MemoryID, armem::client::Reader> memoryReaders;
armarx::RunningTask<MemoryPlotter>::pointer_type task;
struct RemoteGuiTab : RemoteGui::Client::Tab
{
std::atomic_bool rebuild = false;
std::optional<armem::wm::Memory> queryResult;
RemoteGui::Client::GroupBox queryResultGroup;
};
RemoteGuiTab tab;
};
} // 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