Ejemplo n.º 1
0
void set_motor_speed1( int speed )
{
	if (speed>0)
		mot1.ForwardM1( 0x80, speed );
	else 
		mot1.BackwardM1( 0x80, -speed );
}
Ejemplo n.º 2
0
//==============================================================================
//  MotorsDriver::RDrive
//==============================================================================
void MotorsDriver::RDrive(short sVal) {
    if (sVal != RDrivePrev) {
        RDrivePrev = sVal;

        if (sVal >= 0)
            RClaw.ForwardM1(PACKETS_ADDRESS, sVal);
        else
            RClaw.BackwardM1(PACKETS_ADDRESS, -sVal);
    }
}
Ejemplo n.º 3
0
int main( int argc, char *argv[] )
{
	print_args(argc,argv);
	
	bool stop=false;
	init_claws();
	
	time_t t;
	time(&t);
	time_stamp = *(localtime(&t));
	printf("====================== CLAW =========================\n");

	if (argc>1) {

		if (strcmp(argv[1], "stop")==0) {
			stop = true;
			printf("Stop!");
			int count = 10;
			while (count--) {
				mot.ForwardM1 (address, 0);
				mot.ForwardM2 (address, 0);		
				mot2.ForwardM1(address, 0);
				mot2.ForwardM2(address, 0);	
		/*		mot3.ForwardM1(address, 0);
				mot3.ForwardM2(address, 0);
				mot4.ForwardM1(address, 0);
				mot4.ForwardM2(address, 0); */
				usleep(1000000);	// 0.1 sec
				usleep(1000000);	// 0.1 sec
			}
			exit(1);
		}
	}
	 
	while (1)
	{				
		printf("\nForward:\n");
		mot.ForwardM1(address, 64);
		mot.ForwardM2(address, 64);
/*		mot2.ForwardM1(address, 64);
		mot2.ForwardM2(address, 64);		*/
		usleep(1000000);	// 0.1 sec
		//usleep(1000000);	// 0.1 sec
		//read_main_battery();
		
		printf("\nBackward:\n");		
		mot.BackwardM1(address, 64);
		mot.BackwardM2(address, 64);
/*		mot2.BackwardM1(address, 64);
		mot2.BackwardM2(address, 64); */
		usleep(1000000);	// 0.1 sec		
		//usleep(1000000);	// 0.1 sec
	}
}