Skip to content
Snippets Groups Projects
Commit e1dae573 authored by Andre Meixner's avatar Andre Meixner :camera:
Browse files

Added synchronize robot joints to robot reader to be independent of localization

parent 53a9d53b
No related branches found
No related tags found
1 merge request!432Feature/synchronize-robot-joints
Pipeline #18085 passed
......@@ -185,6 +185,26 @@ namespace armarx::armem::robot_state
std::optional<robot::RobotState>
RobotReader::queryState(const robot::RobotDescription& description,
const armem::Time& timestamp) const
{
std::optional<robot::RobotState> robotState = queryJointState(description, timestamp);
if (robotState)
{
const auto globalPose = queryGlobalPose(description, timestamp);
if (not globalPose)
{
ARMARX_VERBOSE << "Failed to query global pose for robot " << description.name;
return std::nullopt;
}
robotState->globalPose = *globalPose;
}
return robotState;
}
std::optional<robot::RobotState>
RobotReader::queryJointState(const robot::RobotDescription& description,
const armem::Time& timestamp) const
{
const auto proprioception = queryProprioception(description, timestamp);
......@@ -196,15 +216,8 @@ namespace armarx::armem::robot_state
}
const auto jointMap = proprioception->joints.position;
const auto globalPose = queryGlobalPose(description, timestamp);
if (not globalPose)
{
ARMARX_VERBOSE << "Failed to query global pose for robot " << description.name;
return std::nullopt;
}
return robot::RobotState{.timestamp = timestamp,
.globalPose = *globalPose,
.globalPose = robot::RobotState::Pose::Identity(),
.jointMap = jointMap,
.proprioception = proprioception};
}
......
......@@ -67,6 +67,9 @@ namespace armarx::armem::robot_state
std::optional<robot::RobotState> queryState(const robot::RobotDescription& description,
const armem::Time& timestamp) const;
std::optional<robot::RobotState> queryJointState(const robot::RobotDescription& description,
const armem::Time& timestamp) const;
std::optional<armarx::armem::arondto::Proprioception>
queryProprioception(const robot::RobotDescription& description,
const armem::Time& timestamp) const;
......
......@@ -47,6 +47,30 @@ namespace armarx::armem::robot_state
return true;
}
bool
VirtualRobotReader::synchronizeRobotJoints(VirtualRobot::Robot& robot,
const armem::Time& timestamp) const
{
// const static auto packages = armarx::CMakePackageFinder::FindAllArmarXSourcePackages();
// const auto package = armarx::ArmarXDataPath::getProject(packages, robot.getFilename());
const robot::RobotDescription robotDescription{.name = robot.getName(),
.xml = PackagePath{"", ""}};
const auto robotState = queryJointState(robotDescription, timestamp);
if (not robotState)
{
ARMARX_VERBOSE << deactivateSpam(5) << "Querying robot state failed for robot `"
<< robot.getName() << "` "
<< "(type `" << robot.getType() << "`)!";
return false;
}
robot.setJointValues(robotState->jointMap);
return true;
}
VirtualRobot::RobotPtr
VirtualRobotReader::getRobot(const std::string& name,
const armem::Time& timestamp,
......
......@@ -49,6 +49,9 @@ namespace armarx::armem::robot_state
[[nodiscard]] bool synchronizeRobot(VirtualRobot::Robot& robot,
const armem::Time& timestamp) const;
[[nodiscard]] bool synchronizeRobotJoints(VirtualRobot::Robot& robot,
const armem::Time& timestamp) const;
[[nodiscard]] VirtualRobot::RobotPtr
getRobot(const std::string& name,
const armem::Time& timestamp = armem::Time::Invalid(),
......
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