aversive_10-03-12/modules/devices/robot/robot_system/robot_system.c File Reference

#include <string.h>
#include <stdio.h>
#include <aversive/error.h>
#include <aversive.h>
#include <f64.h>
#include "angle_distance.h"
#include "robot_system.h"

Go to the source code of this file.

Functions

void rs_init (struct robot_system *rs)
void rs_set_left_pwm (struct robot_system *rs, void(*left_pwm)(void *, int32_t), void *left_pwm_param)
void rs_set_right_pwm (struct robot_system *rs, void(*right_pwm)(void *, int32_t), void *right_pwm_param)
void rs_set_left_ext_encoder (struct robot_system *rs, int32_t(*left_ext_encoder)(void *), void *left_ext_encoder_param, double gain)
void rs_set_right_ext_encoder (struct robot_system *rs, int32_t(*right_ext_encoder)(void *), void *right_ext_encoder_param, double gain)
void rs_set_angle (void *data, int32_t angle)
void rs_set_distance (void *data, int32_t distance)
int32_t rs_get_angle (void *data)
int32_t rs_get_distance (void *data)
int32_t rs_get_ext_angle (void *data)
int32_t rs_get_ext_distance (void *data)
int32_t rs_get_ext_left (void *data)
int32_t rs_get_ext_right (void *data)
void rs_set_flags (struct robot_system *rs, uint8_t flags)
void rs_update (void *data)


Function Documentation

int32_t rs_get_angle ( void *  data  ) 

get the virtual angle according to real encoders value.

Definition at line 238 of file robot_system.c.

References rs_polar::angle, IRQ_LOCK, IRQ_UNLOCK, and robot_system::virtual_encoders.

Referenced by __trajectory_goto_d_a_rel(), and trajectory_hardstop().

int32_t rs_get_distance ( void *  data  ) 

get the virtual distance according to real encoders value.

Definition at line 253 of file robot_system.c.

References rs_polar::distance, IRQ_LOCK, IRQ_UNLOCK, and robot_system::virtual_encoders.

Referenced by __trajectory_goto_d_a_rel(), and trajectory_hardstop().

int32_t rs_get_ext_angle ( void *  rs  ) 

get the angle according to ext encoders value.

Definition at line 265 of file robot_system.c.

References rs_polar::angle, IRQ_LOCK, IRQ_UNLOCK, and robot_system::pext_prev.

Referenced by position_manage(), and position_use_ext().

int32_t rs_get_ext_distance ( void *  rs  ) 

get the distance according to ext encoders value.

Definition at line 277 of file robot_system.c.

References rs_polar::distance, IRQ_LOCK, IRQ_UNLOCK, and robot_system::pext_prev.

Referenced by position_manage(), and position_use_ext().

int32_t rs_get_ext_left ( void *  data  ) 

Definition at line 315 of file robot_system.c.

References IRQ_LOCK, IRQ_UNLOCK, rs_wheels::left, and robot_system::wext_prev.

int32_t rs_get_ext_right ( void *  data  ) 

Definition at line 327 of file robot_system.c.

References IRQ_LOCK, IRQ_UNLOCK, rs_wheels::right, and robot_system::wext_prev.

void rs_init ( struct robot_system rs  ) 

Set the structure to 0

Definition at line 87 of file robot_system.c.

References IRQ_LOCK, and IRQ_UNLOCK.

void rs_set_angle ( void *  data,
int32_t  angle 
)

set the real pwms according to the specified angle (it also depends on the last distance command sent)

Definition at line 193 of file robot_system.c.

References rs_polar::angle, rs_polar::distance, IRQ_LOCK, IRQ_UNLOCK, rs_wheels::left, robot_system::left_pwm, robot_system::left_pwm_param, rs_wheels::right, robot_system::right_pwm, robot_system::right_pwm_param, rs_get_wheels_from_polar(), and robot_system::virtual_pwm.

void rs_set_distance ( void *  data,
int32_t  distance 
)

set the real pwms according to the specified distance (it also depends on the last angle command sent)

Definition at line 216 of file robot_system.c.

References rs_polar::angle, rs_polar::distance, IRQ_LOCK, IRQ_UNLOCK, rs_wheels::left, robot_system::left_pwm, robot_system::left_pwm_param, rs_wheels::right, robot_system::right_pwm, robot_system::right_pwm_param, rs_get_wheels_from_polar(), and robot_system::virtual_pwm.

void rs_set_flags ( struct robot_system rs,
uint8_t  flags 
)

Definition at line 365 of file robot_system.c.

References robot_system::flags, IRQ_LOCK, and IRQ_UNLOCK.

void rs_set_left_ext_encoder ( struct robot_system rs,
int32_t(*)(void *)  left_ext_encoder,
void *  left_ext_encoder_param,
double  gain 
)

define left external encoder function and param

Definition at line 162 of file robot_system.c.

References f64_from_double(), IRQ_LOCK, IRQ_UNLOCK, robot_system::left_ext_encoder, robot_system::left_ext_encoder_param, and robot_system::left_ext_gain.

void rs_set_left_pwm ( struct robot_system rs,
void(*)(void *, int32_t)  left_pwm,
void *  left_pwm_param 
)

define left PWM function and param

Definition at line 112 of file robot_system.c.

References IRQ_LOCK, IRQ_UNLOCK, robot_system::left_pwm, and robot_system::left_pwm_param.

void rs_set_right_ext_encoder ( struct robot_system rs,
int32_t(*)(void *)  right_ext_encoder,
void *  right_ext_encoder_param,
double  gain 
)

define right external encoder function and param

Definition at line 175 of file robot_system.c.

References f64_from_double(), IRQ_LOCK, IRQ_UNLOCK, robot_system::right_ext_encoder, robot_system::right_ext_encoder_param, and robot_system::right_ext_gain.

void rs_set_right_pwm ( struct robot_system rs,
void(*)(void *, int32_t)  right_pwm,
void *  right_pwm_param 
)

define right PWM function and param

Definition at line 123 of file robot_system.c.

References IRQ_LOCK, IRQ_UNLOCK, robot_system::right_pwm, and robot_system::right_pwm_param.

void rs_update ( void *  data  ) 

Read the encoders, and update internal virtual counters. Call this function is needed before reading the virtual encoders.The program will decide if it the external encoders or the motor encoders are taken in account (depending on flags, but not yet)

Definition at line 380 of file robot_system.c.

References rs_polar::angle, rs_polar::distance, f64_from_lsb(), f64_msb_mul(), robot_system::flags, IRQ_LOCK, IRQ_UNLOCK, rs_wheels::left, robot_system::left_ext_encoder, robot_system::left_ext_encoder_param, robot_system::left_ext_gain, robot_system::pext_prev, rs_wheels::right, robot_system::right_ext_encoder, robot_system::right_ext_encoder_param, robot_system::right_ext_gain, rs_get_polar_from_wheels(), rs_get_wheels_from_polar(), RS_IGNORE_EXT_GAIN, RS_IGNORE_MOT_GAIN, RS_USE_EXT, robot_system::virtual_encoders, and robot_system::wext_prev.


Generated on Fri Mar 12 06:32:06 2010 for AVR by  doxygen 1.5.6