00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PEEKABOT_HINGE_HH_INCLUDED
00024 #define PEEKABOT_HINGE_HH_INCLUDED
00025
00026
00027 #include <boost/function.hpp>
00028 #include <boost/any.hpp>
00029 #include <Eigen/Core>
00030 #include <Eigen/Geometry>
00031
00032 #include "Joint.hh"
00033 #include "HandlerInformer.hh"
00034 #include "ScopedHandler.hh"
00035
00036
00037 namespace peekabot
00038 {
00039
00040
00049 class Hinge : public Joint
00050 {
00051 public:
00052 Hinge();
00053
00054 Hinge(ScopedHandler *handler);
00055
00056 virtual ~Hinge() throw();
00057
00068 Hinge(const Eigen::Vector3f &axis, const Eigen::Vector3f &pivot);
00069
00080 void set_axis(
00081 const Eigen::Vector3f &axis,
00082 CoordinateSystem coord_sys = PARENT_COORDINATES) throw();
00083
00087 const Eigen::Vector3f &get_axis() const throw();
00088
00098 void set_pivot(
00099 const Eigen::Vector3f &pivot,
00100 CoordinateSystem coord_sys = PARENT_COORDINATES) throw();
00101
00105 const Eigen::Vector3f &get_pivot() const throw();
00106
00107 virtual void accept(ObjectVisitor *visitor) throw();
00108
00109 virtual ObjectType get_object_type() const;
00110
00111 virtual Eigen::Transform3f calculate_dof_transform(float value)
00112 const throw();
00113
00116
00117 typedef boost::signals2::signal<void ()> AxisSetSignal;
00118
00119 typedef boost::signals2::signal<void ()> PivotSetSignal;
00120
00121 inline AxisSetSignal &axis_set_signal()
00122 {
00123 return m_axis_set_signal;
00124 }
00125
00126 inline PivotSetSignal &pivot_set_signal()
00127 {
00128 return m_pivot_set_signal;
00129 }
00130
00132
00133 protected:
00134 virtual PropMap &get_prop_adapters();
00135
00136 private:
00137 static void create_prop_adapters(PropMap &adapters);
00138
00139 static void start_handler(
00140 const std::string & name,
00141 XMLHandler::AttributeMap &attributes,
00142 ScopedHandler *handler) throw();
00143
00144 void axis_and_pivot_start_handler(
00145 const std::string & name,
00146 XMLHandler::AttributeMap &attributes,
00147 ScopedHandler *handler)
00148 throw();
00149
00150 void axis_and_pivot_cdata_handler(
00151 bool is_axis,
00152 CoordinateSystem coord_sys,
00153 const std::string &cdata,
00154 ScopedHandler *handler)
00155 throw(std::domain_error, std::runtime_error, boost::bad_any_cast);
00156
00157 void min_start_handler(
00158 const std::string & name,
00159 XMLHandler::AttributeMap &attributes,
00160 ScopedHandler *handler)
00161 throw();
00162
00163 void max_start_handler(
00164 const std::string & name,
00165 XMLHandler::AttributeMap &attributes,
00166 ScopedHandler *handler)
00167 throw();
00168
00169 void initial_start_handler(
00170 const std::string & name,
00171 XMLHandler::AttributeMap &attributes,
00172 ScopedHandler *handler)
00173 throw();
00174
00175 void offset_start_handler(
00176 const std::string & name,
00177 XMLHandler::AttributeMap &attributes,
00178 ScopedHandler *handler)
00179 throw();
00180
00181 void degrees_start_handler(
00182 boost::function<void (float)> f,
00183 const std::string & name,
00184 XMLHandler::AttributeMap &attributes,
00185 ScopedHandler *handler)
00186 throw();
00187
00188 void degrees_cdata_handler(
00189 boost::function<void (float)> f,
00190 const std::string &cdata,
00191 ScopedHandler *handler)
00192 throw(std::domain_error);
00193
00194 void radians_start_handler(
00195 boost::function<void (float)> f,
00196 const std::string & name,
00197 XMLHandler::AttributeMap &attributes,
00198 ScopedHandler *handler)
00199 throw();
00200
00201 void radians_cdata_handler(
00202 boost::function<void (float)> f,
00203 const std::string &cdata,
00204 ScopedHandler *handler)
00205 throw(std::domain_error);
00206
00215 static void invoke_on_end_element(
00216 ScopedHandler::TagScope &dof_scope,
00217 boost::function<void (float)> f, float val);
00218
00219 private:
00227 Eigen::Vector3f m_axis;
00228
00234 Eigen::Vector3f m_pivot;
00235
00236
00237 AxisSetSignal m_axis_set_signal;
00238 PivotSetSignal m_pivot_set_signal;
00239
00240 static HandlerInformer ms_handler_informer;
00241 };
00242 }
00243
00244 #endif // PEEKABOT_HINGE_HH_INCLUDED