Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
On-Board Software
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Avionics
Software Development
On-Board Software
Commits
f364eac4
Commit
f364eac4
authored
10 months ago
by
Emilio Corigliano
Browse files
Options
Downloads
Patches
Plain Diff
[ARP] Updated actuators so that 'move' method moves the stepper of N steps, without the multiplier
parent
a1b11c80
Branches
Branches containing commit
Tags
Tags containing commit
Loading
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/boards/Groundstation/Automated/Actuators/Actuators.cpp
+29
-46
29 additions, 46 deletions
src/boards/Groundstation/Automated/Actuators/Actuators.cpp
with
29 additions
and
46 deletions
src/boards/Groundstation/Automated/Actuators/Actuators.cpp
+
29
−
46
View file @
f364eac4
...
...
@@ -148,42 +148,16 @@ float Actuators::getCurrentDegPosition(StepperList axis)
case
StepperList
::
STEPPER_X
:
return
stepperX
.
getCurrentDegPosition
()
/
Config
::
HORIZONTAL_MULTIPLIER
;
break
;
case
StepperList
::
STEPPER_Y
:
return
stepperY
.
getCurrentDegPosition
()
/
Config
::
VERTICAL_MULTIPLIER
;
break
;
default:
assert
(
false
&&
"Non existent stepper"
);
break
;
}
return
0
;
}
ErrorMovement
Actuators
::
move
(
StepperList
axis
,
int16_t
steps
)
{
float
microstepping
=
1.0
;
float
step_angle
=
1.8
;
switch
(
axis
)
{
case
StepperList
::
STEPPER_X
:
microstepping
=
static_cast
<
float
>
(
Config
::
HORIZONTAL_MICROSTEPPING
);
step_angle
=
Config
::
HORIZONTAL_STEP_ANGLE
;
break
;
case
StepperList
::
STEPPER_Y
:
microstepping
=
static_cast
<
float
>
(
Config
::
VERTICAL_MICROSTEPPING
);
step_angle
=
Config
::
VERTICAL_STEP_ANGLE
;
break
;
default:
assert
(
false
&&
"Non existent stepper"
);
break
;
}
return
moveDeg
(
axis
,
static_cast
<
float
>
(
steps
)
*
step_angle
/
microstepping
);
}
ErrorMovement
Actuators
::
move
Deg
(
StepperList
axis
,
float
degree
s
)
ErrorMovement
Actuators
::
move
(
StepperList
axis
,
int16_t
step
s
)
{
if
(
emergencyStop
)
{
...
...
@@ -208,12 +182,14 @@ ErrorMovement Actuators::moveDeg(StepperList axis, float degrees)
ErrorMovement
actuationState
=
ErrorMovement
::
OK
;
//< In case the move command is not limited
float
positionDeg
=
getCurrentDegPosition
(
axis
);
float
degrees
;
switch
(
axis
)
{
case
StepperList
::
STEPPER_X
:
if
(
!
stepperX
.
isEnabled
())
return
ErrorMovement
::
DISABLED
;
degrees
=
steps
*
Config
::
HORIZONTAL_STEP_ANGLE
/
Config
::
HORIZONTAL_MICROSTEPPING
;
// LIMIT POSITION IN ACCEPTABLE RANGE
if
(
positionDeg
+
degrees
>
Config
::
MAX_ANGLE_HORIZONTAL
)
...
...
@@ -226,15 +202,16 @@ ErrorMovement Actuators::moveDeg(StepperList axis, float degrees)
degrees
=
Config
::
MIN_ANGLE_HORIZONTAL
-
positionDeg
;
}
stepperX
.
moveDeg
(
degrees
*
Config
::
HORIZONTAL_MULTIPLIER
);
Logger
::
getInstance
().
log
(
static_cast
<
StepperXData
>
(
stepperX
.
getState
(
degrees
)));
stepperX
.
move
(
steps
);
deltaX
=
degrees
;
Logger
::
getInstance
().
log
(
static_cast
<
StepperXData
>
(
stepperX
.
getState
(
deltaX
)));
break
;
case
StepperList
::
STEPPER_Y
:
if
(
!
stepperY
.
isEnabled
())
return
ErrorMovement
::
DISABLED
;
degrees
=
steps
*
Config
::
VERTICAL_STEP_ANGLE
/
Config
::
VERTICAL_MICROSTEPPING
;
// LIMIT POSITION IN ACCEPTABLE RANGE
if
(
positionDeg
+
degrees
>
Config
::
MAX_ANGLE_VERTICAL
)
...
...
@@ -247,10 +224,10 @@ ErrorMovement Actuators::moveDeg(StepperList axis, float degrees)
degrees
=
Config
::
MIN_ANGLE_VERTICAL
-
positionDeg
;
}
stepperY
.
moveDeg
(
degrees
*
Config
::
VERTICAL_MULTIPLIER
);
stepperY
.
move
(
steps
);
deltaY
=
degrees
;
Logger
::
getInstance
().
log
(
static_cast
<
StepperYData
>
(
stepperY
.
getState
(
degrees
)));
deltaY
=
degrees
;
break
;
default
:
assert
(
false
&&
"Non existent stepper"
);
...
...
@@ -260,33 +237,39 @@ ErrorMovement Actuators::moveDeg(StepperList axis, float degrees)
return
actuationState
;
}
ErrorMovement
Actuators
::
setPosition
(
StepperList
axis
,
int16_t
step
s
)
ErrorMovement
Actuators
::
moveDeg
(
StepperList
axis
,
float
degree
s
)
{
float
microstepping
=
1.0
;
float
step_angle
=
1.8
;
int16_t
steps
=
0
;
switch
(
axis
)
{
case
StepperList
::
STEPPER_X
:
if
(
!
stepperX
.
isEnabled
())
return
ErrorMovement
::
DISABLED
;
microstepping
=
static_cast
<
float
>
(
Config
::
HORIZONTAL_MICROSTEPPING
);
step_angle
=
Config
::
HORIZONTAL_STEP_ANGLE
;
degrees
*=
Config
::
HORIZONTAL_MULTIPLIER
;
steps
=
static_cast
<
int16_t
>
(
degrees
*
Config
::
HORIZONTAL_MICROSTEPPING
/
Config
::
HORIZONTAL_STEP_ANGLE
);
break
;
case
StepperList
::
STEPPER_Y
:
if
(
!
stepperY
.
isEnabled
())
return
ErrorMovement
::
DISABLED
;
microstepping
=
static_cast
<
float
>
(
Config
::
VERTICAL_MICROSTEPPING
);
step_angle
=
Config
::
VERTICAL_STEP_ANGLE
;
degrees
*=
Config
::
VERTICAL_MULTIPLIER
;
steps
=
static_cast
<
int16_t
>
(
degrees
*
Config
::
VERTICAL_MICROSTEPPING
/
Config
::
VERTICAL_STEP_ANGLE
);
break
;
default:
assert
(
false
&&
"Non existent stepper"
);
return
ErrorMovement
::
NO_STEPPER
;
break
;
}
return
setPositionDeg
(
axis
,
static_cast
<
float
>
(
steps
)
*
step_angle
/
microstepping
);
move
(
axis
,
steps
);
}
void
Actuators
::
setPosition
(
StepperList
axis
,
int16_t
steps
)
{
move
(
axis
,
steps
-
getCurrentPosition
(
axis
));
}
ErrorMovement
Actuators
::
setPositionDeg
(
StepperList
axis
,
float
positionDeg
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment