Skip to content

Commit 016b377

Browse files
committed
pbio: Avoid direct docstring in header.
In editors like vscode, docstrings in the headers take priority over those in the source, so we should add a line break after the category descriptors. Otherwise, the hover menu will pick the wrong docstring.
1 parent ceabdd3 commit 016b377

File tree

10 files changed

+70
-61
lines changed

10 files changed

+70
-61
lines changed

lib/pbio/include/pbio/angle.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,24 @@ typedef struct _pbio_angle_t {
2828
int32_t millidegrees; /**< Millidegrees.*/
2929
} pbio_angle_t;
3030

31-
// Conversion to and from basic types.
31+
// Conversion to and from basic types:
32+
3233
int32_t pbio_angle_to_low_res(pbio_angle_t *a, int32_t scale);
3334
void pbio_angle_from_low_res(pbio_angle_t *a, int32_t input, int32_t scale);
3435

35-
// Inplace operations on an angle.
36+
// Inplace operations on an angle:
37+
3638
void pbio_angle_neg(pbio_angle_t *a);
3739
void pbio_angle_add_mdeg(pbio_angle_t *a, int32_t increment);
3840

39-
// Binary operations on two angles to produce new angle.
41+
// Binary operations on two angles to produce new angle:
42+
4043
void pbio_angle_diff(pbio_angle_t *a, pbio_angle_t *b, pbio_angle_t *result);
4144
void pbio_angle_sum(pbio_angle_t *a, pbio_angle_t *b, pbio_angle_t *result);
4245
void pbio_angle_avg(pbio_angle_t *a, pbio_angle_t *b, pbio_angle_t *result);
4346

44-
// Compares two angles.
47+
// Compare two angles:
48+
4549
int32_t pbio_angle_diff_mdeg(pbio_angle_t *a, pbio_angle_t *b);
4650
bool pbio_angle_diff_is_small(pbio_angle_t *a, pbio_angle_t *b);
4751

lib/pbio/include/pbio/control.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,29 @@ typedef struct _pbio_control_t {
137137
bool on_target;
138138
} pbio_control_t;
139139

140-
// Time functions.
140+
// Time functions:
141+
141142
uint32_t pbio_control_get_time_ticks(void);
142143
uint32_t pbio_control_get_ref_time(pbio_control_t *ctl, uint32_t time_now);
143144
bool pbio_control_time_is_later(uint32_t sample, uint32_t base);
144145

145-
// Control loop functions.
146+
// Control loop functions:
147+
146148
void pbio_control_reset(pbio_control_t *ctl);
147149
void pbio_control_stop(pbio_control_t *ctl);
148150
void pbio_control_update(pbio_control_t *ctl, uint32_t time_now, pbio_control_state_t *state, pbio_trajectory_reference_t *ref, pbio_dcmotor_actuation_t *actuation, int32_t *control);
149151

150-
// Control status checks.
152+
// Control status checks:
153+
151154
bool pbio_control_is_active(pbio_control_t *ctl);
152155
bool pbio_control_type_is_position(pbio_control_t *ctl);
153156
bool pbio_control_type_is_time(pbio_control_t *ctl);
154157
bool pbio_control_is_stalled(pbio_control_t *ctl, uint32_t *stall_duration);
155158
bool pbio_control_is_done(pbio_control_t *ctl);
156159
int32_t pbio_control_get_load(pbio_control_t *ctl);
157160

158-
// Start new control command.
161+
// Start new control command:
162+
159163
pbio_error_t pbio_control_start_position_control(pbio_control_t *ctl, uint32_t time_now, pbio_control_state_t *state, int32_t position, int32_t speed, pbio_control_on_completion_t on_completion);
160164
pbio_error_t pbio_control_start_position_control_relative(pbio_control_t *ctl, uint32_t time_now, pbio_control_state_t *state, int32_t distance, int32_t speed, pbio_control_on_completion_t on_completion);
161165
pbio_error_t pbio_control_start_position_control_hold(pbio_control_t *ctl, uint32_t time_now, int32_t position);

