officinerobotiche / uNAV.X

Project MPLABX for drive uNAV on dsPIC33
http://rnext.it/project/unav/
MIT License
9 stars 2 forks source link

Remove reference left and right motor in code #27

Closed rbonghi closed 9 years ago

rbonghi commented 9 years ago

Now it is the time to remove reference in the code about motors. I would like to change name left in motor[0] and right in motor[1]. Second step, I would like to unify similar function in a single function (example PID function, PID initialization)

rbonghi commented 9 years ago

Follow information on https://github.com/officinerobotiche/uNAV.X/pull/32 when this issue is solved https://github.com/officinerobotiche/uNAV.X/issues/34

rbonghi commented 9 years ago

An Idea to solve problem is to set type name on packet for a specific motor: Now we have:

//Name for HASHMAP with information about motion messages
#define HASHMAP_MOTION 'M'
#define HASHMAP_MOTION_NUMBER 20

and

#define PID_CONTROL_L 0
#define PID_CONTROL_R 1
#define MOTOR_L 2
#define MOTOR_R 3
#define PARAMETER_MOTOR_L 6
#define PARAMETER_MOTOR_R 7
#define VEL_MOTOR_L 13
#define VEL_MOTOR_R 14
#define VEL_MOTOR_MIS_L 15
#define VEL_MOTOR_MIS_R 16
#define ENABLE_MOTOR_L 17
#define ENABLE_MOTOR_R 18

If we collect all reference for "hash map" we have a new definition:

//Name for HASHMAP with information about motion messages
#define HASHMAP_MOTOR_L 0
#define HASHMAP_MOTOR_R 1
#define HASHMAP_MOTION_NUMBER 10

#define PID_CONTROL 0
#define MOTOR 1
#define PARAMETER_MOTOR 2
#define VEL_MOTOR 3
#define VEL_MOTOR_MIS 4
#define ENABLE_MOTOR 5

Now if we send a message with reference:

createDataPacket(PID_CONTROL, HASHMAP_MOTOR_L, &send);

We have collect all information in a single message without redundant information :smile:

rbonghi commented 9 years ago

@katodo add measure ADC for temperature sensor

rbonghi commented 9 years ago

Added new message for temperature 946441d16b39298b4ee3565cc16c71526bcde83c