Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ros_lib_kinetic
lift.cpp@6:2ffa254e8f6e, 2018-03-06 (annotated)
- Committer:
- MikeGray92
- Date:
- Tue Mar 06 21:44:07 2018 +0000
- Revision:
- 6:2ffa254e8f6e
- Parent:
- 4:89ebfa37663b
- Child:
- 7:950b3c3b5a2b
Added Comments; Changed the order of rosInput values (0 - neg, 1 -nothing, 2 - pos); Changed Roll limits
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 1 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 2 | #include <stdint.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 3 | #include "mbed.h" |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 4 | #include <ros.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 5 | #include <std_msgs/Empty.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 6 | #include <std_msgs/Float32MultiArray.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 7 | #include <BNO055.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 8 | #include <initializations.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 9 | #include <definitions.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 10 | #include <prototypes.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 11 | #include <Mx28.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 12 | |
MikeGray92 | 4:89ebfa37663b | 13 | bool startFlag = 0; |
MikeGray92 | 2:0537a8007a39 | 14 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 15 | void runLift(void){ |
MikeGray92 | 2:0537a8007a39 | 16 | stallCheck(); |
MikeGray92 | 6:2ffa254e8f6e | 17 | //Check If Arrived |
MikeGray92 | 4:89ebfa37663b | 18 | if (abs(control.height - currentPosition) < 5){ |
MikeGray92 | 4:89ebfa37663b | 19 | liftSpeed.write(0); |
MikeGray92 | 4:89ebfa37663b | 20 | stopHallInt(); |
MikeGray92 | 4:89ebfa37663b | 21 | startFlag = 0; |
MikeGray92 | 4:89ebfa37663b | 22 | } |
MikeGray92 | 4:89ebfa37663b | 23 | else { |
MikeGray92 | 4:89ebfa37663b | 24 | if(startFlag == 0){ |
MikeGray92 | 4:89ebfa37663b | 25 | startHallInt(); |
MikeGray92 | 4:89ebfa37663b | 26 | startFlag = 1; |
MikeGray92 | 4:89ebfa37663b | 27 | } |
MikeGray92 | 6:2ffa254e8f6e | 28 | // Set direction |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 29 | if(control.height > currentPosition){ |
MikeGray92 | 4:89ebfa37663b | 30 | liftDirection.write(LIFTUP); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 31 | } |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 32 | else if(control.height < currentPosition){ |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 33 | liftDirection.write(LIFTDOWN); |
MikeGray92 | 4:89ebfa37663b | 34 | } |
MikeGray92 | 4:89ebfa37663b | 35 | liftSpeed.write(0.5); |
MikeGray92 | 4:89ebfa37663b | 36 | } |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 37 | } |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 38 | |
MikeGray92 | 6:2ffa254e8f6e | 39 | //Determining if the lift stalled and stopping if it is |
MikeGray92 | 2:0537a8007a39 | 40 | void stallCheck(void){ |
MikeGray92 | 4:89ebfa37663b | 41 | if(stallcount > 3 && liftSpeed.read() > 0){ |
MikeGray92 | 2:0537a8007a39 | 42 | liftSpeed.write(0); |
MikeGray92 | 2:0537a8007a39 | 43 | if (liftDirection.read() == LIFTUP){ |
MikeGray92 | 2:0537a8007a39 | 44 | currentPosition = LIFTHEIGHTMAX; |
MikeGray92 | 4:89ebfa37663b | 45 | control.height = currentPosition; |
MikeGray92 | 2:0537a8007a39 | 46 | }else{ |
MikeGray92 | 2:0537a8007a39 | 47 | currentPosition = 0; |
MikeGray92 | 4:89ebfa37663b | 48 | control.height = currentPosition; |
MikeGray92 | 2:0537a8007a39 | 49 | } |
MikeGray92 | 2:0537a8007a39 | 50 | } |
MikeGray92 | 2:0537a8007a39 | 51 | } |