Skip to content

Commit aebf9e5

Browse files
committed
fix cartesian path bug
1 parent 0ded261 commit aebf9e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6497
-6495
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.vscode
2+
build

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set(PACKAGE_NAME z1_controller)
55
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O3")
66

77
# ----------------------options----------------------
8-
set(COMMUNICATION UDP) # UDP
8+
set(COMMUNICATION UDP) # UDP
99
# set(COMMUNICATION ROS) # ROS
1010

1111

include/FSM/BaseState.h

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
#ifndef BASESTATE_H
2-
#define BASESTATE_H
3-
4-
#include <string>
5-
#include "common/enumClass.h"
6-
7-
class BaseState{
8-
public:
9-
BaseState(int stateNameEnum, std::string stateNameString)
10-
: _stateNameEnum(stateNameEnum), _stateNameString(stateNameString){}
11-
virtual ~BaseState(){};
12-
13-
virtual void enter() = 0;
14-
virtual void run() = 0;
15-
virtual void exit() = 0;
16-
virtual int checkChange(int cmd) = 0;
17-
18-
bool isState(int stateEnum){
19-
if(_stateNameEnum == stateEnum){
20-
return true;
21-
}else{
22-
return false;
23-
}
24-
}
25-
std::string getStateName(){return _stateNameString;}
26-
int getStateNameEnum(){return _stateNameEnum;};
27-
protected:
28-
int _stateNameEnum;
29-
std::string _stateNameString;
30-
};
31-
1+
#ifndef BASESTATE_H
2+
#define BASESTATE_H
3+
4+
#include <string>
5+
#include "common/enumClass.h"
6+
7+
class BaseState{
8+
public:
9+
BaseState(int stateNameEnum, std::string stateNameString)
10+
: _stateNameEnum(stateNameEnum), _stateNameString(stateNameString){}
11+
virtual ~BaseState(){};
12+
13+
virtual void enter() = 0;
14+
virtual void run() = 0;
15+
virtual void exit() = 0;
16+
virtual int checkChange(int cmd) = 0;
17+
18+
bool isState(int stateEnum){
19+
if(_stateNameEnum == stateEnum){
20+
return true;
21+
}else{
22+
return false;
23+
}
24+
}
25+
std::string getStateName(){return _stateNameString;}
26+
int getStateNameEnum(){return _stateNameEnum;};
27+
protected:
28+
int _stateNameEnum;
29+
std::string _stateNameString;
30+
};
31+
3232
#endif

include/FSM/FSMState.h

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
#ifndef FSMSTATE_H
2-
#define FSMSTATE_H
3-
4-
#include <string>
5-
#include <iostream>
6-
#include <unistd.h>
7-
#include "control/CtrlComponents.h"
8-
#include "common/math/mathTools.h"
9-
#include "common/utilities/timer.h"
10-
#include "FSM/BaseState.h"
11-
12-
class FSMState : public BaseState{
13-
public:
14-
FSMState(CtrlComponents *ctrlComp, ArmFSMStateName stateName, std::string stateNameString);
15-
virtual ~FSMState(){}
16-
17-
virtual void enter() = 0;
18-
virtual void run() = 0;
19-
virtual void exit() = 0;
20-
virtual int checkChange(int cmd) {return (int)ArmFSMStateName::INVALID;}
21-
bool _collisionTest();
22-
23-
protected:
24-
void _armCtrl();
25-
void _recordData();
26-
Vec6 _postureToVec6(Posture posture);
27-
void _tauFriction();
28-
29-
LowlevelCmd *_lowCmd;
30-
LowlevelState *_lowState;
31-
IOInterface *_ioInter;
32-
ArmModel *_armModel;
33-
34-
Vec6 _qPast, _qdPast, _q, _qd, _qdd, _tauForward;
35-
double _gripperPos, _gripperW, _gripperTau;
36-
37-
CtrlComponents *_ctrlComp;
38-
Vec6 _g, _tauCmd, _tauFric;
39-
40-
private:
41-
42-
uint _collisionCnt;
43-
44-
Vec6 _mLinearFriction;
45-
Vec6 _mCoulombFriction;
46-
47-
};
48-
49-
#endif // FSMSTATE_H
1+
#ifndef FSMSTATE_H
2+
#define FSMSTATE_H
3+
4+
#include <string>
5+
#include <iostream>
6+
#include <unistd.h>
7+
#include "control/CtrlComponents.h"
8+
#include "common/math/mathTools.h"
9+
#include "common/utilities/timer.h"
10+
#include "FSM/BaseState.h"
11+
12+
class FSMState : public BaseState{
13+
public:
14+
FSMState(CtrlComponents *ctrlComp, ArmFSMStateName stateName, std::string stateNameString);
15+
virtual ~FSMState(){}
16+
17+
virtual void enter() = 0;
18+
virtual void run() = 0;
19+
virtual void exit() = 0;
20+
virtual int checkChange(int cmd) {return (int)ArmFSMStateName::INVALID;}
21+
bool _collisionTest();
22+
23+
protected:
24+
void _armCtrl();
25+
void _recordData();
26+
Vec6 _postureToVec6(Posture posture);
27+
void _tauFriction();
28+
29+
LowlevelCmd *_lowCmd;
30+
LowlevelState *_lowState;
31+
IOInterface *_ioInter;
32+
ArmModel *_armModel;
33+
34+
Vec6 _qPast, _qdPast, _q, _qd, _qdd, _tauForward;
35+
double _gripperPos, _gripperW, _gripperTau;
36+
37+
CtrlComponents *_ctrlComp;
38+
Vec6 _g, _tauCmd, _tauFric;
39+
40+
private:
41+
42+
uint _collisionCnt;
43+
44+
Vec6 _mLinearFriction;
45+
Vec6 _mCoulombFriction;
46+
47+
};
48+
49+
#endif // FSMSTATE_H

