00001
00007 #ifndef ACTUATORS_H
00008 #define ACTUATORS_H
00009
00010 #include "jwalkincludes.h"
00011 #include "sensors.h"
00012
00013 #define ACTUATORS_CLEARAFTER 0 // use this to switch between the aldcm's ClearAfter and ClearAll modes
00014
00015
00016 #define JOINT_OFFSET_LARM 0
00017 #define JOINT_OFFSET_RARM 4 // so that jointPositions[JOINT_OFFSET_RARM] is the first joint in the arm
00018 #define JOINT_OFFSET_LLEG 8
00019 #define JOINT_OFFSET_RLEG 14
00020
00021 #define ALIAS_HARDNESS_ALL string("Actuators/Hardness/All")
00022 #define ALIAS_HARDNESS_ALL_LENGTH J_NUM_JOINTS
00023 #define ALIAS_HARDNESS_NOT_HEAD string("Actuators/Hardness/NotHead")
00024 #define ALIAS_HARDNESS_NOT_HEAD_LENGTH J_NUM_JOINTS - 2
00025 #define ALIAS_HARDNESS_HEAD string("Actuators/Hardness/Head")
00026 #define ALIAS_HARDNESS_HEAD_LENGTH 2
00027
00028 #define ALIAS_TARGETS_ALL string("Actuators/Targets/All")
00029 #define ALIAS_TARGETS_ALL_LENGTH J_NUM_JOINTS
00030 #define ALIAS_TARGETS_NOT_HEAD string("Actuators/Targets/NotHead")
00031 #define ALIAS_TARGETS_NOT_HEAD_LENGTH J_NUM_JOINTS - 2
00032 #define ALIAS_TARGETS_HEAD string("Actuators/Targets/Head")
00033 #define ALIAS_TARGETS_HEAD_LENGTH 2
00034
00035
00036 extern string indexToPositionActuator[];
00037 extern string indexToHardnessActuator[];
00038 extern float jointLimits[][2];
00039
00040 extern float actuatorHardnesses[];
00041 extern float actuatorPositions[];
00042
00043 class Actuators
00044 {
00045 public:
00046 Actuators();
00047 ~Actuators();
00048
00049
00050 void setStiffness(int jointindex, float value);
00051 void setStiffnessHead(float value[]);
00052 void setStiffnessAll(float values[]);
00053 int setStiffnessAll(float values[], int time);
00054 void setStiffnessNotHead(float values[]);
00055
00056
00057 void clearDCM();
00058 void resetMotorBoards();
00059 void resetChestBoard();
00060 void sendFrameToBody(float positions[], float hardnesses[]);
00061 void sendFrameToNotHead(float positions[], float hardnesses[]);
00062
00063
00064 int goToAngle(int jointindex, float position, int time);
00065 int goToAnglesAll(float positions[], int time);
00066 int goToAnglesWithVelocityAll(float positions[], float velocity);
00067 int goToAnglesNotHead(float positions[], int time);
00068 int goToAnglesWithVelocityNotHead(float positions[], float velocity);
00069
00070
00071 int goToAngleHeadYaw(float position, int time);
00072 int goToAngleHeadPitch(float position, int time);
00073
00074 public:
00075 static float MaxBatteryVoltage;
00076
00077 private:
00078
00079 void createHardnessAliases();
00080 void createTargetAliases();
00081
00082
00083 void adjustHardness(float hardness, float* adjustedhardness);
00084 void adjustHardnesses(float hardnesses[], float adjustedhardnesses[], unsigned char numactuators);
00085
00086
00087 void sendToActuator(string actuatorname, int time, float value);
00088 void sendToAliasActuator(string aliasname, int time, float values[], int numactuators);
00089 void sendToAliasActuator(string aliasname, int times[], float values[], int numactuators);
00090
00091 void sendCurveToActuator(string actuatorname, int starttime, float value[], int numvalues);
00092 void sendCurveToAliasActuator(string aliasname, int starttime, float values[][ALIAS_TARGETS_ALL_LENGTH], int numvalues);
00093 void sendCurveToAliasActuator(string aliasname, int starttime, float values[][ALIAS_TARGETS_NOT_HEAD_LENGTH], int numvalues);
00094 };
00095
00096 #endif