Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
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
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emilio Corigliano
Skyward Boardcore
Commits
c18571bf
Commit
c18571bf
authored
3 years ago
by
Alberto Nidasio
Browse files
Options
Downloads
Patches
Plain Diff
[Servo] Implemented reset position
parent
3df306e8
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/shared/actuators/Servo/Servo.cpp
+14
-4
14 additions, 4 deletions
src/shared/actuators/Servo/Servo.cpp
src/shared/actuators/Servo/Servo.h
+21
-0
21 additions, 0 deletions
src/shared/actuators/Servo/Servo.h
with
35 additions
and
4 deletions
src/shared/actuators/Servo/Servo.cpp
+
14
−
4
View file @
c18571bf
...
...
@@ -31,22 +31,32 @@ namespace Boardcore
Servo
::
Servo
(
TIM_TypeDef
*
const
timer
,
TimerUtils
::
Channel
pwmChannel
,
unsigned
int
minPulse
,
unsigned
int
maxPulse
,
unsigned
int
frequency
)
unsigned
int
frequency
,
unsigned
int
resetPulse
)
:
pwm
(
timer
,
frequency
),
pwmChannel
(
pwmChannel
),
minPulse
(
minPulse
),
maxPulse
(
maxPulse
),
frequency
(
frequency
)
maxPulse
(
maxPulse
),
resetPulse
(
resetPulse
),
frequency
(
frequency
)
{
setPosition
(
resetPulse
);
}
Servo
::
Servo
(
TIM_TypeDef
*
const
timer
,
TimerUtils
::
Channel
pwmChannel
,
unsigned
int
minPulse
,
unsigned
int
maxPulse
,
unsigned
int
frequency
)
:
Servo
(
timer
,
pwmChannel
,
minPulse
,
maxPulse
,
frequency
,
minPulse
)
{
setPosition
(
0
);
}
void
Servo
::
enable
()
{
pwm
.
enableChannel
(
pwmChannel
);
}
void
Servo
::
disable
()
{
pwm
.
disableChannel
(
pwmChannel
);
}
void
Servo
::
reset
()
{
setPosition
(
resetPulse
);
}
#else
Servo
::
Servo
(
unsigned
int
minPulse
,
unsigned
int
maxPulse
,
unsigned
int
frequency
)
:
minPulse
(
minPulse
),
maxPulse
(
maxPulse
),
frequency
(
frequency
)
:
minPulse
(
minPulse
),
maxPulse
(
maxPulse
),
frequency
(
frequency
),
resetPulse
(
minPulse
)
{
setPosition
(
0
);
}
...
...
This diff is collapsed.
Click to expand it.
src/shared/actuators/Servo/Servo.h
+
21
−
0
View file @
c18571bf
...
...
@@ -76,6 +76,21 @@ public:
explicit
Servo
(
TIM_TypeDef
*
const
timer
,
TimerUtils
::
Channel
pwmChannel
,
unsigned
int
minPulse
=
1000
,
unsigned
int
maxPulse
=
2000
,
unsigned
int
frequency
=
50
);
/**
* @brief Prepare the timer and sets the PWM output to the minimum.
*
* @see Servo::Servo
*
* @param timer Timer peripheral used for the PWM signal.
* @param pwmChannel Timer's channel used for the PWM signal.
* @param frequency Frequency of the PWM driving the H-bridge.
* @param minPulse Minimum signal pulse in microseconds.
* @param maxPulse Maximum signal pulse in microseconds.
* @param resetPulse Reset signal pulse in microseconds.
*/
explicit
Servo
(
TIM_TypeDef
*
const
timer
,
TimerUtils
::
Channel
pwmChannel
,
unsigned
int
minPulse
,
unsigned
int
maxPulse
,
unsigned
int
frequency
,
unsigned
int
resetPulse
);
#else
explicit
Servo
(
unsigned
int
minPulse
=
1000
,
unsigned
int
maxPulse
=
2000
,
unsigned
int
frequency
=
50
);
...
...
@@ -91,6 +106,11 @@ public:
*/
void
disable
();
/**
* @brief Moves the servo to the reset position.
*/
void
reset
();
/**
* @brief Set the position of the servomotor.
*
...
...
@@ -136,6 +156,7 @@ private:
float
minPulse
;
float
maxPulse
;
float
resetPulse
;
float
frequency
;
};
...
...
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