blob: 8e8de476d516463852fd0b632187c9f22278ceb7 [file] [log] [blame]
Austin Schuh69792662015-02-22 21:39:52 -08001#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
9namespace frc971 {
10namespace actors {
11namespace {
12
13static constexpr double kArmVelocity = 0.40;
14static constexpr double kArmAcceleration = 1.0;
15static constexpr double kElevatorVelocity = 0.5;
16static constexpr double kElevatorAcceleration = 2.2;
17
18} // namespace
19
20LiftActor::LiftActor(LiftActionQueueGroup *queues)
21 : aos::common::actions::ActorBase<LiftActionQueueGroup>(queues) {}
22
23namespace {
24
25void 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
48bool LiftActor::RunAction(const LiftParams &params) {
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 &params) {
58 return ::std::unique_ptr<LiftAction>(
59 new LiftAction(&::frc971::actors::lift_action, params));
60}
61
62} // namespace actors
63} // namespace frc971