Skip to content

Commit

Permalink
support for arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
Agnel-Wang committed Apr 26, 2023
1 parent cae64c9 commit fd5a63f
Show file tree
Hide file tree
Showing 48 changed files with 6,493 additions and 6,491 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
build
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ link_directories(lib)
# ----------------------add executable----------------------
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_executable(z1_ctrl main.cpp)
target_link_libraries(z1_ctrl libZ1_${COMMUNICATION}_Linux64.so ${catkin_LIBRARIES} )
target_link_libraries(z1_ctrl libZ1_${COMMUNICATION}_${CMAKE_HOST_SYSTEM_PROCESSOR}.so ${catkin_LIBRARIES} )
62 changes: 31 additions & 31 deletions include/FSM/BaseState.h
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
98 changes: 49 additions & 49 deletions include/FSM/FSMState.h
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
54 changes: 27 additions & 27 deletions include/FSM/FiniteStateMachine.h
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
42 changes: 21 additions & 21 deletions include/FSM/State_BackToStart.h
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
34 changes: 17 additions & 17 deletions include/FSM/State_Calibration.h
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 modified include/FSM/State_Cartesian.h
100755 → 100644
Empty file.
34 changes: 17 additions & 17 deletions include/FSM/State_JointSpace.h
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
34 changes: 17 additions & 17 deletions include/FSM/State_LowCmd.h
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
Loading

0 comments on commit fd5a63f

Please sign in to comment.