diff --git a/examples/bigDemo.cpp b/examples/bigDemo.cpp index 472292e..db75603 100644 --- a/examples/bigDemo.cpp +++ b/examples/bigDemo.cpp @@ -1,5 +1,7 @@ #include "control/unitreeArm.h" +using namespace UNITREE_ARM; + class Z1ARM : public unitreeArm{ public: Z1ARM():unitreeArm(true){}; diff --git a/examples/example_CtrlByFSM.cpp b/examples/example_CtrlByFSM.cpp index c2d41bf..16afd6f 100644 --- a/examples/example_CtrlByFSM.cpp +++ b/examples/example_CtrlByFSM.cpp @@ -1,5 +1,7 @@ #include "control/unitreeArm.h" +using namespace UNITREE_ARM; + int main() { Vec6 posture[2]; unitreeArm arm(true); diff --git a/examples/example_JointCtrl.cpp b/examples/example_JointCtrl.cpp index 503ccc4..150ee91 100644 --- a/examples/example_JointCtrl.cpp +++ b/examples/example_JointCtrl.cpp @@ -1,5 +1,7 @@ #include "control/unitreeArm.h" +using namespace UNITREE_ARM; + class JointTraj{ public: JointTraj(){}; diff --git a/examples/example_lowCmd_send.cpp b/examples/example_lowCmd_send.cpp index 7978411..17a7682 100644 --- a/examples/example_lowCmd_send.cpp +++ b/examples/example_lowCmd_send.cpp @@ -1,5 +1,7 @@ #include "control/unitreeArm.h" +using namespace UNITREE_ARM; + class Z1ARM : public unitreeArm{ public: Z1ARM():unitreeArm(true){ diff --git a/include/unitree_arm_sdk/control/ctrlComponents.h b/include/unitree_arm_sdk/control/ctrlComponents.h index 4a60351..b4faddc 100644 --- a/include/unitree_arm_sdk/control/ctrlComponents.h +++ b/include/unitree_arm_sdk/control/ctrlComponents.h @@ -8,6 +8,7 @@ #include "utilities/loop.h" #include "model/ArmModel.h" +namespace UNITREE_ARM { struct CtrlComponents{ public: CtrlComponents(double deltaT, bool hasUnitreeGripper); @@ -48,4 +49,5 @@ private: UDPPort *_udp; }; +} #endif \ No newline at end of file diff --git a/include/unitree_arm_sdk/control/unitreeArm.h b/include/unitree_arm_sdk/control/unitreeArm.h index 2a833b9..8fc4a2f 100644 --- a/include/unitree_arm_sdk/control/unitreeArm.h +++ b/include/unitree_arm_sdk/control/unitreeArm.h @@ -3,6 +3,8 @@ #include "control/ctrlComponents.h" +namespace UNITREE_ARM { + class unitreeArm{ public: unitreeArm(bool hasUnitreeGripper); @@ -162,4 +164,5 @@ LowlevelState *lowstate;//same as _ctrlComp->lowstate CtrlComponents *_ctrlComp; }; +} #endif diff --git a/include/unitree_arm_sdk/math/mathTools.h b/include/unitree_arm_sdk/math/mathTools.h index 05e1804..420ab78 100644 --- a/include/unitree_arm_sdk/math/mathTools.h +++ b/include/unitree_arm_sdk/math/mathTools.h @@ -5,6 +5,8 @@ #include #include "math/mathTypes.h" +namespace UNITREE_ARM { + template T max(T value){ return value; @@ -241,4 +243,5 @@ private: double _zoomFactor; std::string _valueName; }; +} #endif \ No newline at end of file diff --git a/include/unitree_arm_sdk/math/typeTrans.h b/include/unitree_arm_sdk/math/typeTrans.h index 0f422e8..bcc4ab3 100644 --- a/include/unitree_arm_sdk/math/typeTrans.h +++ b/include/unitree_arm_sdk/math/typeTrans.h @@ -5,6 +5,7 @@ #include #include +namespace UNITREE_ARM { namespace typeTrans{ inline void addValue(std::vector &vec, double value){ @@ -71,5 +72,5 @@ inline void extractVector(std::vector &vec, T &t, Args&... rest){ } } - +} #endif // TYPETRANS_H \ No newline at end of file diff --git a/include/unitree_arm_sdk/message/LowlevelCmd.h b/include/unitree_arm_sdk/message/LowlevelCmd.h index 899441a..e63122d 100644 --- a/include/unitree_arm_sdk/message/LowlevelCmd.h +++ b/include/unitree_arm_sdk/message/LowlevelCmd.h @@ -5,6 +5,7 @@ #include #include +namespace UNITREE_ARM { struct LowlevelCmd{ private: size_t _dof = 6; @@ -76,5 +77,5 @@ Vec6 getQ(); Vec6 getQd(); }; - +} #endif //LOWLEVELCMD_H diff --git a/include/unitree_arm_sdk/message/LowlevelState.h b/include/unitree_arm_sdk/message/LowlevelState.h index b0163fa..9386e9c 100644 --- a/include/unitree_arm_sdk/message/LowlevelState.h +++ b/include/unitree_arm_sdk/message/LowlevelState.h @@ -6,6 +6,8 @@ #include "math/mathTypes.h" #include "message/arm_common.h" +namespace UNITREE_ARM { + Vec6 PosturetoVec6(const Posture p); Posture Vec6toPosture(const Vec6 p); @@ -46,4 +48,5 @@ public: double getGripperTau() {return tau.at(tau.size()-1);} }; +} #endif //LOWLEVELSTATE_HPP diff --git a/include/unitree_arm_sdk/message/arm_common.h b/include/unitree_arm_sdk/message/arm_common.h index b19d8c0..dcfe624 100644 --- a/include/unitree_arm_sdk/message/arm_common.h +++ b/include/unitree_arm_sdk/message/arm_common.h @@ -5,6 +5,7 @@ #pragma pack(1) +namespace UNITREE_ARM { // 4 Byte enum class ArmFSMState{ INVALID, @@ -112,5 +113,5 @@ constexpr int JointCmd_LENGTH = (sizeof(JointCmd)); constexpr int JointState_LENGTH = (sizeof(JointState)); #pragma pack() - +} #endif // _UNITREE_ARM_ARM_MSG_H_ \ No newline at end of file diff --git a/include/unitree_arm_sdk/message/udp.h b/include/unitree_arm_sdk/message/udp.h index df5a224..eaa9493 100644 --- a/include/unitree_arm_sdk/message/udp.h +++ b/include/unitree_arm_sdk/message/udp.h @@ -8,6 +8,7 @@ #include #include "utilities/timer.h" +namespace UNITREE_ARM { enum class BlockYN{ YES, NO @@ -53,7 +54,7 @@ private: size_t _sentLength; fd_set _rSet; }; - +} #endif \ No newline at end of file diff --git a/include/unitree_arm_sdk/model/ArmModel.h b/include/unitree_arm_sdk/model/ArmModel.h index 1b4d16e..decfef2 100644 --- a/include/unitree_arm_sdk/model/ArmModel.h +++ b/include/unitree_arm_sdk/model/ArmModel.h @@ -5,8 +5,9 @@ #include "thirdparty/robotics.h" #include "thirdparty/quadProgpp/QuadProg++.hh" -using namespace robo; +namespace UNITREE_ARM { +using namespace robo; class ArmModel{ public: ArmModel(Vec3 endPosLocal, double endEffectorMass, Vec3 endEffectorCom, Mat3 endEffectorInertia); @@ -146,5 +147,5 @@ private: void setParam_V3_6(); double _theta2Bias; }; - +} #endif \ No newline at end of file diff --git a/include/unitree_arm_sdk/utilities/loop.h b/include/unitree_arm_sdk/utilities/loop.h index f901a40..7db9e98 100644 --- a/include/unitree_arm_sdk/utilities/loop.h +++ b/include/unitree_arm_sdk/utilities/loop.h @@ -12,6 +12,7 @@ #include #include "utilities/timer.h" +namespace UNITREE_ARM { typedef boost::function Callback; class Loop { @@ -54,5 +55,5 @@ public: private: boost::function _fp; }; - +} #endif // _UNITREE_ARM_LOOP_H_ \ No newline at end of file diff --git a/include/unitree_arm_sdk/utilities/timer.h b/include/unitree_arm_sdk/utilities/timer.h index 40701da..25e5c29 100644 --- a/include/unitree_arm_sdk/utilities/timer.h +++ b/include/unitree_arm_sdk/utilities/timer.h @@ -7,21 +7,19 @@ #include #include -//时间戳 微秒级, 需要#include +namespace UNITREE_ARM { + inline long long getSystemTime(){ struct timeval t; gettimeofday(&t, NULL); return 1000000 * t.tv_sec + t.tv_usec; } -//时间戳 秒级, 需要getSystemTime() + inline double getTimeSecond(){ double time = getSystemTime() * 0.000001; return time; } -/* -等待函数,微秒级,从startTime开始等待waitTime微秒 -目前不推荐使用,建议使用AbsoluteTimer类 -*/ + inline void absoluteWait(long long startTime, long long waitTime){ if(getSystemTime() - startTime > waitTime){ std::cout << "[WARNING] The waitTime=" << waitTime << " of function absoluteWait is not enough!" << std::endl @@ -52,5 +50,5 @@ private: double _nextWaitTime; itimerspec _timerSpec; }; - +} #endif \ No newline at end of file diff --git a/lib/libZ1_SDK_Linux64.so b/lib/libZ1_SDK_Linux64.so index 6d8c4be..33d82e6 100644 Binary files a/lib/libZ1_SDK_Linux64.so and b/lib/libZ1_SDK_Linux64.so differ