00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "xyPlatformAxisSimulation.hpp"
00029
00030 #define XY_JOINT_START_ANGLE {0.0, 0.0}
00031
00032 using namespace ORO_DeviceDriver;
00033 using namespace ORO_Execution;
00034
00035
00036 xyPlatformAxisSimulation::xyPlatformAxisSimulation()
00037 :_axes(XY_NUM_AXIS),
00038 _axesInterface(XY_NUM_AXIS),
00039 _reference(XY_NUM_AXIS),
00040 _my_task_context("XYAxis")
00041 {
00042 double jointspeedlimits[XY_NUM_AXIS] = XY_JOINTSPEEDLIMITS;
00043 double qinit[XY_NUM_AXIS] = XY_JOINT_START_ANGLE;
00044
00045
00046
00047 for (unsigned int i = 0; i <XY_NUM_AXIS; i++){
00048 _axes[i] = new ORO_DeviceDriver::SimulationAxis(qinit[i]);
00049 _axes[i]->setMaxDriveValue( jointspeedlimits[i] );
00050 _axesInterface[i] = _axes[i];
00051 _reference[i]=true;
00052 }
00053
00054
00055
00056 _my_factory = newMethodFactory( this );
00057 _my_factory->add("lock", method( &xyPlatformAxisSimulation::lock, "lock axis", "axis", "axis to lock"));
00058 _my_factory->add("unlock", method( &xyPlatformAxisSimulation::unlock, "unlock axis", "axis", "axis to unlock"));
00059 _my_factory->add("stop", method( &xyPlatformAxisSimulation::stop, "stop axis", "axis", "axis to stop"));
00060 _my_factory->add("getDriveValue", method( &xyPlatformAxisSimulation::getDriveValue, "get drive value of axis", "axis", "drive value of this axis"));
00061 _my_factory->add("addOffset", method( &xyPlatformAxisSimulation::addOffset, "Add offset to axis", "offset", "offset to add"));
00062 _my_factory->add("getReference", method( &xyPlatformAxisSimulation::getReference, "Get referencesignal from axis", "axis", "axis to get reference from"));
00063 _my_factory->add("writePosition", method( &xyPlatformAxisSimulation::writePosition, "Write value to axis", "axis","axis to write value to","q", "joint angle in radians"));
00064 _my_factory->add("prepareForUse", method( &xyPlatformAxisSimulation::prepareForUse, "Prepare robot for use"));
00065 _my_factory->add("prepareForShutdown", method( &xyPlatformAxisSimulation::prepareForShutdown, "Prepare robot for shutdown"));
00066 _my_task_context.methodFactory.registerObject("this", _my_factory);
00067 }
00068
00069 xyPlatformAxisSimulation::~xyPlatformAxisSimulation()
00070 {
00071 for (unsigned int i = 0; i < XY_NUM_AXIS; i++)
00072 delete _axes[i];
00073 }
00074
00075 std::vector<ORO_DeviceInterface::AxisInterface*>
00076 xyPlatformAxisSimulation::getAxes()
00077 {
00078 return _axesInterface;
00079 }
00080
00081
00082
00083 void
00084 xyPlatformAxisSimulation::unlock(int axis)
00085 {
00086 _axes[axis]->unlock();
00087 }
00088
00089
00090 void
00091 xyPlatformAxisSimulation::stop(int axis)
00092 {
00093 _axes[axis]->stop();
00094 }
00095
00096
00097 void
00098 xyPlatformAxisSimulation::lock(int axis)
00099 {
00100 _axes[axis]->lock();
00101 }
00102
00103
00104
00105 double
00106 xyPlatformAxisSimulation::getDriveValue(int axis)
00107 {
00108 if (!(axis<0 || axis>XY_NUM_AXIS-1))
00109 return _axes[axis]->getDriveValue();
00110 else
00111 return 0.0;
00112 }
00113
00114
00115 void
00116 xyPlatformAxisSimulation::addOffset(const std::vector<double>& offset)
00117 {}
00118
00119 void
00120 xyPlatformAxisSimulation::writePosition(int axis, double q)
00121 {}
00122
00123 bool
00124 xyPlatformAxisSimulation::getReference(int axis)
00125 {
00126 assert(!(axis<0 || axis>XY_NUM_AXIS-1));
00127 _reference[axis]= !_reference[axis];
00128 return _reference[axis];
00129 }
00130
00131 TaskContext*
00132 xyPlatformAxisSimulation::getTaskContext()
00133 {
00134 return &_my_task_context;
00135 }