LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
motorGroup.hpp
Go to the documentation of this file.
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
6#pragma once
7
11#include <initializer_list>
12#include <vector>
13
14namespace okapi {
15class MotorGroup : public AbstractMotor {
16 public:
25 MotorGroup(const std::initializer_list<Motor> &imotors,
26 const std::shared_ptr<Logger> &ilogger = Logger::getDefaultLogger());
27
36 MotorGroup(const std::initializer_list<std::shared_ptr<AbstractMotor>> &imotors,
37 const std::shared_ptr<Logger> &ilogger = Logger::getDefaultLogger());
38
39 /******************************************************************************/
43 /******************************************************************************/
44
58 std::int32_t moveAbsolute(double iposition, std::int32_t ivelocity) override;
59
74 std::int32_t moveRelative(double iposition, std::int32_t ivelocity) override;
75
89 std::int32_t moveVelocity(std::int16_t ivelocity) override;
90
97 std::int32_t moveVoltage(std::int16_t ivoltage) override;
98
107 std::int32_t modifyProfiledVelocity(std::int32_t ivelocity) override;
108
109 /******************************************************************************/
113 /******************************************************************************/
114
121 double getTargetPosition() override;
122
129 double getPosition() override;
130
136 std::int32_t tarePosition() override;
137
144 std::int32_t getTargetVelocity() override;
145
152 double getActualVelocity() override;
153
159 std::int32_t getCurrentDraw() override;
160
167 std::int32_t getDirection() override;
168
179 double getEfficiency() override;
180
187 std::int32_t isOverCurrent() override;
188
195 std::int32_t isOverTemp() override;
196
206 std::int32_t isStopped() override;
207
217 std::int32_t getZeroPositionFlag() override;
218
226 uint32_t getFaults() override;
227
235 uint32_t getFlags() override;
236
244 std::int32_t getRawPosition(std::uint32_t *timestamp) override;
245
251 double getPower() override;
252
259 double getTemperature() override;
260
266 double getTorque() override;
267
273 std::int32_t getVoltage() override;
274
275 /******************************************************************************/
279 /******************************************************************************/
280
290 std::int32_t setBrakeMode(AbstractMotor::brakeMode imode) override;
291
299
309 std::int32_t setCurrentLimit(std::int32_t ilimit) override;
310
316 std::int32_t getCurrentLimit() override;
317
324 std::int32_t setEncoderUnits(AbstractMotor::encoderUnits iunits) override;
325
333
340 std::int32_t setGearing(AbstractMotor::gearset igearset) override;
341
348 gearset getGearing() override;
349
357 std::int32_t setReversed(bool ireverse) override;
358
365 std::int32_t setVoltageLimit(std::int32_t ilimit) override;
366
373 void controllerSet(double ivalue) override;
374
380 size_t getSize();
381
387 std::shared_ptr<ContinuousRotarySensor> getEncoder() override;
388
395 virtual std::shared_ptr<ContinuousRotarySensor> getEncoder(std::size_t index);
396
397 protected:
398 std::vector<std::shared_ptr<AbstractMotor>> motors;
399};
400} // namespace okapi
brakeMode
Indicates the 'brake mode' of a motor.
gearset
Indicates the internal gear ratio of a motor.
encoderUnits
Indicates the units used by the motor encoders.
static std::shared_ptr< Logger > getDefaultLogger()
std::vector< std::shared_ptr< AbstractMotor > > motors
virtual std::shared_ptr< ContinuousRotarySensor > getEncoder(std::size_t index)
Get the encoder associated with this motor.
double getEfficiency() override
Gets the efficiency of the motor in percent.
std::int32_t setVoltageLimit(std::int32_t ilimit) override
Sets the voltage limit for the motor in Volts.
uint32_t getFaults() override
Gets the faults experienced by the motor.
std::int32_t setBrakeMode(AbstractMotor::brakeMode imode) override
Motor configuration functions
gearset getGearing() override
Gets the gearset that was set for the motor.
encoderUnits getEncoderUnits() override
Gets the encoder units that were set for the motor.
std::int32_t getVoltage() override
Gets the voltage delivered to the motor in millivolts.
MotorGroup(const std::initializer_list< std::shared_ptr< AbstractMotor > > &imotors, const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
A group of V5 motors which act as one motor (i.e.
size_t getSize()
Gets the number of motors in the motor group.
std::int32_t moveRelative(double iposition, std::int32_t ivelocity) override
Sets the relative target position for the motor to move to.
std::int32_t isStopped() override
Checks if the motor is stopped.
std::int32_t getDirection() override
Gets the direction of movement for the motor.
std::int32_t setReversed(bool ireverse) override
Sets the reverse flag for the motor.
std::int32_t setGearing(AbstractMotor::gearset igearset) override
Sets one of AbstractMotor::gearset for the motor.
double getTorque() override
Gets the torque generated by the motor in Newton Metres (Nm).
std::int32_t tarePosition() override
Sets the "absolute" zero position of the motor to its current position.
uint32_t getFlags() override
Gets the flags set by the motor's operation.
double getActualVelocity() override
Gets the actual velocity of the motor.
std::int32_t getCurrentDraw() override
Gets the current drawn by the motor in mA.
std::int32_t isOverTemp() override
Checks if the motor's temperature is above its limit.
std::int32_t modifyProfiledVelocity(std::int32_t ivelocity) override
Changes the output velocity for a profiled movement (moveAbsolute or moveRelative).
double getPower() override
Gets the power drawn by the motor in Watts.
MotorGroup(const std::initializer_list< Motor > &imotors, const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
A group of V5 motors which act as one motor (i.e.
double getPosition() override
Gets the absolute position of the motor in its encoder units.
std::int32_t setCurrentLimit(std::int32_t ilimit) override
Sets the current limit for the motor in mA.
std::int32_t getTargetVelocity() override
Gets the velocity commanded to the motor by the user.
std::shared_ptr< ContinuousRotarySensor > getEncoder() override
Get the encoder associated with the first motor in this group.
std::int32_t getZeroPositionFlag() override
Checks if the motor is at its zero position.
void controllerSet(double ivalue) override
Writes the value of the controller output.
std::int32_t moveVelocity(std::int16_t ivelocity) override
Sets the velocity for the motor.
std::int32_t isOverCurrent() override
Checks if the motor is drawing over its current limit.
std::int32_t getRawPosition(std::uint32_t *timestamp) override
Gets the raw encoder count of the motor at a given timestamp.
double getTemperature() override
Gets the temperature of the motor in degrees Celsius.
std::int32_t moveVoltage(std::int16_t ivoltage) override
Sets the voltage for the motor from -12000 to 12000.
std::int32_t setEncoderUnits(AbstractMotor::encoderUnits iunits) override
Sets one of AbstractMotor::encoderUnits for the motor encoder.
double getTargetPosition() override
Motor telemetry functions
brakeMode getBrakeMode() override
Gets the brake mode that was set for the motor.
std::int32_t getCurrentLimit() override
Gets the current limit for the motor in mA.
std::int32_t moveAbsolute(double iposition, std::int32_t ivelocity) override
Motor movement functions