Skip to content

Commit 302b0de

Browse files
committed
refactor: all gimbal essentials in dronecan frontend
1 parent 80b3c4b commit 302b0de

5 files changed

Lines changed: 21 additions & 32 deletions

File tree

Src/modules/rcout/dronecan_frontend/dronecan_frontend.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ void DronecanPwmFrontend::update_params() {
3131
if (pwm_cmd_type >= CommandType::NUMBER_OF_COMMANDS) {
3232
pwm_cmd_type = CommandType::RAW_COMMAND;
3333
}
34+
gimbal::gimbal_id = static_cast<uint8_t>
35+
(paramsGetIntegerValue(IntParamsIndexes::PARAM_GIMBAL_ID));
36+
gimbal::max_servos_travel = paramsGetIntegerValue(IntParamsIndexes::PARAM_SERVO_MAX_TRAVEL_DEG);
3437
}
3538

3639
void DronecanPwmFrontend::gimbal_angular_command_callback(const uavcan_equipment_camera_gimbal_AngularCommand& msg) {

Src/modules/rcout/dronecan_frontend/params.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,21 @@ pwm.input_type:
66
default: 0
77
min: 0
88
max: 2
9+
10+
servo.max_travel_degrees:
11+
type: Integer
12+
note: Maximum angular travel from PWM minimum to maximum (degrees).
13+
enum: PARAM_SERVO_MAX_TRAVEL_DEG
14+
flags: mutable
15+
default: 90
16+
min: 0
17+
max: 360
18+
19+
gimbal.id:
20+
type: Integer
21+
note: Current gimbal ID (to account several gimbals connected to one bus).
22+
enum: PARAM_GIMBAL_ID
23+
flags: mutable
24+
default: 0
25+
min: 0
26+
max: 127

Src/modules/rcout/main.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,6 @@ void RcoutModule::update_params() {
108108
for (auto& timing : timings) {
109109
timing.set_cmd_ttl(cmd_ttl);
110110
}
111-
gimbal::gimbal_id = static_cast<uint8_t>
112-
(paramsGetIntegerValue(IntParamsIndexes::PARAM_GIMBAL_ID));
113-
new_max_servos_travel = paramsGetIntegerValue(IntParamsIndexes::PARAM_SERVO_MAX_TRAVEL_DEG);
114-
115-
if (new_max_servos_travel != cached_max_servos_travel) {
116-
cached_max_servos_travel = new_max_servos_travel;
117-
#if CONFIG_USE_DRONECAN == 1
118-
gimbal::set_max_servos_angle(new_max_servos_travel);
119-
#endif
120-
}
121111

122112
auto param_frequency = paramsGetIntegerValue(IntParamsIndexes::PARAM_PWM_FREQUENCY);
123113
auto frequency = static_cast<uint16_t>(param_frequency);

Src/modules/rcout/main.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ class RcoutModule : public Module {
3131
protected:
3232
void update_params() override;
3333
void spin_once() override;
34-
private:
35-
// Current feedback
36-
uint16_t new_max_servos_travel = 90; // degrees
37-
uint16_t cached_max_servos_travel = 90;
3834
};
3935

4036
#endif // SRC_MODULES_PWM_PWMMODULE_HPP_

Src/modules/rcout/params.yaml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,6 @@ pwm.frequency:
1616
min: 50
1717
max: 400
1818

19-
servo.max_travel_degrees:
20-
type: Integer
21-
note: Maximum angular travel from PWM minimum to maximum (degrees).
22-
enum: PARAM_SERVO_MAX_TRAVEL_DEG
23-
flags: mutable
24-
default: 90
25-
min: 0
26-
max: 360
27-
28-
gimbal.id:
29-
type: Integer
30-
note: Current gimbal ID (to account several gimbals connected to one bus).
31-
enum: PARAM_GIMBAL_ID
32-
flags: mutable
33-
default: 0
34-
min: 0
35-
max: 127
36-
3719
pwm1.ch:
3820
type: Integer
3921
note: "Index of setpoint channel. [-1; 255]. -1 means disabled, XYZ/RPY: 0 - roll, 1 - pitch, 2 - yaw, -1 - off."

0 commit comments

Comments
 (0)