AmtecProtocolArm.h
Go to the documentation of this file.
00001 /*
00002  * AmtecProtocolArm.h
00003  *
00004  * Amtec protocol specific implementation of RobotArm class.
00005  */
00006 
00007 #ifndef AMTECPROTOCOLARM_H_
00008 #define AMTECPROTOCOLARM_H_
00009 
00010 #include <MetraLabsBase.h>
00011 #include <base/Errors.h>
00012 #include <hardware/AmtecManipulator.h>
00013 
00014 #include "RobotArm.h"
00015 
00016 using namespace MetraLabs::robotic::base;
00017 using namespace MetraLabs::robotic::hardware;
00018 
00019 
00020 class AmtecProtocolArm : public RobotArm {
00021 public:
00022         AmtecProtocolArm(IDType id_offset = 20) : RobotArm(id_offset) {
00023         }
00024 
00025         virtual void init() {
00026                 ROS_INFO("Searching AMTEC motion modules. Please wait...");
00027                 Error tErr = manipulator_.initialize();
00028                 if (tErr != OK) {
00029                         ROS_FATAL("Failed to initialise the AMTEC Manipulator. Code: %s\n", getErrorString(tErr).c_str());
00030                         exit(1);
00031                 }
00032                 modules_count_ = manipulator_.getModules().size();
00033 
00034                 ROS_INFO("Found %d AMTEC modules", modules_count_);
00035         }
00036 
00037         virtual int emergencyStopJoint(IDType id) {
00038                 ROS_WARN("emergency stopping module %d", id + id_offset_);
00039                 return manipulator_.halt(id + id_offset_);
00040         }
00041 
00042         virtual int normalStopJoint(IDType id) {
00043                 return manipulator_.softStop(id + id_offset_);
00044         }
00045 
00046         virtual int ackJoint(IDType id) {
00047                 return manipulator_.reset(id + id_offset_);
00048         }
00049 
00050         virtual int refJoint(IDType id) {
00051                 return manipulator_.ref(id + id_offset_);
00052         }
00053 
00054 
00055         virtual float getPosition(IDType id) {
00056                 return manipulator_.getModules().at(id).status_pos;
00057         }
00058         virtual float getVelocity(IDType id) {
00059                 return manipulator_.getModules().at(id).status_vel;
00060         }
00061         virtual float getMaxCurrent(IDType id) {
00062                 return NAN;
00063         }
00064 
00065         virtual int setVelocity(IDType id, float velocity) {
00066                 return manipulator_.setTargetVelocity(id + id_offset_, velocity);
00067         }
00068         virtual int setAcceleration(IDType id, float acceleration) {
00069                 return manipulator_.setTargetAcceleration(id + id_offset_, acceleration);
00070         }
00071         virtual int setCurrent(IDType id, float current) {
00072                 return ERR_NOT_SUPPORTED;
00073         }
00074 
00075 
00076         virtual int movePosition(IDType id, float position) {
00077                 return manipulator_.execMotion(id + id_offset_, AmtecManipulator::MOTION_FRAMP_MODE, position, 0);
00078         }
00079         virtual int movePositionDuration(IDType id, float position, uint16_t msecs) {
00080                 return manipulator_.execMotion(id + id_offset_, AmtecManipulator::MOTION_FSTEP_MODE, position, msecs);
00081         }
00082         virtual int moveVelocity(IDType id, float velocity) {
00083                 return manipulator_.execMotion(id + id_offset_, AmtecManipulator::MOTION_FVEL_MODE, velocity, 0);
00084         }
00085 
00086 
00087 
00088         virtual void getModuleStatus(IDType module_id, uint8_t& referenced, uint8_t& moving,
00089                         uint8_t& prog_mode, uint8_t& warning, uint8_t& error, uint8_t& brake,
00090                         uint8_t& move_end, uint8_t& pos_reached, uint8_t& error_code, float& current) {
00091                 const AmtecManipulator::ModuleConfig *module_config;
00092                 manipulator_.getModuleConfig(module_id + id_offset_, module_config);
00093 
00094                 brake = module_config->status_flags.flags.brake == 1;
00095                 error = module_config->status_flags.flags.error == 1;
00096                 move_end = module_config->status_flags.flags.ramp_end == 1; // TODO check if used correctly
00097                 moving = module_config->status_flags.flags.motion == 1;
00098                 pos_reached = module_config->status_flags.flags.brake == 0; // TODO // no better equivalent // really?
00099                 prog_mode = 0; // no equivalent
00100                 referenced = module_config->status_flags.flags.home_ok == 1;
00101                 warning = module_config->status_flags.flags.cur_limit == 1;
00102                 error_code = 0; // TODO no equivalent, check if needed by caller
00103                 current = module_config->status_cur;
00104         }
00105 
00106 
00107         const AmtecManipulator& getManipulator() const {
00108                 return manipulator_;
00109         }
00110 
00111 protected:
00112         AmtecManipulator manipulator_;
00113 
00114 };
00115 
00116 #endif /* AMTECPROTOCOLARM_H_ */


metralabs_ros
Author(s): Yianni Gatsoulis and Chris Burbridge and Lorenzo Riano and Felix Kolbe
autogenerated on Mon Oct 6 2014 07:27:58