#include <DifferentialSetter.h>
Public Member Functions | |
DifferentialSetter (Setter *targetA, Setter *targetB) | |
void | setTargets (Setter *targetA, Setter *targetB) |
virtual void | input (int value) |
virtual void | inputB (int value) |
virtual void | failsafe () |
Protected Member Functions | |
void | doOutput () |
Internal function that computes the two output vlaues based on themost recent input values. |
A Differential is used to drive 2 motors in forward and reverse directions in response to the inputs from 2 joysticks.
It requires 2 HBridges as output: one to drive the left motor forward/reverse and one to drive the right motor forward/reverse.
It also requires 2 inputs, one for the fore-aft and one for the left-right. The 2 outputs drive 2 reversible motors that act like the motors on a tank or bulldozer, allowing forward, reverse and turning under the control of an x-Y joystick.
In general, the fore/aft input (inputA) is replicated on the 2 outputs, but if inputB varies either side of 127, outputA is increased/decreased and outputB in decreased/increased. The outputs are never permitted outside the range 0 - 255.
The standard input (inputA) to this Setter controls the forward/reverse. The left/right controls come through an instance of the DifferentialLRSetter class.
Typically the outputs would be two HBridgeSetter instances to control a pair of motors but could be ServoSetter, AccelStepperSpeedSetter or AccelStepperPositionSetter or any other combination.
Set or change the output pin
[in] | targetA | The Setter to use for output A. |
[in] | targetB | The Setter to use for output B. |
References Setter::setTarget().
void DifferentialSetter::input | ( | int | value | ) | [virtual] |
Input the value to be used to set the 2 output Setters.
[in] | value | The fore/aft value. |
Reimplemented from Setter.
References doOutput().
void DifferentialSetter::inputB | ( | int | value | ) | [virtual] |
This is the B input, controlling left-right differential. It has to come from an instance of DifferentialLRSetter.
[in] | value | The input value to set. |
References doOutput().
void DifferentialSetter::failsafe | ( | ) | [virtual] |
Called when the source of input data is lost, and the Setter is required to fail in a safe way. Calls the failsafes of targetA and targetB
Reimplemented from Setter.
References Setter::failsafe().