se2ez
state.h
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #ifndef SE2EZ_CORE_STATE_
4 #define SE2EZ_CORE_STATE_
5 
7 #include <se2ez/core/math.h>
8 
9 namespace se2ez
10 {
11  /** \cond IGNORE */
12  SE2EZ_CLASS_FORWARD(Robot)
13  SE2EZ_CLASS_FORWARD(FrameMap)
14  /** \endcond */
15 
16  /** \cond IGNORE */
17  SE2EZ_CLASS_FORWARD(State)
18  /** \endcond */
19 
20  /** \class se2ez::StatePtr
21  \brief A shared pointer wrapper for se2ez::State. */
22 
23  /** \class se2ez::StateConstPtr
24  \brief A const shared pointer wrapper for se2ez::State. */
25 
26  /** \brief A representation of a state of a Robot.
27  */
28  class State
29  {
30  public:
32 
33  /** \name Constructors
34  \{ */
35 
36  /** \brief Constructor.
37  * \param[in] robot Robot that this is a state for.
38  */
39  State(const Robot &robot);
40 
41  /** \brief Constructor.
42  * \param[in] robot Robot that this is a state for.
43  */
44  State(const RobotPtr &robot);
45 
46  // non-copyable
47  State(const State &) = delete;
48  State(State &&) = delete;
49 
50  /** \} */
51 
52  /** \name Configuration Management
53  \{ */
54 
55  /** \brief Sets the value of a frame with one joint parameter.
56  * \param[in] robot Robot this state is for.
57  * \param[in] name Name of frame to set value of.
58  * \param[in] value Value to set.
59  */
60  void setJoint(const RobotPtr &robot, const std::string &name, double value);
61 
62  /** \brief Sets the value of a frame with a translation joint.
63  * \param[in] robot Robot this state is for.
64  * \param[in] name Name of frame to set value of.
65  * \param[in] value Value to set.
66  */
67  void setTranslateJoint(const RobotPtr &robot, const std::string &name, const Eigen::Vector2d &value);
68 
69  /** \brief Sets the value of a frame with a floating joint.
70  * \param[in] robot Robot this state is for.
71  * \param[in] name Name of frame to set value of.
72  * \param[in] value Value to set.
73  */
74  void setFloatJoint(const RobotPtr &robot, const std::string &name, const Eigen::Isometry2d &value);
75 
76  /** \brief Sets the value of a frame with a floating joint.
77  * \param[in] robot Robot this state is for.
78  * \param[in] name Name of frame to set value of.
79  * \param[in] value Value to set.
80  */
81  void setFloatJoint(const RobotPtr &robot, const std::string &name, const Eigen::Vector3d &value);
82 
83  /** \brief Sets a random value to the state
84  * \param[in] robot Robot this state is for.
85  */
86  void setRandom(const RobotPtr &robot);
87 
88  /** \brief Copies the configuration from another state.
89  * \param[in] other State to copy.
90  */
91  void copy(const StatePtr &other);
92 
93  /** \} */
94 
95  /** \name Pose Management
96  \{ */
97 
98  /** \brief Compute the forward kinematics for all frames in the robot.
99  * \param[in] robot Robot this state is for.
100  */
101  void fk(const RobotPtr &robot);
102 
103  /** \brief Get the pose of a frame of the robot. fk() must be called before calling this function.
104  * \param[in] robot Robot this state is for.
105  * \param[in] frame Frame to get pose for.
106  * \return Pose of the frame.
107  */
108  const Eigen::Isometry2d &getPose(const RobotPtr &robot, const std::string &frame);
109 
110  /** \brief Get the jacobian of a frame of the robot.
111  * \param[in] robot Robot this state is for.
112  * \param[in] frame Frame to get jacobian for.
113  * \return Jacobian of the frame.
114  */
115  const Eigen::MatrixXd &getJacobian(const RobotPtr &robot, const std::string &frame);
116 
117  /** \brief Get the poses of geometry attached to a frame of the robot. fk() must be called before
118  * calling this function.
119  * \param[in] robot Robot this state is for.
120  * \param[in] frame Frame to get pose for.
121  * \return Poses of the frame's geometry.
122  */
123  const tf::EigenVector<Eigen::Isometry2d> &getGeometryPoses(const RobotPtr &robot,
124  const std::string &frame);
125 
126  /** \} */
127 
128  /** \name Informative
129  \{ */
130 
131  /** \brief Print out the current value of all frames on the robot.
132  * \param[in] robot Robot this state is for.
133  * \return Tree of all frames with their poses.
134  */
135  std::string printFrames(const RobotPtr &robot) const;
136 
137  /** \} */
138 
139  bool dirty{true};
140  Eigen::VectorXd data; ///< Configuration vector.
141  FrameMapPtr frames{nullptr}; ///< Frame poses
142  };
143 } // namespace se2ez
144 
145 #endif
A shared pointer wrapper for se2ez::State.
A representation of a state of a Robot.
Definition: state.h:28
A representation of a robot (in this case, a kinematic tree in the plane).
Definition: robot.h:119
#define SE2EZ_EIGEN_CLASS
Definition: class_forward.h:14
A shared pointer wrapper for se2ez::Robot.
Main namespace.
Definition: collision.h:11
Eigen::VectorXd data
Configuration vector.
Definition: state.h:140
#define SE2EZ_CLASS_FORWARD(C)
Definition: class_forward.h:9