Skip to content

Commit 8999a3b

Browse files
Trim Tab Angle Scaling (#501)
* Updated trim tab scaling * Flake 8 updates * Changed scaling function * Updated upper wind threshold
1 parent 8a426bd commit 8999a3b

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

src/controller/controller/wingsail/wingsail_ctrl_node.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
from controller.common.lut import LUT
1616
from controller.wingsail.controllers import WingsailController
1717

18-
SCALING_INTERCEPT = 1
19-
2018

2119
def main(args=None):
2220
rclpy.init(args=args)
@@ -78,8 +76,8 @@ def __declare_ros_parameters(self):
7876
("pub_period_sec", rclpy.Parameter.Type.DOUBLE),
7977
("reynolds_number", rclpy.Parameter.Type.DOUBLE_ARRAY),
8078
("angle_of_attack", rclpy.Parameter.Type.DOUBLE_ARRAY),
81-
("apparent_wind_threshold", rclpy.Parameter.Type.DOUBLE),
82-
("scaling_coef", rclpy.Parameter.Type.DOUBLE),
79+
("apparent_wind_lower_threshold", rclpy.Parameter.Type.DOUBLE),
80+
("apparent_wind_upper_threshold", rclpy.Parameter.Type.DOUBLE),
8381
],
8482
)
8583

@@ -146,20 +144,26 @@ def __publish(self):
146144

147145
apparent_speed = self.__filtered_wind_sensor.speed.speed
148146
apparent_direction = self.__filtered_wind_sensor.direction
149-
apparent_threshold = (
150-
self.get_parameter("apparent_wind_threshold").get_parameter_value().double_value
147+
apparent_lower_threshold = (
148+
self.get_parameter("apparent_wind_lower_threshold").get_parameter_value().double_value
149+
)
150+
apparent_upper_threshold = (
151+
self.get_parameter("apparent_wind_upper_threshold").get_parameter_value().double_value
151152
)
152153

153-
# Sets trim tab angle, scales if apparent wind speed is above threshold
154154
self.__trim_tab_angle = self.__wingsailController.get_trim_tab_angle(
155155
apparent_speed, apparent_direction
156156
)
157-
if apparent_speed > apparent_threshold:
158-
coef = self.get_parameter("scaling_coef").get_parameter_value().double_value
159-
speed_difference = apparent_threshold - apparent_speed
160-
self.__trim_tab_angle = (
161-
self.__trim_tab_angle * coef * speed_difference + SCALING_INTERCEPT
162-
)
157+
158+
# Gets scaling factor based on wind speed thresholds
159+
scaling_coef = 1
160+
if apparent_speed > apparent_lower_threshold and apparent_speed < apparent_upper_threshold:
161+
difference = apparent_upper_threshold - apparent_lower_threshold
162+
scaling_coef = -1 * (apparent_speed - apparent_lower_threshold) / difference + 1
163+
elif apparent_speed >= apparent_upper_threshold:
164+
scaling_coef = 0
165+
166+
self.__trim_tab_angle = scaling_coef * self.__trim_tab_angle
163167

164168
msg.trim_tab_angle_degrees = self.__trim_tab_angle
165169

src/global_launch/config/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ ROS parameters specific to the nodes in the Controller.
9191
- _Datatype_: `double`
9292
- _Range_: `(-180.0, 180.0]`
9393

94-
**`apparent_wind_threshold`**
94+
**`apparent_wind_lower_threshold`**
9595

96-
- _Description_: The high wind threshold value for apparent wind.
96+
- _Description_: The lower wind threshold value for apparent wind.
9797
- _Datatype_: 'double'
9898
- _Range_: '[0.0, MAX_DOUBLE)'
9999

100-
**`scaling_coef`**
100+
**`apparent_wind_upper_threshold`**
101101

102-
- _Description_: The coefficient used to scale trim tab angle.
102+
- _Description_: The higher wind threshold value for apparent wind.
103103
- _Datatype_: 'double'
104104
- _Range_: '[0.0, MAX_DOUBLE)'
105105

src/global_launch/config/globals.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ wingsail_ctrl_node:
2121
ros__parameters:
2222
reynolds_number: [0.0, 1.0, 2.0]
2323
angle_of_attack: [0.0, 1.0, 2.0]
24-
apparent_wind_threshold: 10.0
25-
scaling_coef: 1.0
24+
apparent_wind_lower_threshold: 10.0
25+
apparent_wind_upper_threshold: 15.0
2626

2727
# boat_simulator parameters
2828
low_level_control_node:

0 commit comments

Comments
 (0)