Skip to content
Snippets Groups Projects
Commit d68c47a2 authored by zhou's avatar zhou
Browse files

Scaling support for RobotStateComponent (also fixes issues with poses of...

Scaling support for RobotStateComponent (also fixes issues with poses of scaled models in the world)
parent cf1264ee
No related branches found
No related tags found
No related merge requests found
...@@ -68,6 +68,14 @@ namespace armarx ...@@ -68,6 +68,14 @@ namespace armarx
this->_synchronized = VirtualRobot::RobotIO::loadRobot(robotFile, VirtualRobot::RobotIO::eStructure); this->_synchronized = VirtualRobot::RobotIO::loadRobot(robotFile, VirtualRobot::RobotIO::eStructure);
_synchronized->setName(getProperty<std::string>("AgentName").getValue()); _synchronized->setName(getProperty<std::string>("AgentName").getValue());
robotModelScaling = getProperty<float>("RobotModelScaling").getValue();
ARMARX_INFO << "scale factor: " << robotModelScaling;
if (robotModelScaling != 1.0f)
{
ARMARX_INFO << "Scaling robot model with scale factor " << robotModelScaling;
_synchronized = _synchronized->clone(_synchronized->getName(), _synchronized->getCollisionChecker(), robotModelScaling);
}
if (this->_synchronized) if (this->_synchronized)
{ {
ARMARX_VERBOSE << "Loaded robot from file " << robotFile << ". Robot name: " << this->_synchronized->getName(); ARMARX_VERBOSE << "Loaded robot from file " << robotFile << ". Robot name: " << this->_synchronized->getName();
...@@ -101,6 +109,7 @@ namespace armarx ...@@ -101,6 +109,7 @@ namespace armarx
} }
usingTopic(robotNodeSetName + "State"); usingTopic(robotNodeSetName + "State");
/*VirtualRobot::RobotNodeSetPtr pns = this->_synchronized->getRobotNodeSet("Platform"); /*VirtualRobot::RobotNodeSetPtr pns = this->_synchronized->getRobotNodeSet("Platform");
if (pns) if (pns)
{ {
...@@ -198,6 +207,11 @@ namespace armarx ...@@ -198,6 +207,11 @@ namespace armarx
return relativeRobotFile; return relativeRobotFile;
} }
float RobotStateComponent::getScaling(const Ice::Current&) const
{
return robotModelScaling;
}
std::vector<string> RobotStateComponent::getArmarXPackages(const Current&) const std::vector<string> RobotStateComponent::getArmarXPackages(const Current&) const
{ {
std::vector<string> result; std::vector<string> result;
......
...@@ -51,6 +51,7 @@ namespace armarx ...@@ -51,6 +51,7 @@ namespace armarx
defineRequiredProperty<std::string>("RobotNodeSetName", "Set of nodes that is controlled by the KinematicUnit"); defineRequiredProperty<std::string>("RobotNodeSetName", "Set of nodes that is controlled by the KinematicUnit");
defineRequiredProperty<std::string>("RobotFileName", "Filename of VirtualRobot robot model (e.g. robot_model.xml)"); defineRequiredProperty<std::string>("RobotFileName", "Filename of VirtualRobot robot model (e.g. robot_model.xml)");
defineRequiredProperty<std::string>("AgentName", "Name of the agent for which the sensor values are provided"); defineRequiredProperty<std::string>("AgentName", "Name of the agent for which the sensor values are provided");
defineOptionalProperty<float>("RobotModelScaling", 1.0f, "Scaling of the robot model");
} }
}; };
...@@ -126,6 +127,8 @@ namespace armarx ...@@ -126,6 +127,8 @@ namespace armarx
return "RobotStateComponent"; return "RobotStateComponent";
} }
void setRobotStateObserver(RobotStateObserverPtr observer); void setRobotStateObserver(RobotStateObserverPtr observer);
float getScaling(const Ice::Current&) const;
protected: protected:
/** /**
* Load and create a VirtualRobot::Robot instance from the RobotFileName * Load and create a VirtualRobot::Robot instance from the RobotFileName
...@@ -162,7 +165,7 @@ namespace armarx ...@@ -162,7 +165,7 @@ namespace armarx
std::string robotNodeSetName; std::string robotNodeSetName;
float robotModelScaling;
}; };
} }
......
...@@ -157,6 +157,14 @@ module armarx ...@@ -157,6 +157,14 @@ module armarx
["cpp:const"] ["cpp:const"]
idempotent string getRobotName() throws NotInitializedException; idempotent string getRobotName() throws NotInitializedException;
/**
* @return The scaling of the robot model represented by this component.
*
*/
["cpp:const"]
idempotent float getScaling();
/** /**
* @return The name of the robot node set that is represented by this component. * @return The name of the robot node set that is represented by this component.
* *
......
...@@ -322,10 +322,10 @@ namespace armarx ...@@ -322,10 +322,10 @@ namespace armarx
VirtualRobot::RobotPtr RemoteRobot::createLocalClone(RobotStateComponentInterfacePrx robotStatePrx, const string& filename) VirtualRobot::RobotPtr RemoteRobot::createLocalClone(RobotStateComponentInterfacePrx robotStatePrx, const string& filename)
{ {
return createLocalClone(robotStatePrx->getSynchronizedRobot(), filename); return createLocalClone(robotStatePrx->getSynchronizedRobot(), filename, robotStatePrx->getScaling());
} }
RobotPtr RemoteRobot::createLocalClone(SharedRobotInterfacePrx sharedRobotPrx, const string& filename) RobotPtr RemoteRobot::createLocalClone(SharedRobotInterfacePrx sharedRobotPrx, const string& filename, float scaling)
{ {
boost::recursive_mutex::scoped_lock cloneLock(m); boost::recursive_mutex::scoped_lock cloneLock(m);
ARMARX_VERBOSE_S << "Creating local clone of remote robot (filename:" << filename << ")" << endl; ARMARX_VERBOSE_S << "Creating local clone of remote robot (filename:" << filename << ")" << endl;
...@@ -357,6 +357,12 @@ namespace armarx ...@@ -357,6 +357,12 @@ namespace armarx
ARMARX_ERROR_S << "Could not load robot file " << filename << ". Aborting..." << endl; ARMARX_ERROR_S << "Could not load robot file " << filename << ". Aborting..." << endl;
return result; return result;
} }
if (scaling != 1.0f)
{
ARMARX_INFO_S << "Scaling robot to " << scaling;
result = result->clone(result->getName(), result->getCollisionChecker(), scaling);
}
} }
synchronizeLocalClone(result, sharedRobotPrx); synchronizeLocalClone(result, sharedRobotPrx);
......
...@@ -187,7 +187,7 @@ namespace armarx ...@@ -187,7 +187,7 @@ namespace armarx
*/ */
static VirtualRobot::RobotPtr createLocalClone(RobotStateComponentInterfacePrx robotStatePrx, const std::string& filename = std::string()); static VirtualRobot::RobotPtr createLocalClone(RobotStateComponentInterfacePrx robotStatePrx, const std::string& filename = std::string());
static VirtualRobot::RobotPtr createLocalClone(SharedRobotInterfacePrx sharedRobotPrx, const std::string& filename = std::string()); static VirtualRobot::RobotPtr createLocalClone(SharedRobotInterfacePrx sharedRobotPrx, const std::string& filename = std::string(), float scaling = 1.0f);
/*! /*!
Use this method to synchronize (i.e. copy the joint values) from the remote robot to the local clone. Use this method to synchronize (i.e. copy the joint values) from the remote robot to the local clone.
......
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