Austin Schuh | 6979266 | 2015-02-22 21:39:52 -0800 | [diff] [blame] | 1 | #include <math.h> |
| 2 | |
| 3 | #include "aos/common/time.h" |
| 4 | #include "frc971/actors/lift_actor.h" |
| 5 | #include "frc971/actors/fridge_profile_actor.h" |
| 6 | #include "frc971/constants.h" |
| 7 | #include "frc971/control_loops/claw/claw.q.h" |
| 8 | |
| 9 | namespace frc971 { |
| 10 | namespace actors { |
| 11 | namespace { |
| 12 | |
| 13 | static constexpr double kArmVelocity = 0.40; |
| 14 | static constexpr double kArmAcceleration = 1.0; |
| 15 | static constexpr double kElevatorVelocity = 0.5; |
| 16 | static constexpr double kElevatorAcceleration = 2.2; |
| 17 | |
| 18 | } // namespace |
| 19 | |
| 20 | LiftActor::LiftActor(LiftActionQueueGroup *queues) |
| 21 | : aos::common::actions::ActorBase<LiftActionQueueGroup>(queues) {} |
| 22 | |
| 23 | namespace { |
| 24 | |
| 25 | void DoProfile(double height, double angle, bool grabbers) { |
| 26 | FridgeProfileParams params; |
| 27 | |
| 28 | params.elevator_height = height; |
| 29 | params.elevator_max_velocity = kElevatorVelocity; |
| 30 | params.elevator_max_acceleration = kElevatorAcceleration; |
| 31 | |
| 32 | params.arm_angle = angle; |
| 33 | params.arm_max_velocity = kArmVelocity; |
| 34 | params.arm_max_acceleration = kArmAcceleration; |
| 35 | |
| 36 | params.top_front_grabber = grabbers; |
| 37 | params.top_back_grabber = grabbers; |
| 38 | params.bottom_front_grabber = grabbers; |
| 39 | params.bottom_back_grabber = grabbers; |
| 40 | |
| 41 | ::std::unique_ptr<FridgeAction> profile = MakeFridgeProfileAction(params); |
| 42 | profile->Start(); |
| 43 | profile->WaitUntilDone(); |
| 44 | } |
| 45 | |
| 46 | } // namespace |
| 47 | |
| 48 | bool LiftActor::RunAction(const LiftParams ¶ms) { |
| 49 | // Lift the box straight up. |
| 50 | DoProfile(params.lift_height, 0.0, true); |
| 51 | // Move it back to the storage location. |
| 52 | DoProfile(params.lift_height, params.lift_arm, true); |
| 53 | |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | ::std::unique_ptr<LiftAction> MakeLiftAction(const LiftParams ¶ms) { |
| 58 | return ::std::unique_ptr<LiftAction>( |
| 59 | new LiftAction(&::frc971::actors::lift_action, params)); |
| 60 | } |
| 61 | |
| 62 | } // namespace actors |
| 63 | } // namespace frc971 |