include/FSM/FiniteStateMachine.h

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
#ifndef FSM_H
2-
#define FSM_H
3-
4-
#include <vector>
5-
#include "FSM/FSMState.h"
6-
#include "common/utilities/loop.h"
7-
#include "control/CtrlComponents.h"
8-
9-
class FiniteStateMachine{
10-
public:
11-
FiniteStateMachine(std::vector<FSMState*> states, CtrlComponents *ctrlComp);
12-
virtual ~FiniteStateMachine();
13-
14-
private:
15-
void _run();
16-
std::vector<FSMState*> _states;
17-
18-
FSMMode _mode;
19-
bool _running;
20-
FSMState* _currentState;
21-
FSMState* _nextState;
22-
int _nextStateEnum;
23-
24-
CtrlComponents *_ctrlComp;
25-
LoopFunc *_runThread;
26-
};
27-
1+
#ifndef FSM_H
2+
#define FSM_H
3+
4+
#include <vector>
5+
#include "FSM/FSMState.h"
6+
#include "common/utilities/loop.h"
7+
#include "control/CtrlComponents.h"
8+
9+
class FiniteStateMachine{
10+
public:
11+
FiniteStateMachine(std::vector<FSMState*> states, CtrlComponents *ctrlComp);
12+
virtual ~FiniteStateMachine();
13+
14+
private:
15+
void _run();
16+
std::vector<FSMState*> _states;
17+
18+
FSMMode _mode;
19+
bool _running;
20+
FSMState* _currentState;
21+
FSMState* _nextState;
22+
int _nextStateEnum;
23+
24+
CtrlComponents *_ctrlComp;
25+
LoopFunc *_runThread;
26+
};
27+
2828
#endif // FSM_H

include/FSM/State_BackToStart.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
#ifndef STATE_BACKTOSTART_H
2-
#define STATE_BACKTOSTART_H
3-
4-
5-
#include "FSM/FSMState.h"
6-
#include "trajectory/JointSpaceTraj.h"
7-
8-
class State_BackToStart : public FSMState{
9-
public:
10-
State_BackToStart(CtrlComponents *ctrlComp);
11-
~State_BackToStart();
12-
void enter();
13-
void run();
14-
void exit();
15-
int checkChange(int cmd);
16-
private:
17-
bool _reach, _pastReach;
18-
JointSpaceTraj *_jointTraj;
19-
Vec6 _pos_startFlat;
20-
};
21-
1+
#ifndef STATE_BACKTOSTART_H
2+
#define STATE_BACKTOSTART_H
3+
4+
5+
#include "FSM/FSMState.h"
6+
#include "trajectory/JointSpaceTraj.h"
7+
8+
class State_BackToStart : public FSMState{
9+
public:
10+
State_BackToStart(CtrlComponents *ctrlComp);
11+
~State_BackToStart();
12+
void enter();
13+
void run();
14+
void exit();
15+
int checkChange(int cmd);
16+
private:
17+
bool _reach, _pastReach;
18+
JointSpaceTraj *_jointTraj;
19+
Vec6 _pos_startFlat;
20+
};
21+
2222
#endif // STATE_BACKTOSTART_H

