00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <opspace/TypeIOTGCursor.hpp>
00023
00024 namespace opspace {
00025
00026
00027 TypeIOTGCursor::
00028 TypeIOTGCursor(size_t ndof, double dt_seconds)
00029 : ndof_(ndof),
00030 dt_seconds_(dt_seconds),
00031 otg_(ndof, dt_seconds)
00032 {
00033 pos_clean_ = Vector::Zero(ndof);
00034 vel_clean_ = Vector::Zero(ndof);
00035 pos_dirty_ = Vector::Zero(ndof);
00036 vel_dirty_ = Vector::Zero(ndof);
00037 selection_.resize(ndof);
00038 for (size_t ii(0); ii < ndof; ++ii) {
00039 selection_[ii] = true;
00040 }
00041 }
00042
00043
00044 int TypeIOTGCursor::
00045 next(Vector const & maxvel,
00046 Vector const & maxacc,
00047 Vector const & goal)
00048 {
00049 int const result(otg_.GetNextMotionState_Position(pos_clean_.data(),
00050 vel_clean_.data(),
00051 maxvel.data(),
00052 maxacc.data(),
00053 goal.data(),
00054 selection_.data(),
00055 pos_dirty_.data(),
00056 vel_dirty_.data()));
00057 if (0 <= result) {
00058 pos_clean_ = pos_dirty_;
00059 vel_clean_ = vel_dirty_;
00060 }
00061 return result;
00062 }
00063
00064
00065 int TypeIOTGCursor::
00066 next(double maxvel,
00067 double maxacc,
00068 double goal)
00069 {
00070 if (ndof_ != 1) {
00071 return -1000;
00072 }
00073 int const result(otg_.GetNextMotionState_Position(pos_clean_.data(),
00074 vel_clean_.data(),
00075 &maxvel,
00076 &maxacc,
00077 &goal,
00078 selection_.data(),
00079 pos_dirty_.data(),
00080 vel_dirty_.data()));
00081 if (0 <= result) {
00082 pos_clean_ = pos_dirty_;
00083 vel_clean_ = vel_dirty_;
00084 }
00085 return result;
00086 }
00087
00088
00089 char const * otg_errstr(int otg_error_code)
00090 {
00091 switch (otg_error_code) {
00092 case TypeIOTG::OTG_ERROR:
00093 return "OTG_ERROR (general error)";
00094 case TypeIOTG::OTG_MAX_VELOCITY_ERROR:
00095 return "OTG_MAX_VELOCITY_ERROR (maxvel too small)";
00096 case TypeIOTG::OTG_MAX_ACCELERATION_ERROR:
00097 return "OTG_MAX_ACCELERATION_ERROR (maxacc too small)";
00098 case TypeIOTG::OTG_WORKING:
00099 return "OTG_WORKING (everything is fine)";
00100 case TypeIOTG::OTG_FINAL_STATE_REACHED:
00101 return "OTG_FINAL_STATE_REACHED (all is fine and we're at the goal)";
00102 }
00103 return "invalid or unrecognized otg_error_code";
00104 }
00105
00106 }