Skip to content

Commit

Permalink
Implement motor driver input voltage readings
Browse files Browse the repository at this point in the history
  • Loading branch information
Peque committed May 9, 2019
1 parent abcf2d6 commit a0bc630
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
4 changes: 2 additions & 2 deletions scripts/notebooks/show_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
" value = yaml.load(row.data)\n",
" except yaml.error.YAMLError:\n",
" continue\n",
" if len(value) != 10:\n",
" if len(value) != 12:\n",
" print(value)\n",
" continue\n",
" data.append([row.timestamp] + value)\n",
"df = DataFrame(data)\n",
"df.columns = ['timestamp', 'front_left', 'front_right', 'side_left', 'side_right',\n",
" 'linear_ideal', 'linear_measured', 'angular_ideal', 'angular_measured',\n",
" 'pwm_left', 'pwm_right']\n",
" 'voltage_left', 'voltage_right', 'pwm_left', 'pwm_right']\n",
"df['timestamp'] /= 1000\n",
"df = df.set_index('timestamp')\n",
"df = df.sort_index()\n",
Expand Down
20 changes: 10 additions & 10 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
#define SENSOR_FRONT_RIGHT_B 0.258

/** Control constants */
#define KP_LINEAR 800.
#define KD_LINEAR 1600.
#define KP_ANGULAR 5.
#define KD_ANGULAR 100.
#define KP_ANGULAR_FRONT 50.
#define KI_ANGULAR_FRONT 200.
#define KP_ANGULAR_SIDE 200.
#define KI_ANGULAR_SIDE 400.
#define KP_ANGULAR_DIAGONAL 200.
#define KI_ANGULAR_DIAGONAL 400.
#define KP_LINEAR 8.
#define KD_LINEAR 16.
#define KP_ANGULAR .05
#define KD_ANGULAR 1.
#define KP_ANGULAR_FRONT .5
#define KI_ANGULAR_FRONT 2.
#define KP_ANGULAR_SIDE 2.
#define KI_ANGULAR_SIDE 4.
#define KP_ANGULAR_DIAGONAL 2.
#define KI_ANGULAR_DIAGONAL 4.

struct control_constants {
float kp_linear;
Expand Down
2 changes: 1 addition & 1 deletion src/mmlib
Submodule mmlib updated 3 files
+42 −7 control.c
+3 −0 control.h
+16 −6 logging.c
3 changes: 3 additions & 0 deletions src/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#define WALL_WIDTH 0.012
#define MIDDLE_MAZE_DISTANCE ((CELL_DIMENSION - WALL_WIDTH) / 2.)

/** Motor driver input voltage */
#define MOTOR_DRIVER_INPUT_VOLTAGE 9.

/** Mouse dimensions */
#define MOUSE_MOTOR_TAIL 0.037
#define MOUSE_MOTOR_HEAD 0.057
Expand Down
12 changes: 12 additions & 0 deletions src/voltage.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,15 @@ float get_battery_voltage(void)
battery_bits = adc_read_regular(ADC2);
return battery_bits * ADC_LSB * VOLT_DIV_FACTOR;
}

/**
* @brief Function to get motor driver input voltage.
*
* In Bulebule, we assume the motor driver input voltage is constant.
*
*@return The motor driver input voltage in volts.
*/
float get_motor_driver_input_voltage(void)
{
return MOTOR_DRIVER_INPUT_VOLTAGE;
}
1 change: 1 addition & 0 deletions src/voltage.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
#include "setup.h"

float get_battery_voltage(void);
float get_motor_driver_input_voltage(void);

#endif /* __VOLTAGE_H */

0 comments on commit a0bc630

Please sign in to comment.