include/FSM/State_Calibration.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
#ifndef STATE_CALIBRATION_H
2-
#define STATE_CALIBRATION_H
3-
4-
#include "FSM/FSMState.h"
5-
6-
class State_Calibration : public FSMState{
7-
public:
8-
State_Calibration(CtrlComponents *ctrlComp);
9-
~State_Calibration(){}
10-
void enter();
11-
void run(){};
12-
void exit(){};
13-
int checkChange(int cmd);
14-
private:
15-
16-
};
17-
1+
#ifndef STATE_CALIBRATION_H
2+
#define STATE_CALIBRATION_H
3+
4+
#include "FSM/FSMState.h"
5+
6+
class State_Calibration : public FSMState{
7+
public:
8+
State_Calibration(CtrlComponents *ctrlComp);
9+
~State_Calibration(){}
10+
void enter();
11+
void run(){};
12+
void exit(){};
13+
int checkChange(int cmd);
14+
private:
15+
16+
};
17+
1818
#endif // STATE_CALIBRATION_H

include/FSM/State_Cartesian.h

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class State_Cartesian : public FSMState{
1616
double _posSpeed = 0.2;
1717
double oriSpeedLimit = 0.5;// limits in SDK
1818
double posSpeedLimit = 0.5;
19-
VecX _changeDirections;
19+
VecX _changeDirectionsf;
2020

2121
Vec6 _twist;
2222
HomoMat _endHomoGoal, _endHomoPast, _endHomoDelta;

include/FSM/State_JointSpace.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
#ifndef JOINTSPACE_H
2-
#define JOINTSPACE_H
3-
4-
#include "FSM/FSMState.h"
5-
6-
class State_JointSpace : public FSMState{
7-
public:
8-
State_JointSpace(CtrlComponents *ctrlComp);
9-
~State_JointSpace(){}
10-
void enter();
11-
void run();
12-
void exit();
13-
int checkChange(int cmd);
14-
private:
15-
std::vector<double> jointSpeedMax;
16-
};
17-
1+
#ifndef JOINTSPACE_H
2+
#define JOINTSPACE_H
3+
4+
#include "FSM/FSMState.h"
5+
6+
class State_JointSpace : public FSMState{
7+
public:
8+
State_JointSpace(CtrlComponents *ctrlComp);
9+
~State_JointSpace(){}
10+
void enter();
11+
void run();
12+
void exit();
13+
int checkChange(int cmd);
14+
private:
15+
std::vector<double> jointSpeedMax;
16+
};
17+
1818
#endif // JOINTSPACE_H

include/FSM/State_LowCmd.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
#ifndef LOWCMD_H
2-
#define LOWCMD_H
3-
4-
#include "FSMState.h"
5-
6-
class State_LowCmd : public FSMState{
7-
public:
8-
State_LowCmd(CtrlComponents *ctrlComp);
9-
void enter();
10-
void run();
11-
void exit();
12-
int checkChange(int cmd);
13-
private:
14-
std::vector<float> _kp;
15-
std::vector<float> _kw;
16-
};
17-
1+
#ifndef LOWCMD_H
2+
#define LOWCMD_H
3+
4+
#include "FSMState.h"
5+
6+
class State_LowCmd : public FSMState{
7+
public:
8+
State_LowCmd(CtrlComponents *ctrlComp);
9+
void enter();
10+
void run();
11+
void exit();
12+
int checkChange(int cmd);
13+
private:
14+
std::vector<float> _kp;
15+
std::vector<float> _kw;
16+
};
17+
1818
#endif // LOWCMD_H

0 commit comments

Comments
 (0)