示例#1
0
void
Drive(int sv1, int sv2, int sv3)
{
  Servo(1, sv1);
  Servo(2, sv2);
  Servo(3, sv3);
}
void init_motors(void) {
	Serial.println("INITIALIZING MOTORS");
	
	//Allocate memory for the motors
	for(int i = 0; i < NUM_MOTORS; i++) {
		motors.numbered[i] = (motor_t*)malloc(sizeof(motor_t));
		motors.numbered[i]->esc = Servo();
	}
	
	//Assign pin numbers
	motors.named.back_left->pin = 9;
	motors.named.back_right->pin = 10;
	motors.named.front_left->pin = 11;
	motors.named.front_right->pin = 6;
	
	for(int i = 0; i < NUM_MOTORS; i++) {
		//Attach servo objects for the speed controllers	
		motors.numbered[i]->esc.attach(motors.numbered[i]->pin); 
		
		Serial.print("Pin ");
		Serial.print(motors.numbered[i]->pin);
		Serial.println(" attached");
		
		//Write initial value to motor
		write_motor(motors.numbered[i], 20);

	}
}
示例#3
0
 Victor(int p)
 {
   pin = p;
   controller = Servo();
   goal = 1500;
   cur = goal;
 }
示例#4
0
int main (int argc, char *argv[])
{
    char buf[4];
    if(argc == 2){ 
	InitServer(atoi(argv[1]));
    } else { 
	printf("not enough argument.\nusage: sudo ./a.out <port number>\n\n");
	exit(1);
    }
    if (wiringPiSetup () == -1) exit (1) ;
        pinMode (0, OUTPUT);
	digitalWrite (0, LOW) ;

    int pin = 0; //GPIO 17
    if (softPwmCreate(0,0,200) != 0){
	fprintf (stdout, "oops: %s\n", strerror (errno)) ;
	return 1 ;
    }
    
    while(1){
	while((n = read(sock,buf,4)) > 0){
	    Servo(pin, buf);
        }
    }

    return 1;
}
示例#5
0
文件: sine.cpp 项目: milch/libkovan
int main(int argc, char *argv[])
{
	Servo servos[4] = {
		Servo(1),
		Servo(2),
		Servo(3),
		Servo(4)
	};
	
	for(unsigned char i = 0; i < 4; ++i) servos[i].setPosition(512);
	
	struct timeval tv;
	for(;;) {
		gettimeofday(&tv, NULL);
		float secs = (tv.tv_sec * 1000 + tv.tv_usec / 1000) / 1000.0f;
		printf("secs: %f", secs);
		unsigned int ticks = sin(secs) * 400 + 512;
		printf("\ttick: %u\n", ticks);
		for(unsigned char i = 0; i < 4; ++i) servos[i].setPosition(ticks);
		publish();
		printf("pos 0: %d\n", servos[0].position());
	}
}
//Constructor
SabertoothPWM::SabertoothPWM()
{
  this->motorOne = Servo();
  this->motorTwo = Servo();
}
示例#7
0
文件: main.cpp 项目: ut-ras/magi
#include <XBeeLib.h>

#include <radio.h>
#include "servo.h"
#include "pin_map.h"

#define PAINT_NEUTRAL 0.5
#define PAINT_SPRAY -0.5
#define PAINT_TIME 0.7


Serial *log_serial;


Servo paint_heads[SERVO_COUNT] = {
    Servo(PTD2, 2000),
    Servo(PTD0, 2000),
    Servo(PTC4, 2000),
    Servo(PTA0, 2000),
};

int main()
{
    log_serial = new Serial(DEBUG_TX, DEBUG_RX);
    log_serial->baud(9600);
    DigitalIn sw2(SW2);
    DigitalIn sw3(SW3);

    for (int i = 0; i < SERVO_COUNT; i++) {
        paint_heads[i] = PAINT_NEUTRAL;
    }
示例#8
0
Claw::Claw(PWM pwm_in) {

    claw_servo = Servo(pwm_in, CLAW, PWM4);
}