我正在尝试创建我的swerveDrive
,但遇到一个问题,即构造函数与参数列表不匹配。
我已经尝试过上课并更改原本要求的参数。
GenericEnclosure.h
class GenericEnclosure : public SwerveEnclosure {
public:
GenericEnclosure( std::string name,
frc::SpeedController& m_moveMotor,
frc::SpeedController& m_turnMotor,
rev::CANEncoder& m_encoder,
double m_gearRatio);
~GenericEnclosure();
};
RobotDriveSwerve.h文件
class RobotDriveSwerve
{
public:
RobotDriveSwerve(SwerveEnclosure* frontLeftWheel,
SwerveEnclosure* frontRightWheel,
SwerveEnclosure* rearLeftWheel,
SwerveEnclosure* rearRightWheel,
double width, double length);
virtual ~RobotDriveSwerve() = default;
.cpp文件
//All Drive Motors
rev::CANSparkMax m_leftFrontDriveMotor{1, rev::CANSparkMax::MotorType::kBrushless};
rev::CANSparkMax m_leftBackDriveMotor{2, rev::CANSparkMax::MotorType::kBrushless};
rev::CANSparkMax m_rightFrontDriveMotor{3, rev::CANSparkMax::MotorType::kBrushless};
rev::CANSparkMax m_rightBackDriveMotor{4, rev::CANSparkMax::MotorType::kBrushless};
//All Turn Motors
rev::CANSparkMax m_leftFrontTurnMotor{5, rev::CANSparkMax::MotorType::kBrushless};
rev::CANSparkMax m_leftBackTurnMotor{6, rev::CANSparkMax::MotorType::kBrushless};
rev::CANSparkMax m_rightFrontTurnMotor{7, rev::CANSparkMax::MotorType::kBrushless};
rev::CANSparkMax m_rightBackTurnMotor{8, rev::CANSparkMax::MotorType::kBrushless};
//All Drive Encoders
rev::CANEncoder m_leftFrontDriveEncoder = m_leftFrontDriveMotor.GetEncoder();
rev::CANEncoder m_leftBackDriveEncoder = m_leftBackDriveMotor.GetEncoder();
rev::CANEncoder m_rightFrontDriveEncoder = m_rightFrontDriveMotor.GetEncoder();
rev::CANEncoder m_rightBackDriveEncoder = m_rightBackDriveMotor.GetEncoder();
//All Turn Encoders
rev::CANEncoder m_leftFrontTurnEncoder = m_leftFrontTurnMotor.GetEncoder();
rev::CANEncoder m_leftBackTurnEncoder = m_leftBackTurnMotor.GetEncoder();
rev::CANEncoder m_rightFrontTurnEncoder = m_rightFrontTurnMotor.GetEncoder();
rev::CANEncoder m_rightBackTurnEncoder = m_rightBackTurnMotor.GetEncoder();
const double GEAR_RATIO = (1988/1.2);
const double L = 24.5;
const double W = 20.5;
//Enclosure initialization
GenericEnclosure swerveEnclosure1{"enc 1", m_rightFrontDriveMotor, m_rightFrontDriveMotor, m_rightFrontTurnEncoder,GEAR_RATIO};
GenericEnclosure swerveEnclosure2{"enc 2", m_leftFrontDriveMotor, m_leftFrontTurnMotor, m_leftFrontTurnEncoder, GEAR_RATIO};
GenericEnclosure swerveEnclosure3{"enc 3", m_leftBackDriveMotor, m_leftBackTurnMotor, m_leftBackTurnEncoder, GEAR_RATIO};
GenericEnclosure swerveEnclosure4{"enc 4", m_rightBackDriveMotor, m_rightBackTurnMotor, m_rightBackTurnEncoder, GEAR_RATIO};
//Swerve Drive initialization
RobotDriveSwerve swerveDrive{swerveEnclosure1, swerveEnclosure2, swerveEnclosure3, swerveEnclosure4, W, L};
错误来自此行RobotDriveSwerve swerveDrive{swerveEnclosure1, swerveEnclosure2, swerveEnclosure3, swerveEnclosure4, W, L};
,并引发此错误no instance of constructor "RobotDriveSwerve::RobotDriveSwerve" matches the argument list -- argument types are: (GenericEnclosure, GenericEnclosure, GenericEnclosure, GenericEnclosure, const double, const double)
。一切都编译良好,但这是唯一的难题。对不起所有代码,但它是可正确构建的大型类。非常感谢所有能够提供帮助的人!
答案 0 :(得分:1)
chown -R tomcat:tomcat /home/ubuntu
构造函数正在寻找指针。您需要使用“地址”运算符。更改
RobotDriveSwerve
收件人
RobotDriveSwerve swerveDrive{swerveEnclosure1, swerveEnclosure2, swerveEnclosure3, swerveEnclosure4, W, L};
答案 1 :(得分:1)
在RobotDriveSwerve
的构造函数中,当您在编译器产生错误的行提供引用时,您会期望指向类GenericEnclosure
的指针。