Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added the rest of the configuration parameters to the class. More work done on the example GUI, |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | development |
Files: | files | file ages | folders |
SHA3-256: | 347c1be87b2330ee7324c86a4d7290841a922c0b778503da463738f6c149be5c |
User & Date: | gwlester 2018-02-19 23:31:03 |
Context
2018-02-19
| ||
23:31 | Added the rest of the configuration parameters to the class. More work done on the example GUI, Leaf check-in: 347c1be87b user: gwlester tags: development | |
2018-02-10
| ||
21:04 | Starting a new branch that will introduce instabilities. Changes in this checkin intro place holders for the configuration of the accelerometer and magnetometer. The general configuration gui will likely change and even the low level bno055 may have some incompatible changes (the examples will be updated accordingly). check-in: e9e2cb5abf user: gwlester tags: development | |
Changes
Changes to examples/Multisensor_Example.tcl.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 ... 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 ... 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 ... 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
array set Configuration { bus 1 dIMUaddress 0x28 } array set UI { InLoadCurrentConfiguration false operation,map,label { configmode "Configuration Mode" acconly "Accelerometer Only" magonly "Magnetometer Only" gyroonly "Gyroscope Only" accmag "Accelerometer and Magnetometer Only" accgyro "Accelerometer and Gyroscope Only" ................................................................................ ## ## Accelerometer group ## ttk::label $accel.rangeLbl \ -text {Range:} ttk::combobox $accel.rangeCMB \ -textvariable ::Configuration(accelrange) \ -values [list 250dps 500dps 2000dps] \ -state readonly lappend UI(configurationWidgets) $accel.rangeCMB ttk::label $accel.numDigitsLbl \ -text {Digits before decimal} ttk::combobox $accel.numDigitsCMB \ -textvariable ::AccelValues(digits) \ -values [list 3 4] \ ................................................................................ } proc CreateMagConfigFrame {mag} { ## ## Magnetometer group ## ttk::label $mag.rangeLbl \ -text {Range:} ttk::combobox $mag.rangeCMB \ -textvariable ::Configuration(magrange) \ -values [list 250dps 500dps 2000dps] \ -state readonly lappend UI(configurationWidgets) $mag.rangeCMB ttk::label $mag.numDigitsLbl \ -text {Digits before decimal} ttk::combobox $mag.numDigitsCMB \ -textvariable ::MagValues(digits) \ -values [list 3 4] \ ................................................................................ -textvariable ::MagValues(minChange) ttk::label $mag.minChangeLbl2 \ -text {dps change} trace add variable ::MagValues(digits) write ChangeFormat trace add variable ::MagValues(decimals) write ChangeFormat # Add Self Test status # Add Calibration status # Add Unit Select # Add offsets # Add radius # Add Mag Power Mode # Add Mag Operation Mode # Add Mag Data Output Rate grid configure $mag.rangeLbl $mag.rangeCMB x x -padx 2 -pady 2 -sticky ew grid configure $mag.numDigitsLbl $mag.numDigitsCMB x x -padx 2 -pady 2 -sticky ew grid configure $mag.numDecimalsLbl $mag.numDecimalsCMB x x -padx 2 -pady 2 -sticky ew grid configure $mag.minChangeLbl1 $mag.minChangeEnt $mag.minChangeLbl2 x -padx 2 -pady 2 -sticky ew grid columnconfigure $mag 3 -weight 1 $mag.minChangeEnt set $::MagValues(minChange) |
> > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | < | |
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 ... 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 ... 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 ... 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 |
array set Configuration { bus 1 dIMUaddress 0x28 } array set UI { InLoadCurrentConfiguration false sysCalStatus,map,label { {calib_stat_not calibrated} "Not Calibrated" {calib_stat_in progress} "In progress" {calib_stat_calibration complete} "Calibration Complete" } sysStatus,map,label { {sys_status_system idle} "System Idle" {sys_status_system error} "System Error" {sys_status_initializing peripherals} "Initializing peripherals" {sys_status_system initialization} "System Initialization" {sys_status_executing selftest} "Executing selftest" {sys_status_sensor fusion algorithm running} "Sensor fusion algorithm running" {sys_status_system running without fusion algorithm} "System running without fusion algorithm" } sysError,map,label { {sys_error_no error} "No error" {sys_error_peripheral initialization error} "Peripheral initialization error" {sys_error_system initialization error} "System initialization error" {sys_error_self test result failed} "Self test result failed" {sys_error_register map value out of range} "Register map value out of range" {sys_error_register map address out of range} "Register map address out of range" {sys_error_register map write error} "Register map write error" {sys_error_register map write error} "Register map write error" {sys_error_bno low power mode not available for selected operation mode} "BNO low power mode not available for selected operation mode" {sys_error_accelerometer power mode not available} "Accelerometer power mode not available" {sys_error_fusion algorithm configuration error} "Fusion algorithm configuration error" {sys_error_sensor configuration error} "Sensor configuration error" } operation,map,label { configmode "Configuration Mode" acconly "Accelerometer Only" magonly "Magnetometer Only" gyroonly "Gyroscope Only" accmag "Accelerometer and Magnetometer Only" accgyro "Accelerometer and Gyroscope Only" ................................................................................ ## ## Accelerometer group ## ttk::label $accel.rangeLbl \ -text {Range:} ttk::combobox $accel.rangeCMB \ -textvariable ::Configuration(accelrange) \ -values [list 2g 4g 8g 16g] \ -state readonly lappend UI(configurationWidgets) $accel.rangeCMB ttk::label $accel.numDigitsLbl \ -text {Digits before decimal} ttk::combobox $accel.numDigitsCMB \ -textvariable ::AccelValues(digits) \ -values [list 3 4] \ ................................................................................ } proc CreateMagConfigFrame {mag} { ## ## Magnetometer group ## ttk::label $mag.rateLbl \ -text {Rate:} ttk::combobox $mag.rateCMB \ -textvariable ::Configuration(magrate) \ -values [list 2hz 6hz 8hz 10hz 15hz 20hz 25hz] \ -state readonly lappend UI(configurationWidgets) $mag.rangeCMB ttk::label $mag.numDigitsLbl \ -text {Digits before decimal} ttk::combobox $mag.numDigitsCMB \ -textvariable ::MagValues(digits) \ -values [list 3 4] \ ................................................................................ -textvariable ::MagValues(minChange) ttk::label $mag.minChangeLbl2 \ -text {dps change} trace add variable ::MagValues(digits) write ChangeFormat trace add variable ::MagValues(decimals) write ChangeFormat # Add Self Test status # Add Calibration status # Add offsets # Add radius # Add Mag Power Mode # Add Mag Operation Mode # Add Mag Data Output Rate grid configure $mag.rateLbl $mag.rateCMB x x -padx 2 -pady 2 -sticky ew grid configure $mag.numDigitsLbl $mag.numDigitsCMB x x -padx 2 -pady 2 -sticky ew grid configure $mag.numDecimalsLbl $mag.numDecimalsCMB x x -padx 2 -pady 2 -sticky ew grid configure $mag.minChangeLbl1 $mag.minChangeEnt $mag.minChangeLbl2 x -padx 2 -pady 2 -sticky ew grid columnconfigure $mag 3 -weight 1 $mag.minChangeEnt set $::MagValues(minChange) |
Changes to src/bno055/bno055.tcl.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 ... 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 ... 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
SymDef ACC_BANDWIDTH 15.63HZ 0b001 SymDef ACC_BANDWIDTH 31.25HZ 0b010 SymDef ACC_BANDWIDTH 62.5HZ 0b011 SymDef ACC_BANDWIDTH 125HZ 0b100 SymDef ACC_BANDWIDTH 250HZ 0b101 SymDef ACC_BANDWIDTH 500HZ 0b110 SymDef ACC_BANDWIDTH 1000HZ 0b111 SymDef ACC_OPER_MODE NORMAL 0b000 SymDef ACC_OPER_MODE SUSPEND 0b001 SymDef ACC_OPER_MODE LOW_POWER_1 0b010 SymDef ACC_OPER_MODE STANDBY 0b011 SymDef ACC_OPER_MODE LOW_POWER_2 0b100 SymDef ACC_OPER_MODE DEEP_SUSPEND 0b101 SymDef MAG_DATA_RATE 2Hz 0b000 SymDef MAG_DATA_RATE 6Hz 0b001 SymDef MAG_DATA_RATE 8Hz 0b010 SymDef MAG_DATA_RATE 10Hz 0b011 SymDef MAG_DATA_RATE 15Hz 0b100 SymDef MAG_DATA_RATE 20Hz 0b101 SymDef MAG_DATA_RATE 25Hz 0b110 ................................................................................ set size [expr {1 + ($highBit - $lowBit)}] set tmp [format "%${size}.${size}b" $value] set writeValue [string replace $writeValue end-$highBit end-$lowBit $tmp] } scan $writeValue {%b} writeValue ::twowire writeregbyte $handle [lindex $Registers(page) 1] $page after 10 switch -exact -- $size { 1 { ::twowire writeregbyte $handle $addr $writeValue } 2 { ::twowire writeregword $handle $addr $writeValue ................................................................................ set returnValues {} foreach register $registerList { lassign $Registers($register) page addr type mask if {![dict exists $registerValues page $page addr $addr]} { ::twowire writeregbyte $handle [lindex $Registers(page) 1] $page after 10 switch -exact -- $type { B - b { set result [::twowire readregbyte $handle $addr] set size 8 } W - |
| | | | | | | | |
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 ... 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 ... 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
SymDef ACC_BANDWIDTH 15.63HZ 0b001 SymDef ACC_BANDWIDTH 31.25HZ 0b010 SymDef ACC_BANDWIDTH 62.5HZ 0b011 SymDef ACC_BANDWIDTH 125HZ 0b100 SymDef ACC_BANDWIDTH 250HZ 0b101 SymDef ACC_BANDWIDTH 500HZ 0b110 SymDef ACC_BANDWIDTH 1000HZ 0b111 SymDef ACC_POWER_MODE NORMAL 0b000 SymDef ACC_POWER_MODE SUSPEND 0b001 SymDef ACC_POWER_MODE LOW_POWER_1 0b010 SymDef ACC_POWER_MODE STANDBY 0b011 SymDef ACC_POWER_MODE LOW_POWER_2 0b100 SymDef ACC_POWER_MODE DEEP_SUSPEND 0b101 SymDef MAG_DATA_RATE 2Hz 0b000 SymDef MAG_DATA_RATE 6Hz 0b001 SymDef MAG_DATA_RATE 8Hz 0b010 SymDef MAG_DATA_RATE 10Hz 0b011 SymDef MAG_DATA_RATE 15Hz 0b100 SymDef MAG_DATA_RATE 20Hz 0b101 SymDef MAG_DATA_RATE 25Hz 0b110 ................................................................................ set size [expr {1 + ($highBit - $lowBit)}] set tmp [format "%${size}.${size}b" $value] set writeValue [string replace $writeValue end-$highBit end-$lowBit $tmp] } scan $writeValue {%b} writeValue ::twowire writeregbyte $handle [lindex $Registers(page) 1] $page after 20 switch -exact -- $size { 1 { ::twowire writeregbyte $handle $addr $writeValue } 2 { ::twowire writeregword $handle $addr $writeValue ................................................................................ set returnValues {} foreach register $registerList { lassign $Registers($register) page addr type mask if {![dict exists $registerValues page $page addr $addr]} { ::twowire writeregbyte $handle [lindex $Registers(page) 1] $page after 20 switch -exact -- $type { B - b { set result [::twowire readregbyte $handle $addr] set size 8 } W - |
Changes to src/dimu/dimu.tcl.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 ... 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 ... 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 ... 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
self method init {} { variable HardwiredSettings variable ConfigurationRegisters variable OptionDef variable ReadOnly set OptionDef { -accelunits {-register acc,units -allowed {mps2 mg} -type ACC_UNIT} -accelrange {-register acc,range -allowed {2000dps 1000dps 500dps 250dps 125dps} -type ACC_RANGE} -accelbandwidth {-register acc,bandwidth -allowed {523hz 230hz 116hz 64hz 47hz 32hz 23hz 12hz} -type ACC_BANDWIDTH} -accelpowermode {-register acc,pwrMode -allowed {normal fast_up deep_suspend suspend advanced_powersave} -type ACC_POWER_MODE} -accelautosleep {-register acc,autoSlpDur -allowed {4MS 5MS 8MS 10MS 15MS 20MS 40MS} -type ACC_AUTOSLP_DURR} -accelsleep {-register acc,sleepDur -allowed {4MS 5MS 8MS 10MS 15MS 18MS 20MS} -type ACC_SLEEP_DURR} -accelawake {-register acc,am,durr -allowed {8samples 16samples 32samples 64samples} -type ACC_AWAKE_DURR} -accelslope {-register acc,am,slope} -accelxoffset {-register acc,x,offset} -accelyoffset {-register acc,y,offset} -accelzoffset {-register acc,z,offset} -accelradius {-register acc,radius} -bus {-default 1} -clocksource {-register clockSource -type CLOCK_SOURCE} -eulunits {-register eul,units -allowed {deg rad} -type EUL_UNIT} -fusionunits {-register format,opt -allowed {windows android} -type ORI_MODE} -gyrorange {-register gyr,range -allowed {2000dps 1000dps 500dps 250dps 125dps} -type GYR_RANGE} -gyrobandwidth {-register gyr,bandwidth -allowed {523hz 230hz 116hz 64hz 47hz 32hz 23hz 12hz} -type GYR_BANDWIDTH} -gyropowermode {-register gyr,pwrMode -allowed {normal fast_up deep_suspend suspend advanced_powersave} -type GYR_POWER_MODE} -gyrounits {-register gyr,units -allowed {dps rps} -type GYR_UNIT} -gyroautosleep {-register gyr,autoSlpDur -allowed {4MS 5MS 8MS 10MS 15MS 20MS 40MS} -type GYR_AUTOSLP_DURR} -gyrosleep {-register gyr,sleepDur -allowed {4MS 5MS 8MS 10MS 15MS 18MS 20MS} -type GYR_SLEEP_DURR} -gyroawake {-register gyr,am,durr -allowed {8samples 16samples 32samples 64samples} -type GYR_AWAKE_DURR} -gyroslope {-register gyr,am,slope} -gyroxoffset {-register gyr,x,offset} -gyroyoffset {-register gyr,y,offset} -gyrozoffset {-register gyr,z,offset} -magrange {-register mag,range -allowed {2000dps 1000dps 500dps 250dps 125dps} -type MAG_RANGE} -magbandwidth {-register mag,bandwidth -allowed {523hz 230hz 116hz 64hz 47hz 32hz 23hz 12hz} -type MAG_BANDWIDTH} -magpowermode {-register mag,pwrMode -allowed {normal fast_up deep_suspend suspend advanced_powersave} -type MAG_POWER_MODE} -magautosleep {-register mag,autoSlpDur -allowed {4MS 5MS 8MS 10MS 15MS 20MS 40MS} -type MAG_AUTOSLP_DURR} -magsleep {-register mag,sleepDur -allowed {4MS 5MS 8MS 10MS 15MS 18MS 20MS} -type MAG_SLEEP_DURR} -magawake {-register mag,am,durr -allowed {8samples 16samples 32samples 64samples} -type MAG_AWAKE_DURR} -magslope {-register mag,am,slope} -magxoffset {-register mag,x,offset} -magyoffset {-register mag,y,offset} -magzoffset {-register mag,z,offset} -magradius {-register mag,radius} -operation {-register operMode -immediate yes -allowed {configmode acconly magonly gyroonly accmag accgyro maggyro amg imu compass m4g ndof_fmc_off ndof} -type OPER_MODE} -power {-register powerMode -allowed {normal low suspend} -type PWR_MODE} -remap_x_axis {-register remap,x,value -type REMAP_TO} -remap_y_axis {-register remap,y,value -type REMAP_TO} -remap_z_axis {-register remap,z,value -type REMAP_TO} -remap_x_sign {-register remap,x,sign -type REMAP_SIGN} -remap_y_sign {-register remap,y,sign -type REMAP_SIGN} -remap_z_sign {-register remap,z,sign -type REMAP_SIGN} -temperaturesource {-register tempSource -type TEMP_SRC} -temperatureunits {-register temp,units -allowed {f c} -type TEMP_UNIT} } set ReadOnly { -uniqueID {-register uniqueId} -softwareRev {-register sw,rev -format "0x%1$x"} ................................................................................ } return; } method readAccelerometer {} { } method readMagnetometer {} { } method readEulerAngles {} { } method readGravity{} { } method readGyro {} { variable instanceInfo variable currentConfiguration set operMode [bno055 getShortSymbol OPER_MODE [dict get $currentConfiguration operMode]] if {$operMode in {CONFIGMODE ACCONLY MAGONLY ACCMAG}} { throw [list DIMU SENDIS $operMode] "Gyroscope reading are not availble when dIMU is in '$operMode' mode." } set results {} set readings [bno055 readMultipleRegisters [dict get $instanceInfo handle] {gyr,data,x gyr,data,y gyr,data,z}] set range [bno055 getSymbol GYR_RANGE [dict get $currentConfiguration gyr,range]] switch -exact -- $range { GYR_RANGE_125DPS { ................................................................................ } else { dict set results units rps set divisor [expr {$divsor * 900 / 16}] } dict set results x [expr {[dict get $readings gyr,data,x] / $divisor}] dict set results y [expr {[dict get $readings gyr,data,y] / $divisor}] dict set results z [expr {[dict get $readings gyr,data,z] / $divisor}] } method read LinearAccelration{} { } method readTemperature {} { variable instanceInfo variable currentConfiguration set results {} ................................................................................ dict set results units C set divisor 1.0 } else { dict set results units V set divisor 2.0 } dict set results temperature [expr {$readings / $divisor}] } method readQuaternion {} { variable instanceInfo variable currentConfiguration set operMode [bno055 getShortSymbol OPER_MODE [dict get $currentConfiguration operMode]] if {$operMode ni {IMU COMPASS M4G NDOF_FMC_OFF NDOF}} { throw [list DIMU SENDIS $operMode] "Quaternion reading are not availble when dIMU is in '$operMode' mode." } set results {} set readings [bno055 readMultipleRegisters [dict get $instanceInfo handle] {qua,data,w qua,data,x qua,data,y qua,data,z}] dict set results w [expr {[dict get $readings qua,data,w] / (2.0 ** 14)}] dict set results x [expr {[dict get $readings qua,data,x] / (2.0 ** 14)}] dict set results y [expr {[dict get $readings qua,data,y] / (2.0 ** 14)}] |
| | | | | | < < | | | | | | | | | | | | | | | | | | | < < > > | < < < < | | | | | | | | | | | | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > | > > > > > > > > > > > > > > | > > > | > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > | | > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | |
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 ... 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 ... 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 ... 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
self method init {} { variable HardwiredSettings variable ConfigurationRegisters variable OptionDef variable ReadOnly set OptionDef { -accelunits {-register acc,units -allowed {mps2 mg} -type ACC_UNIT} -accelrange {-register acc,range -allowed {2g 4g 8g 16g} -type ACC_RANGE} -accelbandwidth {-register acc,bandwidth -allowed {7.81hz 15.63hz 31.25hz 62.5hz 125hz 250hz 500hz 1000hz} -type ACC_BANDWIDTH} -accelpowermode {-register acc,pwrMode -allowed {normal suspend low_power_1 standby low_power_2 deep_suspend} -type ACC_POWER_MODE} -accelsleepmode {-register acc,sleepDur -allowed {event equidistant} -type ACC_SLEEP_DURR} -accelsleepdurr {-register acc,sleepDur -allowed {0.5ms 0.5ms 0.5ms 0.5ms 0.5ms 0.5ms 1ms 2ms 4ms 6ms 10ms 25ms 50ms 100ms 500ms 1000ms} -type ACC_SLEEP_DURR} -accelxoffset {-register acc,x,offset} -accelyoffset {-register acc,y,offset} -accelzoffset {-register acc,z,offset} -accelradius {-register acc,radius} -bus {-default 1} -clocksource {-register clockSource -type CLOCK_SOURCE} -eulunits {-register eul,units -allowed {deg rad} -type EUL_UNIT} -fusionunits {-register format,opt -allowed {windows android} -type ORI_MODE} -gyrorange {-register gyr,range -allowed {2000dps 1000dps 500dps 250dps 125dps} -type GYR_RANGE} -gyrobandwidth {-register gyr,bandwidth -allowed {523hz 230hz 116hz 64hz 47hz 32hz 23hz 12hz} -type GYR_BANDWIDTH} -gyropowermode {-register gyr,pwrMode -allowed {normal fast_up deep_suspend suspend advanced_powersave} -type GYR_POWER_MODE} -gyrounits {-register gyr,units -allowed {dps rps} -type GYR_UNIT} -gyroautosleep {-register gyr,autoSlpDur -allowed {4MS 5MS 8MS 10MS 15MS 20MS 40MS} -type GYR_AUTOSLP_DURR} -gyrosleep {-register gyr,sleepDur -allowed {4MS 5MS 8MS 10MS 15MS 18MS 20MS} -type GYR_SLEEP_DURR} -gyroawake {-register gyr,am,durr -allowed {8samples 16samples 32samples 64samples} -type GYR_AWAKE_DURR} -gyroslope {-register gyr,am,slope} -gyroxoffset {-register gyr,x,offset} -gyroyoffset {-register gyr,y,offset} -gyrozoffset {-register gyr,z,offset} -magrate {-register mag,rate -allowed {2hz 6hz 8hz 10hz 15hz 20hz 25hz} -type MAG_DATA_RATE} -magopermode {-register mag,operMode -allowed {low regular enhanced high} -type MAG_OPER_MODE} -magpowermode {-register mag,pwrMode -allowed {normal sleep suspend force} -type MAG_POWER_MODE} -magxoffset {-register mag,x,offset} -magyoffset {-register mag,y,offset} -magzoffset {-register mag,z,offset} -magradius {-register mag,radius} -operation {-register operMode -immediate yes -allowed {configmode acconly magonly gyroonly accmag accgyro maggyro amg imu compass m4g ndof_fmc_off ndof} -type OPER_MODE} -power {-register powerMode -allowed {normal low suspend} -type PWR_MODE} -remap_x_axis {-register remap,x,value -type REMAP_TO} -remap_y_axis {-register remap,y,value -type REMAP_TO} -remap_z_axis {-register remap,z,value -type REMAP_TO} -remap_x_sign {-register remap,x,sign -type REMAP_SIGN} -remap_y_sign {-register remap,y,sign -type REMAP_SIGN} -remap_z_sign {-register remap,z,sign -type REMAP_SIGN} -temperaturesource {-register tempSource -type TEMP_SRC} -temperatureunits {-register temp,units -allowed {f c} -type TEMP_UNIT} } set ReadOnly { -uniqueID {-register uniqueId} -softwareRev {-register sw,rev -format "0x%1$x"} ................................................................................ } return; } method readAccelerometer {} { variable instanceInfo variable currentConfiguration set operMode [bno055 getShortSymbol OPER_MODE [dict get $currentConfiguration operMode]] if {$operMode in {CONFIGMODE MAGONLY GYROONLY MAGGYRO}} { throw [list DIMU SENDIS $operMode] "Accelerometer readings are not availble when dIMU is in '$operMode' mode." } set results {} set readings [bno055 readMultipleRegisters [dict get $instanceInfo handle] {acc,data,x acc,data,y acc,data,z}] set range [bno055 getSymbol ACC_RANGE [dict get $currentConfiguration acc,range]] switch -exact -- $range { ACC_RANGE_2G { set divisor 16.0 } ACC_RANGE_4G { set divisor 8.0 } ACC_RANGE_8G { set divisor 4.0 } ACC_RANGE_16G { set divisor 2.0 } } set units [bno055 getSymbol ACC_UNIT [dict get $currentConfiguration acc,units]] if {$units eq "ACC_UNIT_mg" } { dict set results units mg } else { dict set results units mps2 set divisor [expr {$divsor * 100}] } dict set results x [expr {[dict get $readings acc,data,x] / $divisor}] dict set results y [expr {[dict get $readings acc,data,y] / $divisor}] dict set results z [expr {[dict get $readings acc,data,z] / $divisor}] return $results } method readMagnetometer {} { variable instanceInfo variable currentConfiguration set operMode [bno055 getShortSymbol OPER_MODE [dict get $currentConfiguration operMode]] if {$operMode in {CONFIGMODE ACCONLY GYROONLY ACCGYRO}} { throw [list DIMU SENDIS $operMode] "Magnetometer readings are not availble when dIMU is in '$operMode' mode." } set results {} dict set results units "μT" set divisor 16.0 set readings [bno055 readMultipleRegisters [dict get $instanceInfo handle] {mag,data,x mag,data,y mag,data,z}] dict set results x [expr {[dict get $readings mag,data,x] / $divisor}] dict set results y [expr {[dict get $readings mag,data,y] / $divisor}] dict set results z [expr {[dict get $readings mag,data,z] / $divisor}] return $results } method readEulerAngles {} { variable instanceInfo variable currentConfiguration set operMode [bno055 getShortSymbol OPER_MODE [dict get $currentConfiguration operMode]] if {$operMode ni {IMU COMPASS M4G NDOF_FMC_OFF NDOF}} { throw [list DIMU SENDIS $operMode] "Euler Angles readings are not availble when dIMU is in '$operMode' mode." } set results {} set units [bno055 getSymbol EUL_UNIT [dict get $currentConfiguration eul,units]] if {$units in {DEG deg}} { dict set results units DEG set divisor 16.0 } else { dict set results units RAD set divisor 900.0 } set readings [bno055 readMultipleRegisters [dict get $instanceInfo handle] {heading roll pitch}] dict set results heading [expr {[dict get $readings heading] / $divisor}] dict set results roll [expr {[dict get $readings roll] / $divisor}] dict set results pitch [expr {[dict get $readings pitch] / $divisor}] return $results } method readGravity {} { variable instanceInfo variable currentConfiguration set operMode [bno055 getShortSymbol OPER_MODE [dict get $currentConfiguration operMode]] if {$operMode ni {IMU COMPASS M4G NDOF_FMC_OFF NDOF}} { throw [list DIMU SENDIS $operMode] "Gravity Vector readings are not availble when dIMU is in '$operMode' mode." } set results {} set units [bno055 getSymbol ACC_UNIT [dict get $currentConfiguration acc,units]] if {$units in {MG mg}} { dict set results units MG set divisor 1.0 } else { dict set results units MPS2 set divisor 100.0 } set readings [bno055 readMultipleRegisters [dict get $instanceInfo handle] {grv,data,x grv,data,y grv,data,z}] dict set results x [expr {[dict get $readings grv,data,x] / $divisor}] dict set results y [expr {[dict get $readings grv,data,y] / $divisor}] dict set results z [expr {[dict get $readings grv,data,z] / $divisor}] return $results } method readGyro {} { variable instanceInfo variable currentConfiguration set operMode [bno055 getShortSymbol OPER_MODE [dict get $currentConfiguration operMode]] if {$operMode in {CONFIGMODE ACCONLY MAGONLY ACCMAG}} { throw [list DIMU SENDIS $operMode] "Gyroscope readings are not availble when dIMU is in '$operMode' mode." } set results {} set readings [bno055 readMultipleRegisters [dict get $instanceInfo handle] {gyr,data,x gyr,data,y gyr,data,z}] set range [bno055 getSymbol GYR_RANGE [dict get $currentConfiguration gyr,range]] switch -exact -- $range { GYR_RANGE_125DPS { ................................................................................ } else { dict set results units rps set divisor [expr {$divsor * 900 / 16}] } dict set results x [expr {[dict get $readings gyr,data,x] / $divisor}] dict set results y [expr {[dict get $readings gyr,data,y] / $divisor}] dict set results z [expr {[dict get $readings gyr,data,z] / $divisor}] return $results } method readLinearAccelration {} { variable instanceInfo variable currentConfiguration set operMode [bno055 getShortSymbol OPER_MODE [dict get $currentConfiguration operMode]] if {$operMode ni {IMU COMPASS M4G NDOF_FMC_OFF NDOF}} { throw [list DIMU SENDIS $operMode] "Linear Acceleration readings are not availble when dIMU is in '$operMode' mode." } set results {} set range [bno055 getSymbol ACC_RANGE [dict get $currentConfiguration acc,range]] switch -exact -- $range { ACC_RANGE_2G { set divisor 16.0 } ACC_RANGE_4G { set divisor 8.0 } ACC_RANGE_8G { set divisor 4.0 } ACC_RANGE_16G { set divisor 2.0 } } set units [bno055 getSymbol ACC_UNIT [dict get $currentConfiguration acc,units]] if {$units eq "ACC_UNIT_mg" } { dict set results units mg } else { dict set results units mps2 set divisor [expr {$divsor * 100}] } set readings [bno055 readMultipleRegisters [dict get $instanceInfo handle] {lia,data,x lia,data,y lia,data,z}] dict set results x [expr {[dict get $readings lia,data,x] / $divisor}] dict set results y [expr {[dict get $readings lia,data,y] / $divisor}] dict set results z [expr {[dict get $readings lia,data,z] / $divisor}] return $results } method readTemperature {} { variable instanceInfo variable currentConfiguration set results {} ................................................................................ dict set results units C set divisor 1.0 } else { dict set results units V set divisor 2.0 } dict set results temperature [expr {$readings / $divisor}] return $results } method readQuaternion {} { variable instanceInfo variable currentConfiguration set operMode [bno055 getShortSymbol OPER_MODE [dict get $currentConfiguration operMode]] if {$operMode ni {IMU COMPASS M4G NDOF_FMC_OFF NDOF}} { throw [list DIMU SENDIS $operMode] "Quaternion readings are not availble when dIMU is in '$operMode' mode." } set results {} set readings [bno055 readMultipleRegisters [dict get $instanceInfo handle] {qua,data,w qua,data,x qua,data,y qua,data,z}] dict set results w [expr {[dict get $readings qua,data,w] / (2.0 ** 14)}] dict set results x [expr {[dict get $readings qua,data,x] / (2.0 ** 14)}] dict set results y [expr {[dict get $readings qua,data,y] / (2.0 ** 14)}] |