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@3:527f0b949839, 2018-02-08 (annotated)
- Committer:
- MikeGray92
- Date:
- Thu Feb 08 22:55:15 2018 +0000
- Revision:
- 3:527f0b949839
- Parent:
- 2:0537a8007a39
- Child:
- 4:89ebfa37663b
Just addd/removed comments. See last commit notes for changes
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> |
MikeGray92 | 3:527f0b949839 | 7 | #include "mbed.h" |
MikeGray92 | 2:0537a8007a39 | 8 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 9 | // Initializations |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 10 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 11 | void setupGimbal(){ |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 12 | gimbal.servo(YAWID, YAWZERO, 50); // Set the Gimbal at the zero position. |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 13 | control.yaw = YAWZERO; |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 14 | wait(0.1); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 15 | gimbal.servo(PITCHID, PITCHZERO, 50); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 16 | control.pitch = PITCHZERO; |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 17 | wait(0.1); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 18 | gimbal.servo(ROLLID, ROLLZERO, 50); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 19 | control.roll = ROLLZERO; |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 20 | } |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 21 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 22 | void setupLift(){ |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 23 | |
MikeGray92 | 1:1ac7d472cfa2 | 24 | hallInt.attach(&hallInterrupt, 0.05); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 25 | liftSpeed.period_us(50); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 26 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 27 | // Find the bottom position. Go down at lowest speed and set zero point. |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 28 | liftDirection.write(LIFTDOWN); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 29 | liftSpeed.write(0.3); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 30 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 31 | // Wait until the motor stalls, know the motor is at bottom. |
MikeGray92 | 2:0537a8007a39 | 32 | while(!stall){wait(.01);} |
MikeGray92 | 1:1ac7d472cfa2 | 33 | if(stall == true){ |
MikeGray92 | 1:1ac7d472cfa2 | 34 | liftSpeed.write(0); |
MikeGray92 | 1:1ac7d472cfa2 | 35 | currentPosition = 0; |
MikeGray92 | 1:1ac7d472cfa2 | 36 | stall = false; |
MikeGray92 | 1:1ac7d472cfa2 | 37 | } |
MikeGray92 | 2:0537a8007a39 | 38 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 39 | } |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 40 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 41 | void setupROSNode(ros::NodeHandle& nh, ros::Subscriber<std_msgs::Float32MultiArray>& sub){ |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 42 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 43 | nh.getHardware()->setBaud(57600); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 44 | nh.initNode(); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 45 | nh.subscribe(sub); |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 46 | } |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 47 | |
group-UVic-Assistive-Technolog | 0:3a767f41cf04 | 48 |