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

ObjectPose: add updateAttached() (in-place)

parent 94d567d2
No related branches found
No related tags found
1 merge request!121Resolve "ObjectPoseObserver: Refactor housekeeping tasks"
......@@ -119,30 +119,35 @@ namespace armarx::objpose
return std::nullopt;
}
objpose::ObjectPose ObjectPose::getAttached(VirtualRobot::RobotPtr agent)
objpose::ObjectPose ObjectPose::getAttached(VirtualRobot::RobotPtr agent) const
{
ARMARX_CHECK(attachment);
objpose::ObjectPose updated = *this;
const objpose::ObjectAttachmentInfo& attachment = *updated.attachment;
updated.updateAttached(agent);
return updated;
}
void ObjectPose::updateAttached(VirtualRobot::RobotPtr agent)
{
ARMARX_CHECK(attachment);
ARMARX_CHECK_EQUAL(attachment.agentName, agent->getName());
ARMARX_CHECK_EQUAL(attachment->agentName, agent->getName());
VirtualRobot::RobotNodePtr robotNode = agent->getRobotNode(attachment.frameName);
VirtualRobot::RobotNodePtr robotNode = agent->getRobotNode(attachment->frameName);
ARMARX_CHECK_NOT_NULL(robotNode);
// Overwrite object pose
updated.objectPoseRobot = robotNode->getPoseInRootFrame() * attachment.poseInFrame;
updated.objectPoseGlobal = agent->getGlobalPose() * updated.objectPoseRobot;
objectPoseRobot = robotNode->getPoseInRootFrame() * attachment->poseInFrame;
objectPoseGlobal = agent->getGlobalPose() * objectPoseRobot;
updated.robotPose = agent->getGlobalPose();
updated.robotConfig = agent->getConfig()->getRobotNodeJointValueMap();
return updated;
// Overwrite robot config.
robotPose = agent->getGlobalPose();
robotConfig = agent->getConfig()->getRobotNodeJointValueMap();
}
}
namespace armarx
{
......
......@@ -74,8 +74,17 @@ namespace armarx::objpose
/// Get the OOBB in the global frame (according to `objectPoseGlobal`).
std::optional<simox::OrientedBoxf> oobbGlobal() const;
/// Get `*this` with applied attachment.
objpose::ObjectPose getAttached(VirtualRobot::RobotPtr agent);
/**
* @brief Get a copy of `*this` with updated attachment.
* @see `updateAttached()`
*/
objpose::ObjectPose getAttached(VirtualRobot::RobotPtr agent) const;
/**
* @brief Update an the object pose and robot state of an attached
* object pose according to the given agent state (in-place).
* @param agent The agent/robot.
*/
void updateAttached(VirtualRobot::RobotPtr agent);
};
using ObjectPoseSeq = std::vector<ObjectPose>;
......
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