Go to the documentation of this file.00001
00010 #ifndef SEQUENCEPLAYER_H
00011 #define SEQUENCEPLAYER_H
00012
00013 #include <rtm/idl/BasicDataType.hh>
00014 #include <rtm/idl/ExtendedDataTypes.hh>
00015 #include <semaphore.h>
00016 #include <rtm/Manager.h>
00017 #include <rtm/DataFlowComponentBase.h>
00018 #include <rtm/CorbaPort.h>
00019 #include <rtm/DataInPort.h>
00020 #include <rtm/DataOutPort.h>
00021 #include <rtm/idl/BasicDataTypeSkel.h>
00022 #include <rtm/idl/ExtendedDataTypesSkel.h>
00023 #include <hrpModel/Body.h>
00024 #include <hrpModel/Sensor.h>
00025 #include "seqplay.h"
00026
00027
00028
00029 #include "SequencePlayerService_impl.h"
00030
00031
00032
00033
00034
00035
00036
00037
00038 using namespace RTC;
00039
00040 class SequencePlayer
00041 : public RTC::DataFlowComponentBase
00042 {
00043 public:
00044 SequencePlayer(RTC::Manager* manager);
00045 virtual ~SequencePlayer();
00046
00047
00048
00049 virtual RTC::ReturnCode_t onInitialize();
00050
00051
00052
00053 virtual RTC::ReturnCode_t onFinalize();
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id);
00066
00067
00068
00069
00070
00071
00072
00073 virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 double dt;
00096 seqplay *player() { return m_seq; }
00097 hrp::BodyPtr robot() { return m_robot;}
00098 void setClearFlag();
00099 void waitInterpolation();
00100 bool waitInterpolationOfGroup(const char *gname);
00101 bool setJointAngle(short id, double angle, double tm);
00102 bool setJointAngles(const double *angles, double tm);
00103 bool setJointAngles(const double *angles, const bool *mask, double tm);
00104 bool setJointAnglesSequence(const OpenHRP::dSequenceSequence angless, const OpenHRP::bSequence& mask, const OpenHRP::dSequence& times);
00105 bool setJointAnglesSequenceFull(const OpenHRP::dSequenceSequence i_jvss, const OpenHRP::dSequenceSequence i_vels, const OpenHRP::dSequenceSequence i_torques, const OpenHRP::dSequenceSequence i_poss, const OpenHRP::dSequenceSequence i_rpys, const OpenHRP::dSequenceSequence i_accs, const OpenHRP::dSequenceSequence i_zmps, const OpenHRP::dSequenceSequence i_wrenches, const OpenHRP::dSequenceSequence i_optionals, const dSequence i_tms);
00106 bool clearJointAngles();
00107 bool setBasePos(const double *pos, double tm);
00108 bool setBaseRpy(const double *rpy, double tm);
00109 bool setZmp(const double *zmp, double tm);
00110 bool setTargetPose(const char* gname, const double *xyz, const double *rpy, double tm, const char* frame_name);
00111 bool setWrenches(const double *wrenches, double tm);
00112 void loadPattern(const char *basename, double time);
00113 void playPattern(const OpenHRP::dSequenceSequence& pos, const OpenHRP::dSequenceSequence& rpy, const OpenHRP::dSequenceSequence& zmp, const OpenHRP::dSequence& tm);
00114 bool setInterpolationMode(OpenHRP::SequencePlayerService::interpolationMode i_mode_);
00115 bool setInitialState(double tm=0.0);
00116 bool addJointGroup(const char *gname, const OpenHRP::SequencePlayerService::StrSequence& jnames);
00117 bool removeJointGroup(const char *gname);
00118 bool setJointAnglesOfGroup(const char *gname, const OpenHRP::dSequence& jvs, double tm);
00119 bool setJointAnglesSequenceOfGroup(const char *gname, const OpenHRP::dSequenceSequence angless, const OpenHRP::dSequence& times);
00120 bool clearJointAnglesOfGroup(const char *gname);
00121 bool playPatternOfGroup(const char *gname, const OpenHRP::dSequenceSequence& pos, const OpenHRP::dSequence& tm);
00122
00123 void setMaxIKError(double pos, double rot);
00124 void setMaxIKIteration(short iter);
00125 protected:
00126
00127
00128
00129
00130
00131
00132
00133 TimedDoubleSeq m_qInit;
00134 InPort<TimedDoubleSeq> m_qInitIn;
00135 TimedPoint3D m_basePosInit;
00136 InPort<TimedPoint3D> m_basePosInitIn;
00137 TimedOrientation3D m_baseRpyInit;
00138 InPort<TimedOrientation3D> m_baseRpyInitIn;
00139 TimedPoint3D m_zmpRefInit;
00140 InPort<TimedPoint3D> m_zmpRefInitIn;
00141
00142
00143
00144
00145
00146 TimedDoubleSeq m_qRef;
00147 OutPort<TimedDoubleSeq> m_qRefOut;
00148 TimedDoubleSeq m_tqRef;
00149 OutPort<TimedDoubleSeq> m_tqRefOut;
00150 TimedPoint3D m_zmpRef;
00151 OutPort<TimedPoint3D> m_zmpRefOut;
00152 TimedAcceleration3D m_accRef;
00153 OutPort<TimedAcceleration3D> m_accRefOut;
00154 TimedPoint3D m_basePos;
00155 OutPort<TimedPoint3D> m_basePosOut;
00156 TimedOrientation3D m_baseRpy;
00157 OutPort<TimedOrientation3D> m_baseRpyOut;
00158 std::vector<TimedDoubleSeq> m_wrenches;
00159 std::vector<OutPort<TimedDoubleSeq> *> m_wrenchesOut;
00160 TimedDoubleSeq m_optionalData;
00161 OutPort<TimedDoubleSeq> m_optionalDataOut;
00162
00163
00164
00165
00166
00167
00168 RTC::CorbaPort m_SequencePlayerServicePort;
00169
00170
00171
00172
00173
00174 SequencePlayerService_impl m_service0;
00175
00176
00177
00178
00179
00180
00181
00182
00183 private:
00184 seqplay *m_seq;
00185 bool m_clearFlag, m_waitFlag;
00186 sem_t m_waitSem;
00187 hrp::BodyPtr m_robot;
00188 std::string m_gname;
00189 unsigned int m_debugLevel;
00190 size_t optional_data_dim;
00191 coil::Mutex m_mutex;
00192 double m_error_pos, m_error_rot;
00193 short m_iteration;
00194 std::string m_fixedLink;
00195 hrp::Vector3 m_offsetP, m_fixedP;
00196 hrp::Matrix33 m_offsetR, m_fixedR;
00197 double m_timeToStartPlaying;
00198 int dummy;
00199 };
00200
00201
00202 extern "C"
00203 {
00204 void SequencePlayerInit(RTC::Manager* manager);
00205 };
00206
00207 #endif // SEQUENCEPLAYER_H