Difference between revisions of "Pf calb table py"
From DIDEAS Wiki
m |
m |
||
(21 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | {{pf_top_nav}} | |
− | |||
− | + | =files to modify= | |
+ | *add eeprom address to eeprom_memmap.h | ||
+ | **could be else where, but helps us to keep track of what is being used where | ||
+ | *add macros to pyshared.c that list the global ram address, and or EEPROM address and virtual variable name | ||
+ | *to global.c, declare the global | ||
+ | *to global.h, define the global typedef | ||
+ | **latter two (global) files are optional, but help keep everything in one place | ||
+ | =example= | ||
+ | ==eeprom_memmap.h== | ||
+ | <pre> | ||
+ | #define PERSISTENT_DATA_C1_EEPROM_BASE_ADDRESS 0x1500 | ||
+ | #define PERSISTENT_DATA_C2_EEPROM_BASE_ADDRESS 0x1580 | ||
+ | </pre> | ||
− | == | + | ==pyshared.c== |
+ | <pre> | ||
+ | ... | ||
+ | const SHARED_OBJECT_T SHARED_OBJECT[] = { | ||
+ | ... | ||
+ | SHARED_RAM_OBJ_M(PERSISTENT_DATA_T, persistent_data_c1), // use commas at EOL | ||
+ | SHARED_RAM_OBJ_M(PERSISTENT_DATA_T, persistent_data_c2), | ||
+ | SHARED_EE_OBJ_M (PERSISTENT_DATA_T, EE_persistent_data_c1, PERSISTENT_DATA_C1_EEPROM_BASE_ADDRESS), | ||
+ | SHARED_EE_OBJ_M (PERSISTENT_DATA_T, EE_persistent_data_c2, PERSISTENT_DATA_C2_EEPROM_BASE_ADDRESS), | ||
+ | ... | ||
+ | } ; | ||
+ | </pre> | ||
+ | ==global.h== | ||
<pre> | <pre> | ||
− | + | typedef struct { | |
− | + | // preamble that should appear at the start of all shared objects - use the same field names | |
+ | UINT32_T pytable_crc; // this is the standard header, use CRC8 for now. | ||
+ | UINT16_T pytable_version; | ||
+ | UINT16_T pytable_length; | ||
+ | UINT32_T pytable_magic; // "hash" for this typedef from the file pygen_shared_object_hash_codes.h | ||
+ | |||
+ | ////////////////// | ||
+ | // use table data to follow. only use 'primitive' C types | ||
+ | UINT32_T count; | ||
+ | } PERSISTENT_DATA_T; | ||
− | + | extern PERSISTENT_DATA_T persistent_data_c1; | |
− | + | extern PERSISTENT_DATA_T persistent_data_c2; | |
− | + | </pre> | |
− | |||
− | |||
− | |||
− | + | ==global.c== | |
+ | <pre> | ||
+ | PERSISTENT_DATA_T persistent_data_c1; | ||
+ | PERSISTENT_DATA_T persistent_data_c2; | ||
− | + | void init_global(void) { | |
− | + | ... | |
− | + | ZERO_OBJ(persistent_data_c1); | |
− | + | ZERO_OBJ(persistent_data_c2); | |
− | + | ... | |
− | + | } | |
− | |||
− | |||
</pre> | </pre> | ||
− | == | + | =how to load / save= |
+ | A general purpose solution does not yet exist. However common_files/eeprom_table.c and the following are an example: | ||
+ | |||
<pre> | <pre> | ||
− | + | ERRCODE_T persistent_load() { | |
− | + | ERRCODE_T ecode; | |
− | + | MEMORY_ADDRESS_T mem; | |
− | + | PERSISTENT_DATA_T local_stack_obj; | |
− | + | UINT16_T table_size = sizeof( PERSISTENT_DATA_T); | |
− | + | ||
+ | mem.type = MEMORY_TYPE_TO_USE_FOR_TABLE_STORAGE; | ||
+ | mem.address = PERSISTENT_DATA_C1_EEPROM_BASE_ADDRESS; | ||
+ | |||
+ | // copy EEPROM table into local storage until it is validated | ||
+ | ecode = eeprom_table_read( (TABLE_HEADER_T *)&local_stack_obj, table_size, &mem, PERSISTENT_DATA_T_HASH); | ||
+ | |||
+ | // PERSISTENT_DATA_T_HASH comes from pygen_shared_object_hash_codes.h and is 32 bits of the MD5 HASH of the typedef source code. | ||
+ | |||
+ | if (ecode) return ecode; // invalid table | ||
+ | |||
+ | // if there were no errors and thus the table is valid, then copy into the walking_param state structure | ||
+ | ecode = memcpy((UINT8_T *)&persistent_data_c1, (UINT8_T *)&local_stack_obj, table_size); | ||
+ | |||
+ | return ecode; | ||
+ | } | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | =access= | ||
+ | *Use "robo_config.py" to read / write these tables. | ||
+ | *robo_config.py -p <serial port> -l | ||
+ | *will list all the tables in the robot | ||
+ | |||
+ | |||
+ | =imu calibration table docs= | ||
+ | TBC | ||
+ | |||
+ | |||
+ | Example KVF with calibration data: | ||
+ | |||
+ | <pre> | ||
+ | [EE_imu_model_calibrationTable] | ||
+ | |||
+ | serial_number = 33 | ||
+ | |||
+ | accXgain = 4.839633e-003 | ||
+ | accYgain = 4.630313e-003 | ||
+ | accZgain = 4.735434e-003 | ||
+ | |||
+ | accXoffset = -1.684186e+002 | ||
+ | accYoffset = 5.055467e+002 | ||
+ | accZoffset = -5.931334e+002 | ||
+ | |||
+ | gyroXgain = 7.628163e-004 | ||
+ | gyroYgain = 7.753409e-004 | ||
+ | gyroZgain = 6.809857e-004 | ||
+ | |||
+ | gyroXoffset = -1.153796e+003 | ||
+ | gyroYoffset = -1.272726e+003 | ||
+ | gyroZoffset = -4.543681e+002 | ||
+ | |||
+ | USMacc4acc[9] = 9.999594e-001 -1.322563e-002 5.033391e-003 8.940409e-003 9.986601e-001 4.106794e-002 1.119896e-003 -5.003061e-002 9.991437e-001 | ||
− | + | USMacc4gyro[9] = 0 0 0 0 0 0 0 0 0 | |
− | + | USMgyro4acc[9] = 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 | |
− | |||
− | |||
− | + | USMgyro4gyro[9] = 9.993670e-001 -2.109546e-002 2.492205e-002 -1.123791e-002 9.991589e-001 1.420475e-002 3.375426e-002 3.516471e-002 9.995885e-001 | |
− | |||
− | |||
</pre> | </pre> |
Latest revision as of 04:09, 17 December 2010
PF Users Navigation:
- PCB; Lifefix_users; Pf_users; benchtest_users; CalibFix Users; Hardware; Assembly ; iochan ;
- PCA : PCB ; AKENC SC/MC 218 ; FET 217 ; IMU219 ; Swifi ; Rev200_mods ; PCA Inventory
- Special Commands to the Ankle (PFCMD) : State Controller Commands; Motor Controller Commands; Python Examples; IMU Commands ;PFCMD_PY; Pf_calb_table_py; Virtual spring test; PF EEPROM
- DOC: Pf_users; Powerfoot Keyboard User Interface; Steps for Manual Tuning; "Dashboard" Program For Assisting with Tuning
- NEW (CEB) WIKI
- Torque Feedback Controller Guide
Contents
files to modify
- add eeprom address to eeprom_memmap.h
- could be else where, but helps us to keep track of what is being used where
- add macros to pyshared.c that list the global ram address, and or EEPROM address and virtual variable name
- to global.c, declare the global
- to global.h, define the global typedef
- latter two (global) files are optional, but help keep everything in one place
example
eeprom_memmap.h
#define PERSISTENT_DATA_C1_EEPROM_BASE_ADDRESS 0x1500 #define PERSISTENT_DATA_C2_EEPROM_BASE_ADDRESS 0x1580
... const SHARED_OBJECT_T SHARED_OBJECT[] = { ... SHARED_RAM_OBJ_M(PERSISTENT_DATA_T, persistent_data_c1), // use commas at EOL SHARED_RAM_OBJ_M(PERSISTENT_DATA_T, persistent_data_c2), SHARED_EE_OBJ_M (PERSISTENT_DATA_T, EE_persistent_data_c1, PERSISTENT_DATA_C1_EEPROM_BASE_ADDRESS), SHARED_EE_OBJ_M (PERSISTENT_DATA_T, EE_persistent_data_c2, PERSISTENT_DATA_C2_EEPROM_BASE_ADDRESS), ... } ;
global.h
typedef struct { // preamble that should appear at the start of all shared objects - use the same field names UINT32_T pytable_crc; // this is the standard header, use CRC8 for now. UINT16_T pytable_version; UINT16_T pytable_length; UINT32_T pytable_magic; // "hash" for this typedef from the file pygen_shared_object_hash_codes.h ////////////////// // use table data to follow. only use 'primitive' C types UINT32_T count; } PERSISTENT_DATA_T; extern PERSISTENT_DATA_T persistent_data_c1; extern PERSISTENT_DATA_T persistent_data_c2;
global.c
PERSISTENT_DATA_T persistent_data_c1; PERSISTENT_DATA_T persistent_data_c2; void init_global(void) { ... ZERO_OBJ(persistent_data_c1); ZERO_OBJ(persistent_data_c2); ... }
how to load / save
A general purpose solution does not yet exist. However common_files/eeprom_table.c and the following are an example:
ERRCODE_T persistent_load() { ERRCODE_T ecode; MEMORY_ADDRESS_T mem; PERSISTENT_DATA_T local_stack_obj; UINT16_T table_size = sizeof( PERSISTENT_DATA_T); mem.type = MEMORY_TYPE_TO_USE_FOR_TABLE_STORAGE; mem.address = PERSISTENT_DATA_C1_EEPROM_BASE_ADDRESS; // copy EEPROM table into local storage until it is validated ecode = eeprom_table_read( (TABLE_HEADER_T *)&local_stack_obj, table_size, &mem, PERSISTENT_DATA_T_HASH); // PERSISTENT_DATA_T_HASH comes from pygen_shared_object_hash_codes.h and is 32 bits of the MD5 HASH of the typedef source code. if (ecode) return ecode; // invalid table // if there were no errors and thus the table is valid, then copy into the walking_param state structure ecode = memcpy((UINT8_T *)&persistent_data_c1, (UINT8_T *)&local_stack_obj, table_size); return ecode; }
access
- Use "robo_config.py" to read / write these tables.
- robo_config.py -p <serial port> -l
- will list all the tables in the robot
imu calibration table docs
TBC
Example KVF with calibration data:
[EE_imu_model_calibrationTable] serial_number = 33 accXgain = 4.839633e-003 accYgain = 4.630313e-003 accZgain = 4.735434e-003 accXoffset = -1.684186e+002 accYoffset = 5.055467e+002 accZoffset = -5.931334e+002 gyroXgain = 7.628163e-004 gyroYgain = 7.753409e-004 gyroZgain = 6.809857e-004 gyroXoffset = -1.153796e+003 gyroYoffset = -1.272726e+003 gyroZoffset = -4.543681e+002 USMacc4acc[9] = 9.999594e-001 -1.322563e-002 5.033391e-003 8.940409e-003 9.986601e-001 4.106794e-002 1.119896e-003 -5.003061e-002 9.991437e-001 USMacc4gyro[9] = 0 0 0 0 0 0 0 0 0 USMgyro4acc[9] = 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 0.000000e+000 USMgyro4gyro[9] = 9.993670e-001 -2.109546e-002 2.492205e-002 -1.123791e-002 9.991589e-001 1.420475e-002 3.375426e-002 3.516471e-002 9.995885e-001