forked from unitreerobotics/z1_controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cae64c9
commit fd5a63f
Showing
48 changed files
with
6,493 additions
and
6,491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
#ifndef BASESTATE_H | ||
#define BASESTATE_H | ||
|
||
#include <string> | ||
#include "common/enumClass.h" | ||
|
||
class BaseState{ | ||
public: | ||
BaseState(int stateNameEnum, std::string stateNameString) | ||
: _stateNameEnum(stateNameEnum), _stateNameString(stateNameString){} | ||
virtual ~BaseState(){}; | ||
|
||
virtual void enter() = 0; | ||
virtual void run() = 0; | ||
virtual void exit() = 0; | ||
virtual int checkChange(int cmd) = 0; | ||
|
||
bool isState(int stateEnum){ | ||
if(_stateNameEnum == stateEnum){ | ||
return true; | ||
}else{ | ||
return false; | ||
} | ||
} | ||
std::string getStateName(){return _stateNameString;} | ||
int getStateNameEnum(){return _stateNameEnum;}; | ||
protected: | ||
int _stateNameEnum; | ||
std::string _stateNameString; | ||
}; | ||
|
||
#ifndef BASESTATE_H | ||
#define BASESTATE_H | ||
|
||
#include <string> | ||
#include "common/enumClass.h" | ||
|
||
class BaseState{ | ||
public: | ||
BaseState(int stateNameEnum, std::string stateNameString) | ||
: _stateNameEnum(stateNameEnum), _stateNameString(stateNameString){} | ||
virtual ~BaseState(){}; | ||
|
||
virtual void enter() = 0; | ||
virtual void run() = 0; | ||
virtual void exit() = 0; | ||
virtual int checkChange(int cmd) = 0; | ||
|
||
bool isState(int stateEnum){ | ||
if(_stateNameEnum == stateEnum){ | ||
return true; | ||
}else{ | ||
return false; | ||
} | ||
} | ||
std::string getStateName(){return _stateNameString;} | ||
int getStateNameEnum(){return _stateNameEnum;}; | ||
protected: | ||
int _stateNameEnum; | ||
std::string _stateNameString; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
#ifndef FSMSTATE_H | ||
#define FSMSTATE_H | ||
|
||
#include <string> | ||
#include <iostream> | ||
#include <unistd.h> | ||
#include "control/CtrlComponents.h" | ||
#include "common/math/mathTools.h" | ||
#include "common/utilities/timer.h" | ||
#include "FSM/BaseState.h" | ||
|
||
class FSMState : public BaseState{ | ||
public: | ||
FSMState(CtrlComponents *ctrlComp, ArmFSMStateName stateName, std::string stateNameString); | ||
virtual ~FSMState(){} | ||
|
||
virtual void enter() = 0; | ||
virtual void run() = 0; | ||
virtual void exit() = 0; | ||
virtual int checkChange(int cmd) {return (int)ArmFSMStateName::INVALID;} | ||
bool _collisionTest(); | ||
|
||
protected: | ||
void _armCtrl(); | ||
void _recordData(); | ||
Vec6 _postureToVec6(Posture posture); | ||
void _tauFriction(); | ||
|
||
LowlevelCmd *_lowCmd; | ||
LowlevelState *_lowState; | ||
IOInterface *_ioInter; | ||
ArmModel *_armModel; | ||
|
||
Vec6 _qPast, _qdPast, _q, _qd, _qdd, _tauForward; | ||
double _gripperPos, _gripperW, _gripperTau; | ||
|
||
CtrlComponents *_ctrlComp; | ||
Vec6 _g, _tauCmd, _tauFric; | ||
|
||
private: | ||
|
||
uint _collisionCnt; | ||
|
||
Vec6 _mLinearFriction; | ||
Vec6 _mCoulombFriction; | ||
|
||
}; | ||
|
||
#endif // FSMSTATE_H | ||
#ifndef FSMSTATE_H | ||
#define FSMSTATE_H | ||
|
||
#include <string> | ||
#include <iostream> | ||
#include <unistd.h> | ||
#include "control/CtrlComponents.h" | ||
#include "common/math/mathTools.h" | ||
#include "common/utilities/timer.h" | ||
#include "FSM/BaseState.h" | ||
|
||
class FSMState : public BaseState{ | ||
public: | ||
FSMState(CtrlComponents *ctrlComp, ArmFSMStateName stateName, std::string stateNameString); | ||
virtual ~FSMState(){} | ||
|
||
virtual void enter() = 0; | ||
virtual void run() = 0; | ||
virtual void exit() = 0; | ||
virtual int checkChange(int cmd) {return (int)ArmFSMStateName::INVALID;} | ||
bool _collisionTest(); | ||
|
||
protected: | ||
void _armCtrl(); | ||
void _recordData(); | ||
Vec6 _postureToVec6(Posture posture); | ||
void _tauFriction(); | ||
|
||
LowlevelCmd *_lowCmd; | ||
LowlevelState *_lowState; | ||
IOInterface *_ioInter; | ||
ArmModel *_armModel; | ||
|
||
Vec6 _qPast, _qdPast, _q, _qd, _qdd, _tauForward; | ||
double _gripperPos, _gripperW, _gripperTau; | ||
|
||
CtrlComponents *_ctrlComp; | ||
Vec6 _g, _tauCmd, _tauFric; | ||
|
||
private: | ||
|
||
uint _collisionCnt; | ||
|
||
Vec6 _mLinearFriction; | ||
Vec6 _mCoulombFriction; | ||
|
||
}; | ||
|
||
#endif // FSMSTATE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
#ifndef FSM_H | ||
#define FSM_H | ||
|
||
#include <vector> | ||
#include "FSM/FSMState.h" | ||
#include "common/utilities/loop.h" | ||
#include "control/CtrlComponents.h" | ||
|
||
class FiniteStateMachine{ | ||
public: | ||
FiniteStateMachine(std::vector<FSMState*> states, CtrlComponents *ctrlComp); | ||
virtual ~FiniteStateMachine(); | ||
|
||
private: | ||
void _run(); | ||
std::vector<FSMState*> _states; | ||
|
||
FSMMode _mode; | ||
bool _running; | ||
FSMState* _currentState; | ||
FSMState* _nextState; | ||
int _nextStateEnum; | ||
|
||
CtrlComponents *_ctrlComp; | ||
LoopFunc *_runThread; | ||
}; | ||
|
||
#ifndef FSM_H | ||
#define FSM_H | ||
|
||
#include <vector> | ||
#include "FSM/FSMState.h" | ||
#include "common/utilities/loop.h" | ||
#include "control/CtrlComponents.h" | ||
|
||
class FiniteStateMachine{ | ||
public: | ||
FiniteStateMachine(std::vector<FSMState*> states, CtrlComponents *ctrlComp); | ||
virtual ~FiniteStateMachine(); | ||
|
||
private: | ||
void _run(); | ||
std::vector<FSMState*> _states; | ||
|
||
FSMMode _mode; | ||
bool _running; | ||
FSMState* _currentState; | ||
FSMState* _nextState; | ||
int _nextStateEnum; | ||
|
||
CtrlComponents *_ctrlComp; | ||
LoopFunc *_runThread; | ||
}; | ||
|
||
#endif // FSM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
#ifndef STATE_BACKTOSTART_H | ||
#define STATE_BACKTOSTART_H | ||
|
||
|
||
#include "FSM/FSMState.h" | ||
#include "trajectory/JointSpaceTraj.h" | ||
|
||
class State_BackToStart : public FSMState{ | ||
public: | ||
State_BackToStart(CtrlComponents *ctrlComp); | ||
~State_BackToStart(); | ||
void enter(); | ||
void run(); | ||
void exit(); | ||
int checkChange(int cmd); | ||
private: | ||
bool _reach, _pastReach; | ||
JointSpaceTraj *_jointTraj; | ||
Vec6 _pos_startFlat; | ||
}; | ||
|
||
#ifndef STATE_BACKTOSTART_H | ||
#define STATE_BACKTOSTART_H | ||
|
||
|
||
#include "FSM/FSMState.h" | ||
#include "trajectory/JointSpaceTraj.h" | ||
|
||
class State_BackToStart : public FSMState{ | ||
public: | ||
State_BackToStart(CtrlComponents *ctrlComp); | ||
~State_BackToStart(); | ||
void enter(); | ||
void run(); | ||
void exit(); | ||
int checkChange(int cmd); | ||
private: | ||
bool _reach, _pastReach; | ||
JointSpaceTraj *_jointTraj; | ||
Vec6 _pos_startFlat; | ||
}; | ||
|
||
#endif // STATE_BACKTOSTART_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
#ifndef STATE_CALIBRATION_H | ||
#define STATE_CALIBRATION_H | ||
|
||
#include "FSM/FSMState.h" | ||
|
||
class State_Calibration : public FSMState{ | ||
public: | ||
State_Calibration(CtrlComponents *ctrlComp); | ||
~State_Calibration(){} | ||
void enter(); | ||
void run(){}; | ||
void exit(){}; | ||
int checkChange(int cmd); | ||
private: | ||
|
||
}; | ||
|
||
#ifndef STATE_CALIBRATION_H | ||
#define STATE_CALIBRATION_H | ||
|
||
#include "FSM/FSMState.h" | ||
|
||
class State_Calibration : public FSMState{ | ||
public: | ||
State_Calibration(CtrlComponents *ctrlComp); | ||
~State_Calibration(){} | ||
void enter(); | ||
void run(){}; | ||
void exit(){}; | ||
int checkChange(int cmd); | ||
private: | ||
|
||
}; | ||
|
||
#endif // STATE_CALIBRATION_H |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
#ifndef JOINTSPACE_H | ||
#define JOINTSPACE_H | ||
|
||
#include "FSM/FSMState.h" | ||
|
||
class State_JointSpace : public FSMState{ | ||
public: | ||
State_JointSpace(CtrlComponents *ctrlComp); | ||
~State_JointSpace(){} | ||
void enter(); | ||
void run(); | ||
void exit(); | ||
int checkChange(int cmd); | ||
private: | ||
std::vector<double> jointSpeedMax; | ||
}; | ||
|
||
#ifndef JOINTSPACE_H | ||
#define JOINTSPACE_H | ||
|
||
#include "FSM/FSMState.h" | ||
|
||
class State_JointSpace : public FSMState{ | ||
public: | ||
State_JointSpace(CtrlComponents *ctrlComp); | ||
~State_JointSpace(){} | ||
void enter(); | ||
void run(); | ||
void exit(); | ||
int checkChange(int cmd); | ||
private: | ||
std::vector<double> jointSpeedMax; | ||
}; | ||
|
||
#endif // JOINTSPACE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
#ifndef LOWCMD_H | ||
#define LOWCMD_H | ||
|
||
#include "FSMState.h" | ||
|
||
class State_LowCmd : public FSMState{ | ||
public: | ||
State_LowCmd(CtrlComponents *ctrlComp); | ||
void enter(); | ||
void run(); | ||
void exit(); | ||
int checkChange(int cmd); | ||
private: | ||
std::vector<float> _kp; | ||
std::vector<float> _kw; | ||
}; | ||
|
||
#ifndef LOWCMD_H | ||
#define LOWCMD_H | ||
|
||
#include "FSMState.h" | ||
|
||
class State_LowCmd : public FSMState{ | ||
public: | ||
State_LowCmd(CtrlComponents *ctrlComp); | ||
void enter(); | ||
void run(); | ||
void exit(); | ||
int checkChange(int cmd); | ||
private: | ||
std::vector<float> _kp; | ||
std::vector<float> _kw; | ||
}; | ||
|
||
#endif // LOWCMD_H |
Oops, something went wrong.