Skip to content

Commit ed0d614

Browse files
committed
Hack the heading to 0
1 parent 1d0dc66 commit ed0d614

6 files changed

Lines changed: 18 additions & 3 deletions

File tree

cfg/LowLevelMotion.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ gen.add('roll_accumulator_max', double_t, 0, '', 0.0, 0.0, 100.0)
3030
gen.add('roll_accumulator_min', double_t, 0, '', 0.0, 0.0, 100.0)
3131
gen.add('roll_accumulator_enable_threshold', double_t, 0, '', 0.0, 0.0, 100.0)
3232

33+
gen.add('yaw_p', double_t, 0, '', 0.0, 0.0, 100.0)
34+
3335
exit(gen.generate(PACKAGE, "iarc7_motion", "LowLevelMotion"))

include/iarc7_motion/QuadVelocityController.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class QuadVelocityController
5151
double pitch_pid_settings[6],
5252
double roll_pid_settings[6],
5353
double (&position_p)[3],
54+
double yaw_p,
5455
const ThrustModel& thrust_model,
5556
const ThrustModel& thrust_model_side,
5657
const ros::Duration& battery_timeout,
@@ -121,6 +122,9 @@ class QuadVelocityController
121122
// P terms for the position control
122123
double (&position_p_)[3];
123124

125+
// P term for yaw hold
126+
double yaw_p_;
127+
124128
// Last time an update was successful
125129
ros::Time last_update_time_;
126130

param/low_level_motion_2.0.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ roll_accumulator_max: 5.0
3636
roll_accumulator_min: -5.0
3737
roll_accumulator_enable_threshold: 10.0
3838

39+
yaw_p: 0.0
40+
3941
min_side_thrust: 0.1
4042
max_side_thrust: 10.0
4143

param/low_level_motion_sim.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ roll_accumulator_max: 5.0
3636
roll_accumulator_min: -5.0
3737
roll_accumulator_enable_threshold: 10.0
3838

39+
yaw_p: 0.4
40+
3941
min_side_thrust: 0.0
4042
max_side_thrust: 0.0
4143

src/LowLevelMotionController.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ int main(int argc, char **argv)
9494
double pitch_pid[pid_param_array_size];
9595
double roll_pid[pid_param_array_size];
9696
double position_p[3];
97+
double yaw_p;
9798

9899
ThrustModel thrust_model(private_nh, "thrust_model");
99100
ThrustModel thrust_model_side;
@@ -140,6 +141,8 @@ int main(int argc, char **argv)
140141
position_p[1] = config.position_p_y;
141142
position_p[2] = config.position_p_z;
142143

144+
yaw_p = config.yaw_p;
145+
143146
dynamic_reconfigure_called = true;
144147
};
145148
dynamic_reconfigure_server.setCallback(dynamic_reconfigure_settings_callback);
@@ -193,6 +196,7 @@ int main(int argc, char **argv)
193196
pitch_pid,
194197
roll_pid,
195198
position_p,
199+
yaw_p,
196200
thrust_model,
197201
thrust_model_side,
198202
ros::Duration(battery_timeout),

src/QuadVelocityController.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ QuadVelocityController::QuadVelocityController(
3535
double vx_pid_settings[6],
3636
double vy_pid_settings[6],
3737
double (&position_p)[3],
38+
double yaw_p,
3839
const ThrustModel& thrust_model,
3940
const ThrustModel& thrust_model_side,
4041
const ros::Duration& battery_timeout,
@@ -60,6 +61,7 @@ QuadVelocityController::QuadVelocityController(
6061
private_nh,
6162
"xy_mixer")),
6263
position_p_(position_p),
64+
yaw_p_(yaw_p),
6365
startup_timeout_(ros_utils::ParamUtils::getParam<double>(
6466
private_nh,
6567
"startup_timeout")),
@@ -346,9 +348,8 @@ bool QuadVelocityController::update(const ros::Time& time,
346348
col_height)
347349
/ voltage;
348350

349-
// Yaw rate needs no correction because the input and output are both
350-
// velocities
351-
uav_command.data.yaw = -setpoint_.motion_point.twist.angular.z;
351+
// Hack heading to straight ahead
352+
uav_command.data.yaw = -yaw_p_ * (0.0 - current_yaw);
352353

353354
// Check that the PID loops did not return invalid values before returning
354355
if (!std::isfinite(uav_command.throttle)

0 commit comments

Comments
 (0)