refact with reference

This commit is contained in:
Huang Zhenbiao 2024-09-18 13:18:02 +08:00
parent 85be4715ab
commit e390835458
13 changed files with 23 additions and 23 deletions

View File

@ -15,10 +15,10 @@ class FSMState {
public:
virtual ~FSMState() = default;
FSMState(const FSMStateName &stateName, std::string stateNameString, CtrlComponent ctrlComp)
: state_name(stateName),
state_name_string(std::move(stateNameString)),
ctrl_comp_(std::move(ctrlComp)) {
FSMState(const FSMStateName &state_name, std::string state_name_string, CtrlComponent &ctrl_comp)
: state_name(state_name),
state_name_string(std::move(state_name_string)),
ctrl_comp_(ctrl_comp) {
}
virtual void enter() = 0;
@ -33,7 +33,7 @@ public:
std::string state_name_string;
protected:
CtrlComponent ctrl_comp_;
CtrlComponent &ctrl_comp_;
};
#endif //FSMSTATE_H

View File

@ -9,7 +9,7 @@
class StateBalanceTest final : public FSMState {
public:
explicit StateBalanceTest(CtrlComponent ctrlComp);
explicit StateBalanceTest(CtrlComponent &ctrlComp);
void enter() override;

View File

@ -9,7 +9,7 @@
class StateFixedDown final : public FSMState {
public:
explicit StateFixedDown(CtrlComponent ctrlComp);
explicit StateFixedDown(CtrlComponent &ctrlComp);
void enter() override;

View File

@ -9,7 +9,7 @@
class StateFixedStand final : public FSMState {
public:
explicit StateFixedStand(CtrlComponent ctrlComp);
explicit StateFixedStand(CtrlComponent &ctrlComp);
void enter() override;

View File

@ -9,7 +9,7 @@
class StateFreeStand final : public FSMState {
public:
explicit StateFreeStand(CtrlComponent ctrl_component);
explicit StateFreeStand(CtrlComponent &ctrl_component);
void enter() override;

View File

@ -9,7 +9,7 @@
class StatePassive final : public FSMState {
public:
explicit StatePassive(CtrlComponent ctrlComp);
explicit StatePassive(CtrlComponent &ctrlComp);
void enter() override;

View File

@ -10,7 +10,7 @@
class StateSwingTest final : public FSMState {
public:
explicit StateSwingTest(CtrlComponent ctrlComp);
explicit StateSwingTest(CtrlComponent &ctrlComp);
void enter() override;

View File

@ -6,8 +6,8 @@
#include <unitree_guide_controller/common/mathTools.h>
StateBalanceTest::StateBalanceTest(CtrlComponent ctrlComp) : FSMState(FSMStateName::BALANCETEST, "balance test",
std::move(ctrlComp)),
StateBalanceTest::StateBalanceTest(CtrlComponent &ctrlComp) : FSMState(FSMStateName::BALANCETEST, "balance test",
ctrlComp),
estimator_(ctrlComp.estimator_.get()),
robot_model_(ctrlComp.robot_model_.get()),
balance_ctrl_(ctrlComp.balance_ctrl_.get()) {

View File

@ -6,8 +6,8 @@
#include <cmath>
StateFixedDown::StateFixedDown(CtrlComponent ctrlComp): FSMState(
FSMStateName::FIXEDDOWN, "fixed down", std::move(ctrlComp)) {
StateFixedDown::StateFixedDown(CtrlComponent &ctrlComp): FSMState(
FSMStateName::FIXEDDOWN, "fixed down", ctrlComp) {
duration_ = ctrl_comp_.frequency_ * 1.2;
}

View File

@ -6,8 +6,8 @@
#include <cmath>
StateFixedStand::StateFixedStand(CtrlComponent ctrlComp): FSMState(
FSMStateName::FIXEDSTAND, "fixed stand", std::move(ctrlComp)) {
StateFixedStand::StateFixedStand(CtrlComponent &ctrlComp): FSMState(
FSMStateName::FIXEDSTAND, "fixed stand", ctrlComp) {
duration_ = ctrl_comp_.frequency_ * 1.2;
}

View File

@ -5,8 +5,8 @@
#include "unitree_guide_controller/FSM/StateFreeStand.h"
#include "unitree_guide_controller/common/mathTools.h"
StateFreeStand::StateFreeStand(CtrlComponent ctrl_component) : FSMState(FSMStateName::FREESTAND, "free stand",
std::move(ctrl_component)) {
StateFreeStand::StateFreeStand(CtrlComponent &ctrl_component) : FSMState(FSMStateName::FREESTAND, "free stand",
ctrl_component) {
row_max_ = 20 * M_PI / 180;
row_min_ = -row_max_;
pitch_max_ = 15 * M_PI / 180;

View File

@ -7,8 +7,8 @@
#include <iostream>
#include <utility>
StatePassive::StatePassive(CtrlComponent ctrlComp) : FSMState(
FSMStateName::PASSIVE, "passive", std::move(ctrlComp)) {
StatePassive::StatePassive(CtrlComponent &ctrlComp) : FSMState(
FSMStateName::PASSIVE, "passive", ctrlComp) {
}
void StatePassive::enter() {

View File

@ -6,8 +6,8 @@
#include "unitree_guide_controller/FSM/StateSwingTest.h"
#include "unitree_guide_controller/common/mathTools.h"
StateSwingTest::StateSwingTest(CtrlComponent ctrlComp): FSMState(
FSMStateName::SWINGTEST, "swing test", std::move(ctrlComp)) {
StateSwingTest::StateSwingTest(CtrlComponent &ctrlComp): FSMState(
FSMStateName::SWINGTEST, "swing test", ctrlComp) {
_xMin = -0.15;
_xMax = 0.10;
_yMin = -0.15;