Go to the documentation of this file.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
00029
00030
00031
00032 #ifdef ROS
00033 #include "dx100/ros_conversion.h"
00034 #include "simple_message/log_wrapper.h"
00035 #endif
00036
00037 #ifdef MOTOPLUS
00038 #include "ros_conversion.h"
00039 #include "log_wrapper.h"
00040 #endif
00041
00042 using namespace industrial::joint_data;
00043
00044 namespace motoman
00045 {
00046
00047 namespace ros_conversion
00048 {
00049
00050
00051
00052 float S_PULSE_TO_RAD = 0;
00053 float L_PULSE_TO_RAD = 0;
00054 float U_PULSE_TO_RAD = 0;
00055 float R_PULSE_TO_RAD = 0;
00056 float B_PULSE_TO_RAD = 0;
00057 float T_PULSE_TO_RAD = 0;
00058 float E_PULSE_TO_RAD = 0;
00059
00060
00061
00062
00063 void initJointConversion(MotomanRobotModel model_number)
00064 {
00065
00066 LOG_INFO("Initializing joint conversion factors for: ");
00067 switch (model_number)
00068 {
00069 case MotomanRobotModels::SIA_10D:
00070 LOG_INFO("SIA_10D: %d", model_number);
00071 S_PULSE_TO_RAD = 58670.87822;
00072 L_PULSE_TO_RAD = 58670.87822;
00073 U_PULSE_TO_RAD = 65841.76588;
00074 R_PULSE_TO_RAD = 65841.76588;
00075 B_PULSE_TO_RAD = 65841.76588;
00076 T_PULSE_TO_RAD = 33246.8329;
00077 E_PULSE_TO_RAD = 65841.76588;
00078 break;
00079
00080 case MotomanRobotModels::SIA_20D:
00081 LOG_INFO("SIA_20D: %d", model_number);
00082 S_PULSE_TO_RAD = 58670.87822;
00083 L_PULSE_TO_RAD = 58670.87822;
00084 U_PULSE_TO_RAD = 58670.87822;
00085 R_PULSE_TO_RAD = 65841.76588;
00086 B_PULSE_TO_RAD = 65841.76588;
00087 T_PULSE_TO_RAD = 33246.8329;
00088 E_PULSE_TO_RAD = 58670.87822;
00089 break;
00090
00091 default:
00092 LOG_ERROR("Failed to initialize conversion factors for model: %d", model_number);
00093 break;
00094 }
00095 }
00096
00097
00098
00099 float toPulses(float radians, MotomanJointIndex joint)
00100 {
00101 float rtn = 0.0;
00102 switch (joint)
00103 {
00104 case MotomanJointIndexes::S:
00105 rtn = radians * S_PULSE_TO_RAD;
00106 break;
00107
00108 case MotomanJointIndexes::L:
00109 rtn = radians * L_PULSE_TO_RAD;
00110 break;
00111
00112 case MotomanJointIndexes::U:
00113 rtn = radians * U_PULSE_TO_RAD;
00114 break;
00115
00116 case MotomanJointIndexes::R:
00117 rtn = radians * R_PULSE_TO_RAD;
00118 break;
00119
00120 case MotomanJointIndexes::B:
00121 rtn = radians * B_PULSE_TO_RAD;
00122 break;
00123
00124 case MotomanJointIndexes::T:
00125 rtn = radians * T_PULSE_TO_RAD;
00126 break;
00127
00128 case MotomanJointIndexes::E:
00129 rtn = radians * E_PULSE_TO_RAD;
00130 break;
00131
00132 default:
00133 rtn = radians;
00134 }
00135 return rtn;
00136 }
00137
00138 float toRadians(float pulses, MotomanJointIndex joint)
00139 {
00140 float rtn = 0.0;
00141 switch (joint)
00142 {
00143 case MotomanJointIndexes::S:
00144 rtn = pulses / S_PULSE_TO_RAD;
00145 break;
00146
00147 case MotomanJointIndexes::L:
00148 rtn = pulses / L_PULSE_TO_RAD;
00149 break;
00150
00151 case MotomanJointIndexes::U:
00152 rtn = pulses / U_PULSE_TO_RAD;
00153 break;
00154
00155 case MotomanJointIndexes::R:
00156 rtn = pulses / R_PULSE_TO_RAD;
00157 break;
00158
00159 case MotomanJointIndexes::B:
00160 rtn = pulses / B_PULSE_TO_RAD;
00161 break;
00162
00163 case MotomanJointIndexes::T:
00164 rtn = pulses / T_PULSE_TO_RAD;
00165 break;
00166
00167 case MotomanJointIndexes::E:
00168 rtn = pulses / E_PULSE_TO_RAD;
00169 break;
00170
00171 default:
00172 rtn = pulses;
00173 }
00174 return rtn;
00175 }
00176
00177 void toRosJoint(industrial::joint_data::JointData & mp_joints,
00178 industrial::joint_data::JointData & ros_joints)
00179 {
00180
00181 ros_joints.copyFrom(mp_joints);
00182
00183 for (int i = 0; i < ros_joints.getMaxNumJoints() ; i++)
00184 {
00185 ros_joints.setJoint(i, toRadians(ros_joints.getJoint(i),
00186 (MotomanJointIndex)i));
00187 }
00188 toRosJointOrder(ros_joints);
00189 }
00190
00191 void toMpJoint(industrial::joint_data::JointData & ros_joints,
00192 industrial::joint_data::JointData & mp_joints)
00193 {
00194
00195 mp_joints.copyFrom(ros_joints);
00196 toMotomanJointOrder(mp_joints);
00197
00198 for (int i = 0; i < mp_joints.getMaxNumJoints() ; i++)
00199 {
00200 ros_joints.setJoint(i, toPulses(mp_joints.getJoint(i),
00201 (MotomanJointIndex)i));
00202 }
00203 }
00204
00205
00206 void toRosJointOrder(JointData & joints)
00207 {
00208
00209 JointData swap;
00210 swap.setJoint(RosJointIndexes::S, joints.getJoint(MotomanJointIndexes::S));
00211 swap.setJoint(RosJointIndexes::L, joints.getJoint(MotomanJointIndexes::L));
00212 swap.setJoint(RosJointIndexes::U, joints.getJoint(MotomanJointIndexes::U));
00213 swap.setJoint(RosJointIndexes::R, joints.getJoint(MotomanJointIndexes::R));
00214 swap.setJoint(RosJointIndexes::B, joints.getJoint(MotomanJointIndexes::B));
00215 swap.setJoint(RosJointIndexes::T, joints.getJoint(MotomanJointIndexes::T));
00216 swap.setJoint(RosJointIndexes::E, joints.getJoint(MotomanJointIndexes::E));
00217 joints.copyFrom(swap);
00218 }
00219
00220 void toMotomanJointOrder(JointData & joints)
00221 {
00222
00223 JointData swap;
00224 swap.setJoint(MotomanJointIndexes::S, joints.getJoint(RosJointIndexes::S));
00225 swap.setJoint(MotomanJointIndexes::L, joints.getJoint(RosJointIndexes::L));
00226 swap.setJoint(MotomanJointIndexes::U, joints.getJoint(RosJointIndexes::U));
00227 swap.setJoint(MotomanJointIndexes::R, joints.getJoint(RosJointIndexes::R));
00228 swap.setJoint(MotomanJointIndexes::B, joints.getJoint(RosJointIndexes::B));
00229 swap.setJoint(MotomanJointIndexes::T, joints.getJoint(RosJointIndexes::T));
00230 swap.setJoint(MotomanJointIndexes::E, joints.getJoint(RosJointIndexes::E));
00231 joints.copyFrom(swap);
00232 }
00233
00234 }
00235 }