Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
c9d72c0d
Commit
c9d72c0d
authored
7 years ago
by
bresch
Committed by
Roman Bapst
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
PWMSim : add MC_AIRMODE support
parent
7ef3ae88
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/drivers/pwm_out_sim/PWMSim.cpp
+30
-0
30 additions, 0 deletions
src/drivers/pwm_out_sim/PWMSim.cpp
src/drivers/pwm_out_sim/PWMSim.hpp
+4
-0
4 additions, 0 deletions
src/drivers/pwm_out_sim/PWMSim.hpp
with
34 additions
and
0 deletions
src/drivers/pwm_out_sim/PWMSim.cpp
+
30
−
0
View file @
c9d72c0d
...
...
@@ -135,6 +135,18 @@ PWMSim::subscribe()
}
}
void
PWMSim
::
update_params
()
{
// multicopter air-mode
param_t
param_handle
=
param_find
(
"MC_AIRMODE"
);
if
(
param_handle
!=
PARAM_INVALID
)
{
int32_t
val
;
param_get
(
param_handle
,
&
val
);
_airmode
=
val
>
0
;
}
}
void
PWMSim
::
run
()
{
...
...
@@ -146,6 +158,9 @@ PWMSim::run()
/* advertise the mixed control outputs, insist on the first group output */
_outputs_pub
=
orb_advertise
(
ORB_ID
(
actuator_outputs
),
&
_actuator_outputs
);
update_params
();
int
params_sub
=
orb_subscribe
(
ORB_ID
(
parameter_update
));
/* loop until killed */
while
(
!
should_exit
())
{
...
...
@@ -172,6 +187,10 @@ PWMSim::run()
_current_update_rate
=
_update_rate
;
}
if
(
_mixers
)
{
_mixers
->
set_airmode
(
_airmode
);
}
/* this can happen during boot, but after the sleep its likely resolved */
if
(
_poll_fds_num
==
0
)
{
usleep
(
1000
*
1000
);
...
...
@@ -283,6 +302,16 @@ PWMSim::run()
_lockdown
=
aa
.
manual_lockdown
;
}
}
/* check for parameter updates */
bool
param_updated
=
false
;
orb_check
(
params_sub
,
&
param_updated
);
if
(
param_updated
)
{
struct
parameter_update_s
update
;
orb_copy
(
ORB_ID
(
parameter_update
),
params_sub
,
&
update
);
update_params
();
}
}
for
(
unsigned
i
=
0
;
i
<
actuator_controls_s
::
NUM_ACTUATOR_CONTROL_GROUPS
;
i
++
)
{
...
...
@@ -292,6 +321,7 @@ PWMSim::run()
}
orb_unsubscribe
(
_armed_sub
);
orb_unsubscribe
(
params_sub
);
}
int
...
...
This diff is collapsed.
Click to expand it.
src/drivers/pwm_out_sim/PWMSim.hpp
+
4
−
0
View file @
c9d72c0d
...
...
@@ -49,6 +49,7 @@
#include
<uORB/topics/actuator_armed.h>
#include
<uORB/topics/actuator_controls.h>
#include
<uORB/topics/actuator_outputs.h>
#include
<uORB/topics/parameter_update.h>
class
PWMSim
:
public
device
::
CDev
,
public
ModuleBase
<
PWMSim
>
{
...
...
@@ -129,10 +130,13 @@ private:
actuator_controls_s
_controls
[
actuator_controls_s
::
NUM_ACTUATOR_CONTROL_GROUPS
]
{};
orb_id_t
_control_topics
[
actuator_controls_s
::
NUM_ACTUATOR_CONTROL_GROUPS
]
{};
bool
_airmode
{
false
};
///< multicopter air-mode
static
int
control_callback
(
uintptr_t
handle
,
uint8_t
control_group
,
uint8_t
control_index
,
float
&
input
);
void
subscribe
();
void
update_params
();
};
#endif
/* DRIVERS_PWM_OUT_SIM_PWMSIM_HPP_ */
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