-
Notifications
You must be signed in to change notification settings - Fork 2
/
CollisionRecovery.h
66 lines (51 loc) · 1.92 KB
/
CollisionRecovery.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
This file is part of the PubSubsumption library, an implementation of the Subsumption
Architecture based upon a simple Publisher/Subscriber mechanism.
Copyright (C) 2014 Terry Crook
Written by Terry Crook in collaboration with Clayton Dean, and based upon the
Subsumption Architecture as described by David P. Anderson.
*/
#pragma once
#include <Director.h>
#include <CommandDispatcher.h>
// The CollisionRecovery class implements behaviors which are intended to get the robot
// around obstacles it has crashed into. It detects collisions through two "bumper" inputs (left and right),
// basically switch closures connected to two input pins.
//
// The recovery behavior consists of a sequence of steps, or states:
//
// 1. Stop
// 2. Reverse
// 3. Turn away from the collision side
// 4. Forward
//
// Each state has an associated duration and speed, which can be configured from the console.
class CollisionRecovery : public Behavior
{
enum eRecoveryState {
eNormal,
eStopped,
eReversing,
eTurning,
eForward,
eStates
};
eRecoveryState _eState;
int _nStateTimer;
int _StateTimes[ eStates ];
int _StateSpeeds[ eStates ];
int _leftMotorSpeed;
int _rightMotorSpeed;
bool _bSimBumpLeft;
bool _bSimBumpRight;
// pins connected to bumper switches
uint8_t _leftPin;
uint8_t _rightPin;
public:
CollisionRecovery( CommandDispatcher* pCD, uint8_t leftPin, uint8_t rightPin );
~CollisionRecovery() {}
// virtual Subscriber* HandleEvent( EventNotification* pEvent );
virtual void handleCommandEvent( EventNotification* pEvent, CommandArgs* pArgs );
virtual void handleSubsumptionEvent( EventNotification* pEvent, SubsumptionParams* pSubsumptionParams );
virtual void PrintSpecificParameterValues();
};