VirtualRobotReader.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @author Fabian Reister ( fabian dot reister at kit dot edu )
17  * @date 2021
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
22 #pragma once
23 
24 #include <VirtualRobot/Robot.h>
25 #include <VirtualRobot/VirtualRobot.h>
26 #include <VirtualRobot/XML/RobotIO.h>
27 
28 #include "RobotReader.h"
29 
31 {
32  /**
33  * @brief The VirtualRobotReader class.
34  *
35  * The aim of this class is to obtain a virtual robot instance and synchronize it
36  * with the data (joint positions, global pose, ...) stored in the working memory.
37  *
38  * This is only a lightweight wrapper of @see RobotReader for Simox's VirtualRobot class.
39  */
40  class VirtualRobotReader : virtual public RobotReader
41  {
42  public:
44 
45  ~VirtualRobotReader() override = default;
46 
48 
49  [[nodiscard]] bool synchronizeRobot(VirtualRobot::Robot& robot,
50  const armem::Time& timestamp) const;
51 
52  [[nodiscard]] VirtualRobot::RobotPtr
53  getRobot(const std::string& name,
54  const armem::Time& timestamp = armem::Time::Invalid(),
55  const VirtualRobot::RobotIO::RobotDescription& loadMode =
56  VirtualRobot::RobotIO::RobotDescription::eStructure);
57 
58  [[nodiscard]] VirtualRobot::RobotPtr
59  getSynchronizedRobot(const std::string& name,
60  const VirtualRobot::RobotIO::RobotDescription& loadMode =
61  VirtualRobot::RobotIO::RobotDescription::eStructure,
62  bool blocking = true);
63 
64  [[nodiscard]] VirtualRobot::RobotPtr
65  getSynchronizedRobot(const std::string& name,
66  const armem::Time& timestamp,
67  const VirtualRobot::RobotIO::RobotDescription& loadMode =
68  VirtualRobot::RobotIO::RobotDescription::eStructure,
69  bool blocking = true);
70 
71  std::optional<std::map<RobotReader::Hand, robot::ForceTorque>>
72  queryForceTorque(const std::string& name, const armem::Time& timestamp);
74 
75  private:
76  [[nodiscard]] VirtualRobot::RobotPtr
77  _getSynchronizedRobot(const std::string& name,
78  const armem::Time& timestamp = armem::Time::Invalid(),
79  const VirtualRobot::RobotIO::RobotDescription& loadMode =
80  VirtualRobot::RobotIO::RobotDescription::eStructure,
81  bool blocking = true);
82  };
83 
84 } // namespace armarx::armem::robot_state
armarx::armem::robot_state::RobotReader::queryForceTorque
std::optional< std::map< Hand, robot::ForceTorque > > queryForceTorque(const robot::RobotDescription &description, const armem::Time &timestamp) const
Definition: RobotReader.cpp:511
armarx::armem::robot_state::VirtualRobotReader::queryForceTorque
std::optional< std::map< RobotReader::Hand, robot::ForceTorque > > queryForceTorque(const std::string &name, const armem::Time &timestamp)
Definition: VirtualRobotReader.cpp:125
armarx::armem::robot_state::VirtualRobotReader
The VirtualRobotReader class.
Definition: VirtualRobotReader.h:40
armarx::armem::robot_state::VirtualRobotReader::getRobot
VirtualRobot::RobotPtr getRobot(const std::string &name, const armem::Time &timestamp=armem::Time::Invalid(), const VirtualRobot::RobotIO::RobotDescription &loadMode=VirtualRobot::RobotIO::RobotDescription::eStructure)
Definition: VirtualRobotReader.cpp:51
armarx::armem::robot_state::VirtualRobotReader::~VirtualRobotReader
~VirtualRobotReader() override=default
armarx::armem::robot_state::VirtualRobotReader::registerPropertyDefinitions
void registerPropertyDefinitions(::armarx::PropertyDefinitionsPtr &def) override
Definition: VirtualRobotReader.cpp:20
armarx::armem::robot_state
Definition: RobotStatePredictionClient.cpp:42
armarx::armem::robot_state::VirtualRobotReader::synchronizeRobot
bool synchronizeRobot(VirtualRobot::Robot &robot, const armem::Time &timestamp) const
Definition: VirtualRobotReader.cpp:26
armarx::armem::human::Robot
@ Robot
Definition: util.h:14
RobotReader.h
armarx::armem::robot_state::VirtualRobotReader::getSynchronizedRobot
VirtualRobot::RobotPtr getSynchronizedRobot(const std::string &name, const VirtualRobot::RobotIO::RobotDescription &loadMode=VirtualRobot::RobotIO::RobotDescription::eStructure, bool blocking=true)
armarx::armem::robot_state::RobotReader
The RobotReader class.
Definition: RobotReader.h:43
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::armem::robot_state::RobotReader::RobotReader
RobotReader()=default
armarx::core::time::DateTime::Invalid
static DateTime Invalid()
Definition: DateTime.cpp:60
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18