M1M3 Support System
Loading...
Searching...
No Matches
PositionController.h
1/*
2 * This file is part of LSST M1M3 support system package.
3 *
4 * Developed for the Vera C. Rubin Telescope and Site System.
5 * This product includes software developed by the LSST Project
6 * (https://www.lsst.org).
7 * See the COPYRIGHT file at the top-level directory of this distribution
8 * for details of code ownership.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef POSITIONCONTROLLER_H_
25#define POSITIONCONTROLLER_H_
26
27#include <SAL_MTM1M3C.h>
28
29#include <HardpointActuatorSettings.h>
30#include <PositionControllerSettings.h>
31#include <SafetyController.h>
32#include <Units.h>
33#include <cRIO/DataTypes.h>
34
35namespace LSST {
36namespace M1M3 {
37namespace SS {
38
39typedef enum { NO_WAIT, CAN_WAIT, WAITING, ALREADY_WAITED } wait_tension_t;
40
62public:
64
70 int getRaiseTimeout() { return _positionControllerSettings->raiseTimeout; }
71 int getLowerTimeout() { return _positionControllerSettings->lowerTimeout; }
72
73 bool enableChaseAll();
74 void disableChaseAll();
75
76 void startRaise();
77 void startLower();
78
88 bool hpRaiseLowerForcesInTolerance(bool raise);
89 bool motionComplete();
90
99 bool moveHardpoint(int32_t steps, int hpIndex);
100
110 bool move(int32_t *steps);
111 bool moveToEncoder(int32_t *encoderValues);
112
125 bool moveToAbsolute(double x, double y, double z, double rX, double rY, double rZ);
126 bool moveToReferencePosition();
127
138 bool moveToLowerPosition();
139
140 bool translate(double x, double y, double z, double rX, double rY, double rZ);
141
148 void stopMotion(int hardpointIndex = -1);
149
177 void updateSteps();
178
182 void checkLimits(int hp);
183
184private:
185 void _convertToSteps(int32_t *steps, double x, double y, double z, double rX, double rY, double rZ);
186
187 void _checkFollowingError(int hp);
188
189 void _resetWaitTension();
190
191 PositionControllerSettings *_positionControllerSettings;
192 HardpointActuatorSettings *_hardpointActuatorSettings;
193
194 MTM1M3_hardpointActuatorDataC *_hardpointActuatorData;
195 MTM1M3_logevent_hardpointActuatorStateC *_hardpointActuatorState;
196 MTM1M3_logevent_hardpointActuatorInfoC *_hardpointInfo;
197
198 int32_t _scaledMaxStepsPerLoop[HP_COUNT];
199 int32_t _targetEncoderValues[HP_COUNT];
200 int32_t _stableEncoderCount[HP_COUNT];
201 int32_t _unstableEncoderCount[HP_COUNT];
202
203 int32_t _lastEncoderCount[HP_COUNT];
204 wait_tension_t _waitTension[HP_COUNT];
205 uint16_t _raisingLoweringInRangeSamples[HP_COUNT];
206
207 SafetyController *_safetyController;
208};
209
210} /* namespace SS */
211} /* namespace M1M3 */
212} /* namespace LSST */
213
214#endif /* POSITIONCONTROLLER_H_ */
Controls M1M3 position.
Definition PositionController.h:61
bool hpRaiseLowerForcesInTolerance(bool raise)
Checks that hardpoint forces are in tolerance for mirror raising and lowering.
Definition PositionController.cpp:114
bool moveToLowerPosition()
Moves mirror to position ideal for lowering.
Definition PositionController.cpp:415
void checkLimits(int hp)
Check the hardpoint doesn't try to move past limits.
Definition PositionController.cpp:548
void stopMotion(int hardpointIndex=-1)
Stops HP motion.
Definition PositionController.cpp:434
bool move(int32_t *steps)
Move HPs by given steps.
Definition PositionController.cpp:291
int getRaiseTimeout()
Returns raise and lower timeout.
Definition PositionController.h:70
bool moveHardpoint(int32_t steps, int hpIndex)
Move single hardpoint specified number of steps.
Definition PositionController.cpp:263
void updateSteps()
Called in any enabled state (raised, parked, ..).
Definition PositionController.cpp:451
bool moveToAbsolute(double x, double y, double z, double rX, double rY, double rZ)
Commands mirror to move to new position.
Definition PositionController.cpp:396