- Main Page
- Modules
- Data Structures
- Files
- Directories

# e_motors.c File Reference

Manage the motors (with timer1, 2, 3). More...

`#include "../../e_epuck_ports.h"`
`#include "e_agenda_fast.h"`
`#include <stdlib.h>`

## Defines
#define | POWERSAVE
#define | TRESHV 650
#define | MAXV 601
## Functions
void | run_left_motor (void)
void | run_right_motor (void)
void | e_init_motors (void)
| Initialize the motors's agendas.
void | e_set_speed_left (int motor_speed)
| Manage the left motor speed.
void | e_set_speed_right (int motor_speed)
| Manage the right motor speed.
void | e_set_speed (int linear_speed, int angular_speed)
| Manage linear/angular speed.
int | e_get_steps_left ()
| Give the number of left motor steps.
void | e_set_steps_left (int set_steps)
| Set the number of left motor steps.
int | e_get_steps_right ()
| Give the number of right motor steps.
void | e_set_steps_right (int set_steps)
| Set the number of right motor steps.
## Variables
static int | left_speed = 0
static int | right_speed = 0
static int | left_motor_phase = 0
static int | right_motor_phase = 0
static int | nbr_steps_left = 0
static int | nbr_steps_right = 0

## Detailed Description

Manage the motors (with timer1, 2, 3).

This module manage the motors with the fast agenda solution (timer1, 2, 3).

See also:
  e_agenda.h

Author:
  Code: Francesco Mondada, Lucas Meier
  Doc: Jonathan Besuchet

## Define Documentation

#define MAXV 601

#define POWERSAVE

#define TRESHV 650

## Function Documentation

int e_get_steps_left | ( | void |  | ) |

Give the number of left motor steps.

Returns:
  The number of phases steps made since the left motor is running.

int e_get_steps_right | ( | void |  | ) |

Give the number of right motor steps.

Returns:
  The number of phases steps made since the right motor is running.

void e_init_motors | ( | void |  | ) |

Initialize the motors's agendas.

This function initialize the agendas used by the motors. In fact it call "e_activate_agenda(void (*func)(void), int cycle)" function.

See also:
  e_activate_agenda

void e_set_speed | ( | int | linear_speed,
|  | int | angular_speed |
| ) |  |  |

Manage linear/angular speed.

This function manage the speed of the motors according to the desired linear and angular speed.

Parameters:

  | linear_speed | the speed in the axis of e-puck
  | angular_speed | the rotation speed (trigonometric)

void e_set_speed_left | ( | int | motor_speed | ) |

Manage the left motor speed.

This function manage the left motor speed by changing the MOTOR1 phases. The changing phases frequency (=> speed) is controled by the agenda (throw the function "e_set_agenda_cycle(void (*func)(void), int cycle)").

Parameters:

  | motor_speed | from -1000 to 1000 give the motor speed in steps/s, positive value to go forward and negative to go backward.

See also:
  e_set_agenda_cycle

void e_set_speed_right | ( | int | motor_speed | ) |

Manage the right motor speed.

This function manage the right motor speed by changing the MOTOR2 phases. The changing phases frequency (=> speed) is controled by the agenda (throw the function "e_set_agenda_cycle(void (*func)(void), int cycle)").

Parameters:

  | motor_speed | from -1000 to 1000 give the motor speed in steps/s, positive value to go forward and negative to go backward.

See also:
  e_set_agenda_cycle

void e_set_steps_left | ( | int | set_steps | ) |

Set the number of left motor steps.

Parameters:

  | set_steps | The number of changed phases that you want set.

void e_set_steps_right | ( | int | set_steps | ) |

Set the number of right motor steps.

Parameters:

  | set_steps | The number of changed phases that you want set.

void run_left_motor | ( | void |  | ) |

Change left motor phase according to the left_speed signe.

void run_right_motor | ( | void |  | ) |

Change right motor phase according to the right_speed signe

## Variable Documentation

int left_motor_phase = 0`[static]`

int left_speed = 0`[static]`

int nbr_steps_left = 0`[static]`

int nbr_steps_right = 0`[static]`

int right_motor_phase = 0`[static]`

int right_speed = 0`[static]`