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
initializations.cpp@2:0537a8007a39, 2018-02-08 (annotated)
- Committer:
- MikeGray92
- Date:
- Thu Feb 08 22:23:40 2018 +0000
- Revision:
- 2:0537a8007a39
- Parent:
- 1:1ac7d472cfa2
- Child:
- 3:527f0b949839
Code ready to be tested with ROS. ; -Tested external interrupt positioning for the lift; -remove unnecessary flags and functions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 1 | #include <std_msgs/Empty.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 2 | #include <std_msgs/Float32MultiArray.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 3 | #include <initializations.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 4 | #include <ros.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 5 | #include <definitions.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 6 | #include <prototypes.h> |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 7 | #include "mbed.h" |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 8 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 9 | #define BNO055_ID (0xA0) |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 10 | |
MikeGray92 | 2:0537a8007a39 | 11 | //Serial pc(USBTX, USBRX); |
MikeGray92 | 2:0537a8007a39 | 12 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 13 | // Initializations |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 14 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 15 | void setupGimbal(){ |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 16 | gimbal.servo(YAWID, YAWZERO, 50); // Set the Gimbal at the zero position. |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 17 | control.yaw = YAWZERO; |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 18 | wait(0.1); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 19 | gimbal.servo(PITCHID, PITCHZERO, 50); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 20 | control.pitch = PITCHZERO; |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 21 | wait(0.1); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 22 | gimbal.servo(ROLLID, ROLLZERO, 50); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 23 | control.roll = ROLLZERO; |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 24 | } |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 25 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 26 | void setupLift(){ |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 27 | |
MikeGray92 | 1:1ac7d472cfa2 | 28 | hallInt.attach(&hallInterrupt, 0.05); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 29 | liftSpeed.period_us(50); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 30 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 31 | // Find the bottom position. Go down at lowest speed and set zero point. |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 32 | liftDirection.write(LIFTDOWN); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 33 | liftSpeed.write(0.3); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 34 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 35 | // Wait until the motor stalls, know the motor is at bottom. |
MikeGray92 | 2:0537a8007a39 | 36 | while(!stall){wait(.01);} |
MikeGray92 | 1:1ac7d472cfa2 | 37 | if(stall == true){ |
MikeGray92 | 1:1ac7d472cfa2 | 38 | liftSpeed.write(0); |
MikeGray92 | 1:1ac7d472cfa2 | 39 | currentPosition = 0; |
MikeGray92 | 1:1ac7d472cfa2 | 40 | stall = false; |
MikeGray92 | 1:1ac7d472cfa2 | 41 | } |
MikeGray92 | 2:0537a8007a39 | 42 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 43 | } |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 44 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 45 | void setupROSNode(ros::NodeHandle& nh, ros::Subscriber<std_msgs::Float32MultiArray>& sub){ |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 46 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 47 | nh.getHardware()->setBaud(57600); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 48 | nh.initNode(); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 49 | nh.subscribe(sub); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 50 | } |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 51 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 52 |