00001 /* 00002 * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA) 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 00018 #ifndef _POWERCUBECTRL_OROCOS_ 00019 #define _POWERCUBECTRL_OROCOS_ 00020 00021 #include <rtt/TaskContext.hpp> 00022 #include <rtt/Command.hpp> 00023 #include <rtt/Ports.hpp> 00024 #include <rtt/Property.hpp> 00025 #include <rtt/marsh/PropertyMarshaller.hpp> 00026 #include "PowerCubeCtrl.h" 00027 00028 #include <iostream> 00029 using namespace std; 00030 00031 00032 class PowerCubeCtrl_OROCOS : public RTT::TaskContext 00033 { 00034 public: 00035 00036 PowerCubeCtrl_OROCOS(std::string name, std::string file, int dof); 00037 //PowerCubeCtrl_OROCOS(std::string name); 00038 ~PowerCubeCtrl_OROCOS(); 00039 00040 bool configureHook(); 00041 bool startHook(); 00042 void updateHook(); 00043 void stopHook(); 00044 void cleanupHook(){} 00045 00046 /* The dataports have the following names: 00047 "in_Angles" 00048 "in_Velocities" 00049 "in_Currents" 00050 "out_Angles" 00051 "out_Velocities" 00052 */ 00053 00054 protected: 00055 00056 bool stopArm(); 00057 bool isArmStopped(); 00058 bool moveJointSpace(std::vector<double> target); 00059 //bool m_stopped; 00060 00061 std::string m_xmlFile; 00062 int m_dof; 00063 00064 RTT::ReadDataPort< std::vector<double> > m_in_Angles; 00065 bool m_in_Angles_connected; 00066 00067 RTT::ReadDataPort< std::vector<double> > m_in_Velocities; // MoveVel 00068 bool m_in_Velocities_connected; 00069 00070 RTT::ReadDataPort< std::vector<double> > m_in_Currents; 00071 bool m_in_Currents_connected; 00072 00073 RTT::WriteDataPort< std::vector<double> > m_out_Angles; // getConfig 00074 RTT::WriteDataPort< std::vector<double> > m_out_Velocities; // getJointVelocities 00075 //WriteDataPort< std::vector<double> > m_out_Currents; 00076 00077 RTT::Method<bool(void)> m_stop_method; 00078 //RTT::Method<bool(std::vector<double>)> m_moveJointSpace_method; 00079 00080 RTT::Property<int> m_CanDev_prop; 00081 RTT::Property<int> m_CanBaud_prop; 00082 RTT::Property<int> m_dof_prop; 00083 RTT::Property<double> m_MaxVel_prop; 00084 RTT::Property<double> m_MaxAcc_prop; 00085 00086 std::vector< RTT::PropertyBag > m_mod_params_bags; 00087 std::vector< RTT::Property<RTT::PropertyBag> > m_mod_params; 00088 00089 std::vector< RTT::Property<int> > m_modId_props; 00090 std::vector< RTT::Property<double> > m_ul_props; 00091 std::vector< RTT::Property<double> > m_ll_props; 00092 std::vector< RTT::Property<double> > m_offset_props; 00093 00094 PowerCubeCtrl m_powercubectrl; 00095 00096 }; 00097 00098 #endif 00099