Skip to content
Snippets Groups Projects
Commit ca734dc6 authored by Raphael Grimm's avatar Raphael Grimm
Browse files

Improve RobotStateComponentPlugin

* add RobotNameHelper
* add ctor
parent 233eb78a
No related branches found
No related tags found
1 merge request!76Update cartesian impedance and arviz
......@@ -7,6 +7,7 @@ set(LIBS
RobotAPICore
DebugDrawer
diffik
RobotStatechartHelpers
)
set(LIB_FILES
......
......@@ -25,6 +25,18 @@
namespace armarx::plugins
{
const RobotNameHelper& RobotStateComponentPlugin::getRobotNameHelper() const
{
ARMARX_CHECK_NOT_NULL(_nameHelper);
return *_nameHelper;
}
void RobotStateComponentPlugin::setRobotStateComponent(const RobotStateComponentInterfacePrx& rsc)
{
ARMARX_CHECK_NOT_NULL(rsc);
ARMARX_CHECK_NULL(_robotStateComponent);
_robotStateComponent = rsc;
}
bool RobotStateComponentPlugin::hasRobot(const std::string& id) const
{
std::lock_guard {_robotsMutex};
......@@ -130,7 +142,7 @@ namespace armarx::plugins
}
}
RobotStateComponentInterfacePrx RobotStateComponentPlugin::getRobotStateComponent()
const RobotStateComponentInterfacePrx& RobotStateComponentPlugin::getRobotStateComponent() const
{
return _robotStateComponent;
}
......@@ -216,6 +228,7 @@ namespace armarx::plugins
{
parent<Component>().getProxy(_robotStateComponent, _robotStateComponentName);
}
_nameHelper = std::make_shared<RobotNameHelper>(_robotStateComponent->getRobotInfo());
}
void RobotStateComponentPlugin::postOnDisconnectComponent()
......@@ -279,7 +292,11 @@ namespace armarx
const RobotStateComponentInterfacePrx& RobotStateComponentPluginUser::getRobotStateComponent() const
{
return _robotStateComponentPlugin->_robotStateComponent;
return getRobotStateComponentPlugin().getRobotStateComponent();
}
const RobotNameHelper& RobotStateComponentPluginUser::getRobotNameHelper() const
{
return getRobotStateComponentPlugin().getRobotNameHelper();
}
bool RobotStateComponentPluginUser::hasRobot(const std::string& id) const
......
......@@ -29,6 +29,7 @@
#include <ArmarXCore/core/Component.h>
#include <RobotAPI/libraries/RobotStatechartHelpers/RobotNameHelper.h>
#include <RobotAPI/interface/core/RobotState.h>
#include <RobotAPI/libraries/diffik/SimpleDiffIK.h>
......@@ -54,6 +55,7 @@ namespace armarx::plugins
using ComponentPlugin::ComponentPlugin;
void setRobotStateComponentName(const std::string& name);
void setRobotStateComponent(const RobotStateComponentInterfacePrx& rsc);
const std::string& getRobotStateComponentName() const;
//get / add
public:
......@@ -86,7 +88,9 @@ namespace armarx::plugins
RobotData getRobotData(const std::string& id) const;
void setRobotRNSAndNode(const std::string& id, const std::string& rnsName, const std::string& nodeName);
RobotStateComponentInterfacePrx getRobotStateComponent();
const RobotStateComponentInterfacePrx& getRobotStateComponent() const;
const RobotNameHelper& getRobotNameHelper() const;
//sync
public:
bool synchronizeLocalClone(const VirtualRobot::RobotPtr& robot) const;
......@@ -137,12 +141,13 @@ namespace armarx::plugins
const SimpleDiffIK::Parameters& params = {}) const;
};
//data
public:
private:
static constexpr auto _propertyName = "RemoteStateComponentName";
std::string _robotStateComponentName;
RobotStateComponentInterfacePrx _robotStateComponent;
mutable std::recursive_mutex _robotsMutex;
std::map<std::string, RobotData> _robots;
RobotNameHelperPtr _nameHelper;
};
}
......@@ -162,6 +167,7 @@ namespace armarx
const RobotStateComponentInterfacePrx& getRobotStateComponent() const;
const RobotNameHelper& getRobotNameHelper() const;
//get / add
public:
bool hasRobot(const std::string& id) const;
......
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