/** * Constructor for RobotDrive with 4 motors specified with channel numbers. * Set up parameters for a four wheel drive system where all four motor * pwm channels are specified in the call. * This call assumes Talons for controlling the motors. * @param frontLeftMotor Front left motor channel number. 0-9 are on-board, * 10-19 are on the MXP port * @param rearLeftMotor Rear Left motor channel number. 0-9 are on-board, 10-19 * are on the MXP port * @param frontRightMotor Front right motor channel number. 0-9 are on-board, * 10-19 are on the MXP port * @param rearRightMotor Rear Right motor channel number. 0-9 are on-board, * 10-19 are on the MXP port */ RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor, uint32_t frontRightMotor, uint32_t rearRightMotor) { InitRobotDrive(); m_rearLeftMotor = std::make_shared<Talon>(rearLeftMotor); m_rearRightMotor = std::make_shared<Talon>(rearRightMotor); m_frontLeftMotor = std::make_shared<Talon>(frontLeftMotor); m_frontRightMotor = std::make_shared<Talon>(frontRightMotor); SetLeftRightMotorOutputs(0.0, 0.0); }
RobotDrive::RobotDrive(SpeedController &frontLeftMotor, SpeedController &rearLeftMotor, SpeedController &frontRightMotor, SpeedController &rearRightMotor) { InitRobotDrive(); m_frontLeftMotor = make_shared_nodelete(&frontLeftMotor); m_rearLeftMotor = make_shared_nodelete(&rearLeftMotor); m_frontRightMotor = make_shared_nodelete(&frontRightMotor); m_rearRightMotor = make_shared_nodelete(&rearRightMotor); }
RobotDrive::RobotDrive(SpeedController &leftMotor, SpeedController &rightMotor) { InitRobotDrive(); m_rearLeftMotor = &leftMotor; m_rearRightMotor = &rightMotor; for (int32_t i=0; i < kMaxNumberOfMotors; i++) { m_invertedMotors[i] = 1; } m_deleteSpeedControllers = false; }
/** * Constructor for RobotDrive with 2 motors specified as SpeedController * objects. * The SpeedController version of the constructor enables programs to use the * RobotDrive classes with * subclasses of the SpeedController objects, for example, versions with ramping * or reshaping of * the curve to suit motor bias or deadband elimination. * @param leftMotor The left SpeedController object used to drive the robot. * @param rightMotor the right SpeedController object used to drive the robot. */ RobotDrive::RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor) { InitRobotDrive(); if (leftMotor == nullptr || rightMotor == nullptr) { wpi_setWPIError(NullParameter); m_rearLeftMotor = m_rearRightMotor = nullptr; return; } m_rearLeftMotor = make_shared_nodelete(leftMotor); m_rearRightMotor = make_shared_nodelete(rightMotor); }
RobotDrive::RobotDrive(std::shared_ptr<SpeedController> leftMotor, std::shared_ptr<SpeedController> rightMotor) { InitRobotDrive(); if (leftMotor == nullptr || rightMotor == nullptr) { wpi_setWPIError(NullParameter); m_rearLeftMotor = m_rearRightMotor = nullptr; return; } m_rearLeftMotor = leftMotor; m_rearRightMotor = rightMotor; }
/** Constructor for RobotDrive with 2 motors specified with channel numbers. * Set up parameters for a two wheel drive system where the * left and right motor pwm channels are specified in the call. * This call assumes Jaguars for controlling the motors. * @param leftMotorChannel The PWM channel number on the default digital module that drives the left motor. * @param rightMotorChannel The PWM channel number on the default digital module that drives the right motor. */ RobotDrive::RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel) { InitRobotDrive(); m_rearLeftMotor = new Jaguar(leftMotorChannel); m_rearRightMotor = new Jaguar(rightMotorChannel); for (int32_t i=0; i < kMaxNumberOfMotors; i++) { m_invertedMotors[i] = 1; } SetLeftRightMotorOutputs(0.0, 0.0); m_deleteSpeedControllers = true; }
/** * Constructor for RobotDrive with 4 motors specified with channel numbers. * Set up parameters for a four wheel drive system where all four motor * pwm channels are specified in the call. * This call assumes Jaguars for controlling the motors. * @param frontLeftMotor Front left motor channel number on the default digital module * @param rearLeftMotor Rear Left motor channel number on the default digital module * @param frontRightMotor Front right motor channel number on the default digital module * @param rearRightMotor Rear Right motor channel number on the default digital module */ RobotDrive::RobotDrive(UINT32 frontLeftMotor, UINT32 rearLeftMotor, UINT32 frontRightMotor, UINT32 rearRightMotor) { InitRobotDrive(); m_rearLeftMotor = new Jaguar(rearLeftMotor); m_rearRightMotor = new Jaguar(rearRightMotor); m_frontLeftMotor = new Jaguar(frontLeftMotor); m_frontRightMotor = new Jaguar(frontRightMotor); for (INT32 i=0; i < kMaxNumberOfMotors; i++) { m_invertedMotors[i] = 1; } SetLeftRightMotorOutputs(0.0, 0.0); m_deleteSpeedControllers = true; }
RobotDrive::RobotDrive(std::shared_ptr<SpeedController> frontLeftMotor, std::shared_ptr<SpeedController> rearLeftMotor, std::shared_ptr<SpeedController> frontRightMotor, std::shared_ptr<SpeedController> rearRightMotor) { InitRobotDrive(); if (frontLeftMotor == nullptr || rearLeftMotor == nullptr || frontRightMotor == nullptr || rearRightMotor == nullptr) { wpi_setWPIError(NullParameter); return; } m_frontLeftMotor = frontLeftMotor; m_rearLeftMotor = rearLeftMotor; m_frontRightMotor = frontRightMotor; m_rearRightMotor = rearRightMotor; }
/** * Constructor for RobotDrive with 2 motors specified as SpeedController objects. * The SpeedController version of the constructor enables programs to use the RobotDrive classes with * subclasses of the SpeedController objects, for example, versions with ramping or reshaping of * the curve to suit motor bias or deadband elimination. * @param leftMotor The left SpeedController object used to drive the robot. * @param rightMotor the right SpeedController object used to drive the robot. */ RobotDrive::RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor) { InitRobotDrive(); if (leftMotor == NULL || rightMotor == NULL) { wpi_setWPIError(NullParameter); m_rearLeftMotor = m_rearRightMotor = NULL; return; } m_rearLeftMotor = leftMotor; m_rearRightMotor = rightMotor; for (int32_t i=0; i < kMaxNumberOfMotors; i++) { m_invertedMotors[i] = 1; } m_deleteSpeedControllers = false; }
/** * Constructor for RobotDrive with 4 motors specified as SpeedController objects. * Speed controller input version of RobotDrive (see previous comments). * @param rearLeftMotor The back left SpeedController object used to drive the robot. * @param frontLeftMotor The front left SpeedController object used to drive the robot * @param rearRightMotor The back right SpeedController object used to drive the robot. * @param frontRightMotor The front right SpeedController object used to drive the robot. */ RobotDrive::RobotDrive(SpeedController *frontLeftMotor, SpeedController *rearLeftMotor, SpeedController *frontRightMotor, SpeedController *rearRightMotor) { InitRobotDrive(); if (frontLeftMotor == NULL || rearLeftMotor == NULL || frontRightMotor == NULL || rearRightMotor == NULL) { wpi_setWPIError(NullParameter); return; } m_frontLeftMotor = frontLeftMotor; m_rearLeftMotor = rearLeftMotor; m_frontRightMotor = frontRightMotor; m_rearRightMotor = rearRightMotor; for (INT32 i=0; i < kMaxNumberOfMotors; i++) { m_invertedMotors[i] = 1; } m_deleteSpeedControllers = false; }
/** * Constructor for RobotDrive with 2 motors specified with channel numbers. * Set up parameters for a two wheel drive system where the * left and right motor pwm channels are specified in the call. * This call assumes Talons for controlling the motors. * @param leftMotorChannel The PWM channel number that drives the left motor. * 0-9 are on-board, 10-19 are on the MXP port * @param rightMotorChannel The PWM channel number that drives the right motor. * 0-9 are on-board, 10-19 are on the MXP port */ RobotDrive::RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel) { InitRobotDrive(); m_rearLeftMotor = std::make_shared<Talon>(leftMotorChannel); m_rearRightMotor = std::make_shared<Talon>(rightMotorChannel); SetLeftRightMotorOutputs(0.0, 0.0); }