当前位置: 首页>>代码示例>>C++>>正文


C++ Motor::setAcceleration方法代码示例

本文整理汇总了C++中Motor::setAcceleration方法的典型用法代码示例。如果您正苦于以下问题:C++ Motor::setAcceleration方法的具体用法?C++ Motor::setAcceleration怎么用?C++ Motor::setAcceleration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Motor的用法示例。


在下文中一共展示了Motor::setAcceleration方法的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);
}
开发者ID:BearXP,项目名称:DLY_2014_Sumo,代码行数:11,代码来源:TDT.c

示例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++;
	}
}
开发者ID:BearXP,项目名称:DLY_2014_Sumo,代码行数:15,代码来源:TDT.c

示例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++)
		{}
	}
}
开发者ID:BearXP,项目名称:DLY_2014_Sumo,代码行数:16,代码来源:TDT.c

示例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++)
		{}
	}
	
}
开发者ID:BearXP,项目名称:DLY_2014_Sumo,代码行数:20,代码来源:TDT.c

示例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
				);
//.........这里部分代码省略.........
开发者ID:BearXP,项目名称:DLY_2014_Sumo,代码行数:101,代码来源:TDT.c


注:本文中的Motor::setAcceleration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。