27#include <Ice/ObjectAdapter.h>
29#include <SimoxUtility/math/convert.h>
30#include <VirtualRobot/MathTools.h>
37#include <ArmarXCore/interface/observers/VariantBase.h>
53#include <MemoryX/interface/components/WorkingMemoryInterface.h>
77 const std::string& projects,
88 if (!projects.empty())
90 std::vector<std::string> proj =
armarx::Split(projects,
",;",
true,
true);
92 for (std::string& p : proj)
99 ARMARX_WARNING <<
"ArmarX Package " << p <<
" has not been found!";
128 <<
". Valid model names are " <<
motionWrapper->getModelNames();
180 TrajectoryBasePtr t =
motionData->getJointTrajectory();
199MMMSimulation::initialize()
201 const std::string name = this->
getName();
203 const std::string mmmModelFileProject =
209 modelFileName = std::filesystem::path(mmmModelFilePath).stem();
225 startPose = simox::math::pos_rpy_to_mat4f(position, orientation);
226 std::string robotName =
simulatorPrx->addScaledRobotName(
231 ARMARX_INFO <<
"Added robot " << robotName <<
" to simulator";
233 const std::string robotStateConfigName =
"RobotStateComponent";
236 std::string packageName(
"RobotAPI");
238 std::string appPath = finder.getBinaryDir() +
"/RobotStateComponentRun";
239 pros.push_back(appPath);
243 const std::string robotSateConfPre =
getConfigDomain() +
"." + robotStateConfigName +
".";
244 properties->setProperty(robotSateConfPre +
"AgentName",
agentName);
245 properties->setProperty(robotSateConfPre +
"RobotFileName", mmmModelFilePath);
246 properties->setProperty(robotSateConfPre +
"RobotFileNameProject", mmmModelFileProject);
247 properties->setProperty(robotSateConfPre +
"RobotNodeSetName", mmmRobotNodeSetName);
248 properties->setProperty(robotSateConfPre +
"RobotModelScaling",
250 properties->setProperty(robotSateConfPre +
"ObjectName", robotStateConfigName + name);
251 properties->setProperty(
getConfigDomain() +
".RobotStateObserver." +
"ObjectName",
252 "RobotStateObserver" + name);
253 ARMARX_DEBUG <<
"creating unit " << robotStateConfigName
254 <<
" using these properties: " << properties->getPropertiesForPrefix(
"");
265 std::string packageName(
"ArmarXSimulation");
266 armarx::CMakePackageFinder finder(packageName);
267 std::string appPath = finder.getBinaryDir() +
"/SelfLocalizationDynamicSimulationAppRun";
268 pros.push_back(appPath);
272 const std::string localizationConfigName =
"SelfLocalizationDynamicSimulation";
273 const std::string localizationConfPre =
275 properties->setProperty(localizationConfPre +
"AgentName",
agentName);
276 properties->setProperty(localizationConfPre +
"RobotStateComponentName",
277 robotStateConfigName + name);
278 properties->setProperty(localizationConfPre +
"RobotName", robotName);
279 properties->setProperty(localizationConfPre +
"SimulatorName", simulatorName);
280 properties->setProperty(localizationConfPre +
"ObjectName", localizationConfigName + name);
281 properties->setProperty(localizationConfPre +
"WorkingMemoryName",
283 ARMARX_DEBUG <<
"creating unit " << localizationConfigName
284 <<
" using these properties: " << properties->getPropertiesForPrefix(
"");
285 IceInternal::Handle<SelfLocalizationDynamicSimulation> localizationComponent =
291 std::string kinematicUnitConfigName =
"KinematicUnit";
293 const std::string kinematicUnitConfPre =
296 properties->setProperty(kinematicUnitConfPre +
"RobotName", robotName);
297 properties->setProperty(kinematicUnitConfPre +
"RobotFileName", mmmModelFilePath);
298 properties->setProperty(kinematicUnitConfPre +
"RobotFileNameProject", mmmModelFileProject);
299 properties->setProperty(kinematicUnitConfPre +
"RobotNodeSetName", mmmRobotNodeSetName);
300 properties->setProperty(kinematicUnitConfPre +
"ObjectName",
301 kinematicUnitConfigName + name);
302 properties->setProperty(kinematicUnitConfPre +
"SimulatorName", simulatorName);
303 ARMARX_DEBUG <<
"creating unit " << kinematicUnitConfigName
304 <<
" using these properties: " << properties->getPropertiesForPrefix(
"");
305 IceInternal::Handle<KinematicUnit> kinematicUnitComponent =
312 const std::string robotposeUnitConfigName =
"RobotPoseUnit";
314 const std::string robotposeUnitConfPre =
317 properties->setProperty(robotposeUnitConfPre +
"RobotName", robotName);
318 properties->setProperty(robotposeUnitConfPre +
"ObjectName",
319 robotposeUnitConfigName + name);
320 properties->setProperty(robotposeUnitConfPre +
"SimulatorProxyName", simulatorName);
321 ARMARX_DEBUG <<
"creating unit " << robotposeUnitConfigName
322 <<
" using these properties: " << properties->getPropertiesForPrefix(
"");
323 IceInternal::Handle<RobotPoseUnit> robotposecUnitComponent =
347 <<
"Could not load motion as trajectory player could not be not instanciated";
355 Eigen::Vector3f position = simox::math::mat4f_to_pos(
startPose);
356 Eigen::Vector3f orientation = simox::math::mat4f_to_rpy(
startPose);
357 const std::string trajectoryPlayerConfigName =
"TrajectoryPlayer";
358 const std::string trajectoryPlayerConfPre =
361 properties->setProperty(trajectoryPlayerConfPre +
"KinematicTopicName",
kinematicUnitName);
362 properties->setProperty(trajectoryPlayerConfPre +
"KinematicUnitName",
kinematicUnitName);
363 properties->setProperty(trajectoryPlayerConfPre +
"ObjectName",
364 trajectoryPlayerConfigName +
getName());
365 properties->setProperty(trajectoryPlayerConfPre +
"LoopPlayback",
367 properties->setProperty(trajectoryPlayerConfPre +
"Offset.x", std::to_string(position(0)));
368 properties->setProperty(trajectoryPlayerConfPre +
"Offset.y", std::to_string(position(1)));
369 properties->setProperty(trajectoryPlayerConfPre +
"Offset.z", std::to_string(position(2)));
370 properties->setProperty(trajectoryPlayerConfPre +
"Offset.roll",
371 std::to_string(orientation(0)));
372 properties->setProperty(trajectoryPlayerConfPre +
"Offset.pitch",
373 std::to_string(orientation(1)));
374 properties->setProperty(trajectoryPlayerConfPre +
"Offset.yaw", std::to_string(orientation(2)));
375 properties->setProperty(trajectoryPlayerConfPre +
"EnableRobotPoseUnit",
"true");
376 properties->setProperty(trajectoryPlayerConfPre +
"RobotPoseUnitName",
robotPoseUnitName);
377 ARMARX_DEBUG <<
"creating unit " << trajectoryPlayerConfigName
378 <<
" using these properties: " << properties->getPropertiesForPrefix(
"");
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
static void addDataPaths(const std::string &dataPathList)
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
std::string getDataDir() const
bool packageFound() const
Returns whether or not this package was found with cmake.
static TPtr create(Ice::PropertiesPtr properties=Ice::createProperties(), const std::string &configName="", const std::string &configDomain="ArmarX")
Factory method for a component.
std::string getConfigDomain()
Retrieve config domain for this component as set in constructor.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Property< PropertyType > getProperty(const std::string &name)
Eigen::Matrix4f startPose
void onInitComponent() override
void stopMotion(const Ice::Current &=Ice::emptyCurrent) override
void pauseMotion(const Ice::Current &=Ice::emptyCurrent) override
std::string trajectoryPlayerName
std::string modelFileName
bool isMotionLoaded(const Ice::Current &=Ice::emptyCurrent) override
std::string kinematicUnitName
void onDisconnectComponent() override
TrajectoryPlayerInterfacePrx trajectoryPlayer
std::string robotPoseUnitName
std::shared_ptr< MotionData > motionData
std::shared_ptr< MotionFileWrapper > motionWrapper
void playMotion(const Ice::Current &=Ice::emptyCurrent) override
SimulatorInterfacePrx simulatorPrx
void createTrajectoryPlayer()
void onConnectComponent() override
PropertyDefinitionsPtr createPropertyDefinitions() override
bool loadMMMFile(const std::string &filePath, const std::string &projects=std::string(), bool createTrajectoryPlayer=true, const Ice::Current &=Ice::emptyCurrent) override
void setLoopBack(bool state, const Ice::Current &=Ice::emptyCurrent) override
void onExitComponent() override
std::recursive_mutex mmmMutex
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
void waitForProxy(std::string const &name, bool addToDependencies)
std::string getName() const
Retrieve name of object.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
ArmarXManagerPtr getArmarXManager() const
Returns the ArmarX manager used to add and remove components.
static MotionFileWrapperPtr create(const std::string &motionFilePath, double butterworthFilterCutOffFreq=0.0, const std::string relativeModelRoot="mmm")
Ice::PropertiesPtr getIceProperties() const
Returns the set of Ice properties.
bool hasProperty(const std::string &name)
Property< PropertyType > getProperty(const std::string &name)
Property creation and retrieval.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Ice::PropertiesPtr createProperties()
::IceInternal::Handle<::Ice::Properties > PropertiesPtr
T getValue(nlohmann::json &userConfig, nlohmann::json &defaultConfig, const std::string &entryName)
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::vector< std::string > Split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
IceInternal::Handle< Trajectory > TrajectoryPtr
IceInternal::Handle< Pose > PosePtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.