Skip to content

Feature/bldc haptics #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Jun 3, 2023
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3522aef
feat(bldc_haptics): initial bldc_haptics component
finger563 May 25, 2023
04aa8ab
feat(bldc_haptics): remove empty src
finger563 May 25, 2023
e6ee866
feat(pid): udpate API
finger563 May 26, 2023
1c18925
chore(math): add maybe_unused to suppress compiler warning
finger563 May 26, 2023
ae25fb9
doc: update
finger563 May 26, 2023
f66034f
ci: update
finger563 May 26, 2023
f47e192
removed unneeded file
finger563 May 26, 2023
208ddcf
feat(bldc_driver): add fault
finger563 May 27, 2023
a76c066
feat(bldc_motor): update example
finger563 May 27, 2023
cdd3bd9
example(bldc_motor): update to use logger
finger563 May 27, 2023
550a203
example(bldc_haptics): update
finger563 May 27, 2023
dde3d42
feat(bldc_haptics): allow pid config
finger563 May 29, 2023
abfe080
feat(bldc_motor): refactor types
finger563 May 31, 2023
59e8acf
feat(bldc_haptics): updated interface
finger563 May 31, 2023
4ec09be
doc(rtsp): update
finger563 May 31, 2023
a56542a
doc(ftp): update
finger563 May 31, 2023
65f3ff7
feat(bldc_haptics): updated haptics
finger563 Jun 1, 2023
d5f41ca
doc
finger563 Jun 1, 2023
671d80f
doc: update
finger563 Jun 1, 2023
682ca04
doc: rebuild
finger563 Jun 1, 2023
e162a78
feat(haptics): update api
finger563 Jun 2, 2023
b52a513
example(haptics): update
finger563 Jun 2, 2023
114392e
update to use new logger
finger563 Jun 2, 2023
1e1d2c3
merge main
finger563 Jun 2, 2023
a874795
feat(bldc_motor): accept 0 targets in the move() command
finger563 Jun 2, 2023
58c45bb
feat(bldc_haptics): better behavior
finger563 Jun 2, 2023
ffaaad5
feat(bldc_motor): minor update
finger563 Jun 3, 2023
b71ab12
feat(bldc_haptics): working haptics example
finger563 Jun 3, 2023
8fb55f1
doc: rebuild
finger563 Jun 3, 2023
886d5e3
feat(bldc_haptics): update example
finger563 Jun 3, 2023
e3beb88
doc: rebuild
finger563 Jun 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update to use new logger
  • Loading branch information
finger563 committed Jun 2, 2023
commit 114392e8f8e27dc1e344c97a017d436421f280bc
23 changes: 15 additions & 8 deletions components/bldc_haptics/include/bldc_haptics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ template <MotorConcept M> class BldcHaptics {
,
kp_factor_(config.kp_factor), kd_factor_min_(config.kd_factor_min),
kd_factor_max_(config.kd_factor_max), motor_(config.motor),
logger_({.tag = "BldcHaptics", .level = config.log_level}) {
logger_({.tag = "BldcHaptics",
.rate_limit = std::chrono::milliseconds(100),
.level = config.log_level}) {
// set the motion control type to torque
motor_.get().set_motion_control_type(detail::MotionControlType::TORQUE);
// create the motor task
Expand Down Expand Up @@ -308,10 +310,15 @@ template <MotorConcept M> class BldcHaptics {
((angle_to_detent_center > 0 && current_position_ == detent_config.min_position) ||
(angle_to_detent_center < 0 && current_position_ == detent_config.max_position));

logger_.debug("Current position: {}, current detent center: {}, motor angle: {}, "
"angle_to_detent_center: {}, dead_zone_adjustment: {}, out_of_bounds: {}",
current_position_, current_detent_center_, motor_angle, angle_to_detent_center,
dead_zone_adjustment, out_of_bounds);
logger_.debug_rate_limited("\n"
"\tCurrent position: {}\n"
"\tcurrent detent center: {}\n"
"\tmotor angle: {}\n"
"\tangle_to_detent_center: {}\n"
"\tdead_zone_adjustment: {}\n"
"\tout_of_bounds: {}",
current_position_, current_detent_center_, motor_angle,
angle_to_detent_center, dead_zone_adjustment, out_of_bounds);

// update the PID parameters based on our position
Pid::Config pid_config = detent_pid_.get_config();
Expand All @@ -321,15 +328,14 @@ template <MotorConcept M> class BldcHaptics {
: detent_config.detent_strength *
kp_factor_; // if we're in bounds, then we apply detent force
// we don't want to clear the PID state when we change the config, so we pass false
logger_.debug("setting detent PID config: {}", pid_config);
detent_pid_.set_config(pid_config, false);

// Apply motor torque based on our angle to the nearest detent (detent
// strength, etc is handled by the pid parameters)
if (std::abs(motor_.get().get_shaft_velocity()) > 60) {
// Don't apply torque if velocity is too high (helps avoid positive
// feedback loop/runaway)
logger_.debug("velocity too high, not applying torque");
logger_.info_rate_limited("velocity too high, not applying torque");
motor_.get().move(0);
} else {
// apply torque based on our angle to the nearest detent
Expand All @@ -353,7 +359,8 @@ template <MotorConcept M> class BldcHaptics {
}
// get the torque from the PID controller
float torque = detent_pid_.update(input);
logger_.debug("{:0.2f} -> {:0.2f}", input, torque);
logger_.info_rate_limited("angle: {:0.2f}, input: {:0.2f}, torque: {:0.2f}", motor_angle,
input, torque);
// apply the torque to the motor
motor_.get().move(-torque);
} // end if std::abs(motor_.get().get_shaft_velocity()) > 60
Expand Down