本文整理汇总了C++中Motor::setTargetSpeed方法的典型用法代码示例。如果您正苦于以下问题:C++ Motor::setTargetSpeed方法的具体用法?C++ Motor::setTargetSpeed怎么用?C++ Motor::setTargetSpeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Motor
的用法示例。
在下文中一共展示了Motor::setTargetSpeed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: forward
void forward(USHORT lspeed,USHORT rspeed)
{
lmotor.setReverse(true);
rmotor.setReverse(false);
lmotor.setAcceleration(normal_acc);
rmotor.setAcceleration(normal_acc);
lmotor.setTargetSpeed(lspeed);
rmotor.setTargetSpeed(rspeed);
}
示例2: stop
//Actions
void stop (USHORT acc)
{
int motorcounter =0;
lmotor.setAcceleration(acc);
rmotor.setAcceleration(acc);
lmotor.setTargetSpeed(0); //stop
rmotor.setTargetSpeed(0);
while ( rmotor.getCurrentSpeed()>1 && motorcounter<stop_timeout)
{
motorcounter++;
}
}
示例3: reverse
void reverse(USHORT speed) //straight back
{
lmotor.setReverse(false);
rmotor.setReverse(true);
lmotor.setAcceleration(normal_acc);
rmotor.setAcceleration(normal_acc);
lmotor.setTargetSpeed(speed);
rmotor.setTargetSpeed(speed);
for(int del =0;del<20000;del++)
{ for(int eel =0;eel<reverse_delay;eel++)
{}
}
}
示例4: turn_left
void turn_left(bool inplace, USHORT lspeed, USHORT rspeed)
{
lmotor.setAcceleration(normal_acc);
rmotor.setAcceleration(normal_acc);
lmotor.setTargetSpeed(lspeed); //stop
rmotor.setTargetSpeed(rspeed);
lmotor.setReverse(!inplace);
rmotor.setReverse(false);
for(int del =0;del<20000;del++)
{ for(int eel =0;eel<turn_delay;eel++)
{}
}
}
示例5: main
int main()
{
state = state_search;
//USHORT speed =search_speed;
Setup_Sumo_Ports();
line_triggered=false;
ioinit ();
// enable interrupts
sei();
// create timer that executes refreshDotMatrix() at 4000 hertz
Timer::instance(0)->setFrequency(1000);
Timer::instance(0)->setFunctionPtr(refreshDotMatrix);
Timer::instance(0)->start();
lmotor.setPhaseRegisters(&LEFT_PHASE_A, &LEFT_PHASE_B);
rmotor.setPhaseRegisters(&RIGHT_PHASE_A, &RIGHT_PHASE_B);
lmotor.setTimerNumber(1);
rmotor.setTimerNumber(5);
lmotor.setTargetSpeed(0);
rmotor.setTargetSpeed(0);
lmotor.setTorque(255);
rmotor.setTorque(255);
lmotor.setAcceleration(normal_acc);
rmotor.setAcceleration(normal_acc);
lmotor.setReverse(true);
rmotor.setReverse(false);
while(countdownrunning)//wait for countdown
{}
Timer::instance(1)->setFrequency(200);
Timer::instance(1)->setFunctionPtr(leftMotorUpdate);
Timer::instance(1)->start();
Timer::instance(5)->setFrequency(200);
Timer::instance(5)->setFunctionPtr(rightMotorUpdate);
Timer::instance(5)->start();
// enable the adc
A2DConverter::enable();
IRSensor IRL(UBYTE(14)); //left
IRSensor IRB(UBYTE(13)); //back
IRSensor IRR(UBYTE(12)); //right
IRSensor IRFR(UBYTE(11)); //front right
IRSensor IRFL(UBYTE(0)); //frong left
IRSensor * rangeSensors[5];
rangeSensors[0] = &IRFL;
rangeSensors[1] = &IRFR;
rangeSensors[2] = &IRR;
rangeSensors[3] = &IRB;
rangeSensors[4] = &IRL;
lines.SetFunctionPtr(checkLines);
if(enable_lines)
lines.EnableFunction();
USHORT counter =0;
//displayInt(speed);
while (true)
{
if(counter == 2000)
{
double d = volts.GetVoltageBatt();
displayFloat(d,2);
counter = 0;
}
counter++;
switch (state)
{
case state_search:
{
DotMatrix::instance()->loadSprite(
sc_hexDigits_mini[1],
SPRITE_ALPHANUMERIC_MINI_WIDTH,
SPRITE_ALPHANUMERIC_MINI_HEIGHT,
1,
12
);
//.........这里部分代码省略.........