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
- Committer:
- MikeGray92
- Date:
- 2018-12-14
- Revision:
- 13:8630f38f8066
- Parent:
- 10:836e701d00a6
- Child:
- 15:aeb817f93336
File content as of revision 13:8630f38f8066:
#include <stdint.h> #include "mbed.h" #include <ros.h> #include <std_msgs/Empty.h> #include <std_msgs/Int32MultiArray.h> #include <BNO055.h> #include <initializations.h> #include <definitions.h> #include <prototypes.h> #include <Mx28.h> bool startFlag = 0; void runLift(void){ stallCheck(); //Check If Arrived if (abs(control.height - currentPosition) < 6){ liftSpeed.write(0); stopHallInt(); startFlag = 0; } else { value1.write(1); if(startFlag == 0){ startHallInt(); startFlag = 1; } // Set direction if(control.height > currentPosition){ liftDirection.write(LIFTUP); } else if(control.height < currentPosition){ liftDirection.write(LIFTDOWN); } // liftSpeed.write(liftDutyCycle); liftSpeed.write(0.4); } } //Determining if the lift stalled and stopping if it is void stallCheck(void){ if(stallcount > 3 && liftSpeed.read() > 0 && eStopFlag == 0){ liftSpeed.write(0); if (liftDirection.read() == LIFTUP){ currentPosition = LIFTHEIGHTMAX; control.height = LIFTHEIGHTMAX; }else{ currentPosition = 0; control.height = 0; } } }