lib/pbio/include/pbio/control_settings.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,23 @@ typedef struct _pbio_control_settings_t {
111111
*/
112112
#define pbio_control_time_ticks_to_ms(ticks) ((ticks) / 10)
113113

114-
// Unit conversion functions.
114+
// Unit conversion functions:
115+
115116
int32_t pbio_control_settings_ctl_to_app(pbio_control_settings_t *s, int32_t input);
116117
int32_t pbio_control_settings_ctl_to_app_long(pbio_control_settings_t *s, pbio_angle_t *input);
117118
int32_t pbio_control_settings_app_to_ctl(pbio_control_settings_t *s, int32_t input);
118119
void pbio_control_settings_app_to_ctl_long(pbio_control_settings_t *s, int32_t input, pbio_angle_t *output);
119120
int32_t pbio_control_settings_actuation_ctl_to_app(int32_t input);
120121
int32_t pbio_control_settings_actuation_app_to_ctl(int32_t input);
121122

122-
// Scale values by given constants.
123+
// Scale values by given constants:
124+
123125
int32_t pbio_control_settings_mul_by_loop_time(int32_t input);
124126
int32_t pbio_control_settings_mul_by_gain(int32_t value, int32_t gain);
125127
int32_t pbio_control_settings_div_by_gain(int32_t value, int32_t gain);
126128

127-
// Control settings getters and setters.
129+
// Control settings getters and setters:
130+
128131
void pbio_control_settings_get_limits(pbio_control_settings_t *s, int32_t *speed, int32_t *acceleration, int32_t *deceleration, int32_t *actuation);
129132
pbio_error_t pbio_control_settings_set_limits(pbio_control_settings_t *s, int32_t speed, int32_t acceleration, int32_t deceleration, int32_t actuation);
130133
void pbio_control_settings_get_pid(pbio_control_settings_t *s, int32_t *pid_kp, int32_t *pid_ki, int32_t *pid_kd, int32_t *integral_change_max);

lib/pbio/include/pbio/dcmotor.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,29 @@ typedef struct _pbio_dcmotor_t {
4343

4444
#if PBIO_CONFIG_DCMOTOR
4545

46-
// Global reset
46+
// Global reset:
47+
4748
void pbio_dcmotor_stop_all(bool clear_parents);
4849

49-
// Setup and status
50+
// Setup and status:
51+
5052
pbio_error_t pbio_dcmotor_get_dcmotor(pbio_port_id_t port, pbio_dcmotor_t **dcmotor);
5153
pbio_error_t pbio_dcmotor_setup(pbio_dcmotor_t *dcmotor, pbio_direction_t direction);
5254
void pbio_dcmotor_get_state(pbio_dcmotor_t *dcmotor, pbio_dcmotor_actuation_t *actuation, int32_t *voltage_now);
5355

54-
// Settings
56+
// Settings:
57+
5558
int32_t pbio_dcmotor_get_max_voltage(pbio_iodev_type_id_t id);
5659
pbio_error_t pbio_dcmotor_set_settings(pbio_dcmotor_t *dcmotor, int32_t max_voltage);
5760
void pbio_dcmotor_get_settings(pbio_dcmotor_t *dcmotor, int32_t *max_voltage);
5861

59-
// Actuation for system purposes
62+
// Actuation for system purposes:
63+
6064
pbio_error_t pbio_dcmotor_coast(pbio_dcmotor_t *dcmotor);
6165
pbio_error_t pbio_dcmotor_set_voltage(pbio_dcmotor_t *dcmotor, int32_t voltage);
6266

63-
// Actuation for end users
67+
// Actuation for end users:
68+
6469
pbio_error_t pbio_dcmotor_user_command(pbio_dcmotor_t *dcmotor, bool coast, int32_t voltage);
6570

6671
#else

lib/pbio/include/pbio/drivebase.h

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,43 +24,37 @@ typedef struct _pbio_drivebase_t {
2424

2525
pbio_error_t pbio_drivebase_get_drivebase(pbio_drivebase_t **db_address, pbio_servo_t *left, pbio_servo_t *right, int32_t wheel_diameter, int32_t axle_track);
2626

27+
// Drive base status:
28+
2729
void pbio_drivebase_update_all(void);
2830
bool pbio_drivebase_update_loop_is_running(pbio_drivebase_t *db);
31+
bool pbio_drivebase_is_busy(pbio_drivebase_t *db);
2932

30-
// Finite point to point control
33+
// Finite point to point control:
3134

3235
pbio_error_t pbio_drivebase_drive_straight(pbio_drivebase_t *db, int32_t distance, pbio_control_on_completion_t on_completion);
33-
3436
pbio_error_t pbio_drivebase_drive_curve(pbio_drivebase_t *db, int32_t radius, int32_t angle, pbio_control_on_completion_t on_completion);
3537

36-
// Infinite driving
38+
// Infinite driving:
3739

3840
pbio_error_t pbio_drivebase_drive_forever(pbio_drivebase_t *db, int32_t speed, int32_t turn_rate);
39-
4041
pbio_error_t pbio_drivebase_stop(pbio_drivebase_t *db, pbio_control_on_completion_t on_completion);
4142

42-
bool pbio_drivebase_is_busy(pbio_drivebase_t *db);
4343

44-
// Measuring and settings
44+
// Measuring and settings:
4545

4646
pbio_error_t pbio_drivebase_get_state_user(pbio_drivebase_t *db, int32_t *distance, int32_t *drive_speed, int32_t *angle, int32_t *turn_rate);
47-
4847
pbio_error_t pbio_drivebase_get_drive_settings(pbio_drivebase_t *db, int32_t *drive_speed, int32_t *drive_acceleration, int32_t *drive_deceleration, int32_t *turn_rate, int32_t *turn_acceleration, int32_t *turn_deceleration);
49-
5048
pbio_error_t pbio_drivebase_set_drive_settings(pbio_drivebase_t *db, int32_t drive_speed, int32_t drive_acceleration, int32_t drive_deceleration, int32_t turn_rate, int32_t turn_acceleration, int32_t turn_deceleration);
5149

5250
#if PBIO_CONFIG_DRIVEBASE_SPIKE
5351

54-
// SPIKE drive base wrappers
52+
// SPIKE drive base wrappers:
5553

5654
pbio_error_t pbio_drivebase_get_drivebase_spike(pbio_drivebase_t **db_address, pbio_servo_t *left, pbio_servo_t *right);
57-
5855
pbio_error_t pbio_drivebase_spike_drive_forever(pbio_drivebase_t *db, int32_t speed_left, int32_t speed_right);
59-
6056
pbio_error_t pbio_drivebase_spike_drive_time(pbio_drivebase_t *db, int32_t speed_left, int32_t speed_right, int32_t duration, pbio_control_on_completion_t on_completion);
61-
6257
pbio_error_t pbio_drivebase_spike_drive_angle(pbio_drivebase_t *db, int32_t speed_left, int32_t speed_right, int32_t angle, pbio_control_on_completion_t on_completion);
63-
6458
pbio_error_t pbio_drivebase_spike_steering_to_tank(int32_t speed, int32_t steering, int32_t *speed_left, int32_t *speed_right);
6559

6660
#endif // PBIO_CONFIG_DRIVEBASE_SPIKE

lib/pbio/include/pbio/integrator.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ typedef struct _pbio_speed_integrator_t {
2424
pbio_control_settings_t *settings; // Control settings, which includes integrator settings.
2525
} pbio_speed_integrator_t;
2626

27-
void pbio_speed_integrator_pause(pbio_speed_integrator_t *itg, uint32_t time_now, int32_t position_error);
27+
// Speed integrator functions:
2828

29+
void pbio_speed_integrator_pause(pbio_speed_integrator_t *itg, uint32_t time_now, int32_t position_error);
2930
void pbio_speed_integrator_resume(pbio_speed_integrator_t *itg, int32_t position_error);
30-
3131
void pbio_speed_integrator_reset(pbio_speed_integrator_t *itg, pbio_control_settings_t *settings);
32-
3332
int32_t pbio_speed_integrator_get_error(pbio_speed_integrator_t *itg, int32_t position_error);
34-
3533
bool pbio_speed_integrator_stalled(pbio_speed_integrator_t *itg, uint32_t time_now, int32_t speed_now, int32_t speed_ref);
3634

3735
typedef struct _pbio_position_integrator_t {
@@ -44,16 +42,13 @@ typedef struct _pbio_position_integrator_t {
4442
pbio_control_settings_t *settings; // Control settings, which includes integrator settings.
4543
} pbio_position_integrator_t;
4644

47-
uint32_t pbio_position_integrator_get_ref_time(pbio_position_integrator_t *itg, uint32_t time_now);
45+
// Position integrator functions:
4846

47+
uint32_t pbio_position_integrator_get_ref_time(pbio_position_integrator_t *itg, uint32_t time_now);
4948
void pbio_position_integrator_pause(pbio_position_integrator_t *itg, uint32_t time_now);
50-
5149
void pbio_position_integrator_resume(pbio_position_integrator_t *itg, uint32_t time_now);
52-
5350
void pbio_position_integrator_reset(pbio_position_integrator_t *itg, pbio_control_settings_t *settings, uint32_t time_now);
54-
5551
int32_t pbio_position_integrator_update(pbio_position_integrator_t *itg, int32_t position_error, int32_t position_remaining);
56-
5752
bool pbio_position_integrator_stalled(pbio_position_integrator_t *itg, uint32_t time_now, int32_t speed_now, int32_t speed_ref);
5853

5954
#endif // _PBIO_INTEGRATOR_H_

lib/pbio/include/pbio/math.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,23 @@
1414
#include <stdint.h>
1515
#include <stdbool.h>
1616

17-
bool pbio_math_sign_not_opposite(int32_t a, int32_t b);
18-
int32_t pbio_math_abs(int32_t value);
19-
int32_t pbio_math_atan2(int32_t y, int32_t x);
17+
// Clamping and binding:
18+
2019
int32_t pbio_math_bind(int32_t value, int32_t min, int32_t max);
2120
int32_t pbio_math_clamp(int32_t value, int32_t abs_max);
2221
int32_t pbio_math_max(int32_t a, int32_t b);
2322
int32_t pbio_math_min(int32_t a, int32_t b);
24-
int32_t pbio_math_mult_then_div(int32_t a, int32_t b, int32_t c);
23+
24+
// Signing:
25+
26+
bool pbio_math_sign_not_opposite(int32_t a, int32_t b);
27+
int32_t pbio_math_abs(int32_t value);
2528
int32_t pbio_math_sign(int32_t a);
29+
30+
// Integer re-implementations of selected math functions.
31+
32+
int32_t pbio_math_atan2(int32_t y, int32_t x);
33+
int32_t pbio_math_mult_then_div(int32_t a, int32_t b, int32_t c);
2634
int32_t pbio_math_sqrt(int32_t n);
2735

2836
#endif // _PBIO_MATH_H_

lib/pbio/include/pbio/observer.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,17 @@ typedef struct _pbio_observer_t {
7878
pbio_control_settings_t *settings;
7979
} pbio_observer_t;
8080

81-
void pbio_observer_reset(pbio_observer_t *obs, pbio_control_settings_t *settings, pbio_angle_t *angle);
81+
// Observer state functions:
8282

83+
void pbio_observer_reset(pbio_observer_t *obs, pbio_control_settings_t *settings, pbio_angle_t *angle);
8384
void pbio_observer_get_estimated_state(pbio_observer_t *obs, pbio_angle_t *angle, int32_t *speed);
84-
8585
void pbio_observer_update(pbio_observer_t *obs, uint32_t time, pbio_angle_t *angle, pbio_dcmotor_actuation_t actuation, int32_t voltage);
86-
8786
bool pbio_observer_is_stalled(pbio_observer_t *obs, uint32_t time, uint32_t *stall_duration);
8887

89-
int32_t pbio_observer_get_feedforward_torque(const pbio_observer_model_t *model, int32_t rate_ref, int32_t acceleration_ref);
88+
// Model conversion functions:
9089

90+
int32_t pbio_observer_get_feedforward_torque(const pbio_observer_model_t *model, int32_t rate_ref, int32_t acceleration_ref);
9191
int32_t pbio_observer_torque_to_voltage(const pbio_observer_model_t *model, int32_t desired_torque);
92-
9392
int32_t pbio_observer_voltage_to_torque(const pbio_observer_model_t *model, int32_t voltage);
9493

9594
#endif // _PBIO_OBSERVER_H_

lib/pbio/include/pbio/servo.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,23 @@ typedef struct _pbio_servo_t {
7878
bool run_update_loop;
7979
} pbio_servo_t;
8080

81-
// Servo initialization and updates.
81+
// Servo initialization and updates:
82+
8283
pbio_error_t pbio_servo_get_servo(pbio_port_id_t port, pbio_servo_t **srv);
8384
pbio_error_t pbio_servo_setup(pbio_servo_t *srv, pbio_direction_t direction, int32_t gear_ratio, bool reset_angle);
8485
pbio_error_t pbio_servo_actuate(pbio_servo_t *srv, pbio_dcmotor_actuation_t actuation_type, int32_t payload);
8586
pbio_error_t pbio_servo_load_settings(pbio_control_settings_t *control_settings, const pbio_observer_model_t **model, pbio_iodev_type_id_t id);
8687
void pbio_servo_update_all(void);
8788

88-
// Servo status.
89+
// Servo status:
90+
8991
pbio_error_t pbio_servo_get_state_control(pbio_servo_t *srv, pbio_control_state_t *state);
9092
pbio_error_t pbio_servo_get_state_user(pbio_servo_t *srv, int32_t *angle, int32_t *speed);
9193
bool pbio_servo_update_loop_is_running(pbio_servo_t *srv);
9294
pbio_error_t pbio_servo_is_stalled(pbio_servo_t *srv, bool *stalled, uint32_t *stall_duration);
9395

94-
// Servo end user commands.
96+
// Servo end user commands:
97+
9598
pbio_error_t pbio_servo_stop(pbio_servo_t *srv, pbio_control_on_completion_t on_completion);
9699
pbio_error_t pbio_servo_reset_angle(pbio_servo_t *srv, int32_t reset_angle, bool reset_to_abs);
97100
pbio_error_t pbio_servo_run_forever(pbio_servo_t *srv, int32_t speed);

lib/pbio/include/pbio/trajectory.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,18 @@ typedef struct _pbio_trajectory_t {
7575
int32_t a2; /**< Encoder acceleration during out-phase */
7676
} pbio_trajectory_t;
7777

78-
// Make a new full trajectory from user command, with angle target as endpoint.
79-
pbio_error_t pbio_trajectory_new_angle_command(pbio_trajectory_t *trj, const pbio_trajectory_command_t *command);
78+
// Make or modify trajectories:
8079

81-
// Make a new full trajectory from user command, with time based endpoint.
80+
pbio_error_t pbio_trajectory_new_angle_command(pbio_trajectory_t *trj, const pbio_trajectory_command_t *command);
8281
pbio_error_t pbio_trajectory_new_time_command(pbio_trajectory_t *trj, const pbio_trajectory_command_t *command);
83-
84-
void pbio_trajectory_get_last_vertex(pbio_trajectory_t *trj, uint32_t time_ref, pbio_trajectory_reference_t *ref);
85-
86-
// Make a stationary trajectory for holding position.
8782
void pbio_trajectory_make_constant(pbio_trajectory_t *trj, const pbio_trajectory_command_t *command);
88-
89-
// Stretches out a given trajectory time-wise to make it match time frames of leading trajectory
9083
void pbio_trajectory_stretch(pbio_trajectory_t *trj, pbio_trajectory_t *leader);
9184

92-
uint32_t pbio_trajectory_get_duration(pbio_trajectory_t *trj);
85+
// Reference getter functions:
9386

87+
uint32_t pbio_trajectory_get_duration(pbio_trajectory_t *trj);
9488
void pbio_trajectory_get_endpoint(pbio_trajectory_t *trj, pbio_trajectory_reference_t *end);
95-
89+
void pbio_trajectory_get_last_vertex(pbio_trajectory_t *trj, uint32_t time_ref, pbio_trajectory_reference_t *ref);
9690
void pbio_trajectory_get_reference(pbio_trajectory_t *trj, uint32_t time_ref, pbio_trajectory_reference_t *ref);
9791

9892
#endif // _PBIO_TRAJECTORY_H_

0 commit comments

Comments
 (0)