ServoController.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00010 #ifndef SERVO_CONTROLLER_H
00011 #define SERVO_CONTROLLER_H
00012 
00013 #include <rtm/idl/BasicDataType.hh>
00014 #include <rtm/idl/ExtendedDataTypes.hh>
00015 #include <rtm/Manager.h>
00016 #include <rtm/DataFlowComponentBase.h>
00017 #include <rtm/CorbaPort.h>
00018 #include <rtm/DataInPort.h>
00019 #include <rtm/DataOutPort.h>
00020 #include <rtm/idl/BasicDataTypeSkel.h>
00021 #include <rtm/idl/ExtendedDataTypesSkel.h>
00022 
00023 // Service implementation headers
00024 // <rtc-template block="service_impl_h">
00025 #include "ServoControllerService_impl.h"
00026 
00027 // </rtc-template>
00028 
00029 // Service Consumer stub headers
00030 // <rtc-template block="consumer_stub_h">
00031 
00032 // </rtc-template>
00033 
00034 using namespace RTC;
00035 
00036 class ServoSerial;
00037 
00041 class ServoController
00042   : public RTC::DataFlowComponentBase
00043 {
00044  public:
00049   ServoController(RTC::Manager* manager);
00053   virtual ~ServoController();
00054 
00055   // The initialize action (on CREATED->ALIVE transition)
00056   // formaer rtc_init_entry()
00057   virtual RTC::ReturnCode_t onInitialize();
00058 
00059   // The finalize action (on ALIVE->END transition)
00060   // formaer rtc_exiting_entry()
00061   virtual RTC::ReturnCode_t onFinalize();
00062 
00063   // The startup action when ExecutionContext startup
00064   // former rtc_starting_entry()
00065   // virtual RTC::ReturnCode_t onStartup(RTC::UniqueId ec_id);
00066 
00067   // The shutdown action when ExecutionContext stop
00068   // former rtc_stopping_entry()
00069   // virtual RTC::ReturnCode_t onShutdown(RTC::UniqueId ec_id);
00070 
00071   // The activated action (Active state entry action)
00072   // former rtc_active_entry()
00073   virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id);
00074 
00075   // The deactivated action (Active state exit action)
00076   // former rtc_active_exit()
00077   virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
00078 
00079   // The execution action that is invoked periodically
00080   // former rtc_active_do()
00081   virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);
00082 
00083   // The aborting action when main logic error occurred.
00084   // former rtc_aborting_entry()
00085   // virtual RTC::ReturnCode_t onAborting(RTC::UniqueId ec_id);
00086 
00087   // The error action in ERROR state
00088   // former rtc_error_do()
00089   // virtual RTC::ReturnCode_t onError(RTC::UniqueId ec_id);
00090 
00091   // The reset action that is invoked resetting
00092   // This is same but different the former rtc_init_entry()
00093   // virtual RTC::ReturnCode_t onReset(RTC::UniqueId ec_id);
00094 
00095   // The state update action that is invoked after onExecute() action
00096   // no corresponding operation exists in OpenRTm-aist-0.2.0
00097   // virtual RTC::ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
00098 
00099   // The action that is invoked when execution context's rate is changed
00100   // no corresponding operation exists in OpenRTm-aist-0.2.0
00101   // virtual RTC::ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
00102 
00103   bool setJointAngle(short id, double angle, double tm);
00104   bool setJointAngles(const OpenHRP::ServoControllerService::dSequence angles, double tm);
00105   bool getJointAngle(short id, double &angle);
00106   bool getJointAngles(OpenHRP::ServoControllerService::dSequence_out &angles);
00107   bool addJointGroup(const char *gname, const ::OpenHRP::ServoControllerService::iSequence ids);
00108   bool removeJointGroup(const char *gname);
00109   bool setJointAnglesOfGroup(const char *gname, const ::OpenHRP::ServoControllerService::dSequence angles, double tm);
00110   bool setMaxTorque(short id, short percentage);
00111   bool setReset(short id);
00112   bool getDuration(short id, double &duration);
00113   bool getSpeed(short id, double &speed);
00114   bool getMaxTorque(short id, short &percentage);
00115   bool getTorque(short id, double &torque);
00116   bool getTemperature(short id, double &temperature);
00117   bool getVoltage(short id, double &voltage);
00118   bool servoOn();
00119   bool servoOff();
00120 
00121  protected:
00122   // Configuration variable declaration
00123   // <rtc-template block="config_declare">
00124   
00125   // </rtc-template>
00126 
00127   // DataInPort declaration
00128   // <rtc-template block="inport_declare">
00129   
00130   // </rtc-template>
00131 
00132   // DataOutPort declaration
00133   // <rtc-template block="outport_declare">
00134   
00135   // </rtc-template>
00136 
00137   // CORBA Port declaration
00138   // <rtc-template block="corbaport_declare">
00139   
00140   // </rtc-template>
00141 
00142   // Service declaration
00143   // <rtc-template block="service_declare">
00144   RTC::CorbaPort m_ServoControllerServicePort;
00145   
00146   // </rtc-template>
00147 
00148   // Consumer declaration
00149   // <rtc-template block="consumer_declare">
00150   ServoControllerService_impl m_service0;
00151   
00152   // </rtc-template>
00153 
00154  private:
00155   std::map<std::string, std::vector<int> > joint_groups;
00156   std::vector<int> servo_id;
00157   std::vector<double> servo_offset;
00158   std::vector<double> servo_dir;
00159   ServoSerial* serial;
00160 };
00161 
00162 
00163 extern "C"
00164 {
00165   void ServoControllerInit(RTC::Manager* manager);
00166 };
00167 
00168 #endif // SERVO_CONTROLLER_H


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed Sep 6 2017 02:35:56