Show Posts
|
|
Pages: [1] 2 3
|
|
2
|
Topics / Robotics / Auto tennis ball shooter code help
|
on: March 22, 2013, 10:12:45 pm
|
The machine has a very odd behavior of instead of waiting for the VEX limit switch ( http://www.vexrobotics.com/276-2174.html) to give the HIGH signal and spin the motors full forward for 5 seconds, it simply spins full forward immediately and if the limit switch is tripped for 5-6 seconds the motors stop till the switch is released. Anyone know whats wrong???? #include <Servo.h>
Servo Victor;
const int LimitSwitch = 2;
void setup() // This runs once, at startup { pinMode( LimitSwitch, INPUT); Victor.attach(9); }
void loop() // This loop runs over and over {
Victor.writeMicroseconds(1500); // Turn the shooter off
if( digitalRead(LimitSwitch) == HIGH) // If the limit switch is pressed { Victor.writeMicroseconds(2000); // Turn the shooter on delay (5000); // Timer for ball to shoot }
}
|
|
|
|
|
3
|
Topics / Robotics / Re: Autonomous tennis ball shooter
|
on: March 17, 2013, 07:20:34 pm
|
|
Ok, so if I ditch the RobotOpen system and just use the arduino, can someone help me?? the program needs to wait for a signal from the VEX limit switch, and when the signal is received spin up the motors (Victor 888 for speed control) for 5 seconds, then shut off the motors and wait for the switch to trip again
|
|
|
|
|
4
|
Topics / Robotics / Autonomous tennis ball shooter
|
on: March 15, 2013, 07:03:22 pm
|
My parents have requested a autonomous tennis ball shooting machine for our dogs when they'r home alone. My plan for it was to use the RobotOpen shield ( http://www.team221.com/robotopen/product.php?id=105) and a FRC control system. It needs to detect a ball at the top of a ramp, and after the ball trips a limit switch at the top ( http://www.vexrobotics.com/276-2174.html) spin up the motors for a preset amount of time (the time it takes the ball to roll down and get launched by the wheels, probably 3-5 seconds), then shut down the motors and await the next time the limit switch trips. This is the tank drive RobotOpen program #include <SPI.h> #include <Ethernet.h> #include <RobotOpen.h>
/* I/O Setup */ USBJoystick usb1('0'); // Assign the logitech USBJoystick object to bundle 0
void setup() { /* Initiate comms */ RobotOpen.begin(); }
/* This is your primary robot loop - all of your code * should live here that allows the robot to operate */ void enabled() { // Constantly update PWM values with joystick values RobotOpen.setPWM(SIDECAR_PWM1, usb1.makePWM(ANALOG_LEFTY, INVERT)); RobotOpen.setPWM(SIDECAR_PWM2, usb1.makePWM(ANALOG_RIGHTY, NORMAL)); }
/* This is called while the robot is disabled * You must make sure to set all of your outputs * to safe/disable values here */ void disabled() { // PWMs are automatically disabled }
/* This loop ALWAYS runs - only place code here that can run during a disabled state * This is also a good spot to put driver station publish code * You can use either publishAnalog, publishDigital, publishByte, publishShort, or publishLong * Specify a bundle ID with a single character (a-z, A-Z, 0-9) - Just make sure not to use the same twice! */ void timedtasks() { RobotOpen.publishAnalog(ANALOG0, 'A'); // Bundle A RobotOpen.publishAnalog(ANALOG1, 'B'); // Bundle B RobotOpen.publishAnalog(ANALOG2, 'C'); // Bundle C RobotOpen.publishAnalog(ANALOG3, 'D'); // Bundle D RobotOpen.publishAnalog(ANALOG4, 'E'); // Bundle E RobotOpen.publishAnalog(ANALOG5, 'F'); // Bundle F }
/* This is the main program loop that keeps comms operational * There's no need to touch anything here!!! */ void loop() { RobotOpen.pollDS(); if (RobotOpen.enabled()) enabled(); else disabled(); timedtasks(); RobotOpen.outgoingDS(); } How can this be modified to allow for all the necessary tasks of a autonomous tennis ball shooter??????????
|
|
|
|
|
5
|
Using Arduino / Motors, Mechanics, and Power / Mecanum/Holonomic Drive
|
on: February 19, 2013, 11:46:59 pm
|
My current project uses an Arduino Uno with Ethernet Shield and a RobotOpen shield ( http://www.team221.com/robotopen/product.php?id=105) but they don't have Mecanum (sometimes called Holonomic) drive examples, only Tank, Swerve, and Arcade style drive systems. So this is the robots current Tank setup: #include <SPI.h> #include <Ethernet.h> #include <RobotOpen.h>
/* I/O Setup */ USBJoystick usb1('0'); // Assign the logitech USBJoystick object to bundle 0
void setup() { /* Initiate comms */ RobotOpen.begin(); }
/* This is your primary robot loop - all of your code * should live here that allows the robot to operate */ void enabled() { // Constantly update PWM values with joystick values RobotOpen.setPWM(SIDECAR_PWM1, usb1.makePWM(ANALOG_LEFTY, NORMAL)); RobotOpen.setPWM(SIDECAR_PWM2, usb1.makePWM(ANALOG_RIGHTY, NORMAL)); }
/* This is called while the robot is disabled * You must make sure to set all of your outputs * to safe/disable values here */ void disabled() { // PWMs are automatically disabled }
/* This loop ALWAYS runs - only place code here that can run during a disabled state * This is also a good spot to put driver station publish code * You can use either publishAnalog, publishDigital, publishByte, publishShort, or publishLong * Specify a bundle ID with a single character (a-z, A-Z, 0-9) - Just make sure not to use the same twice! */ void timedtasks() { RobotOpen.publishAnalog(ANALOG0, 'A'); // Bundle A RobotOpen.publishAnalog(ANALOG1, 'B'); // Bundle B RobotOpen.publishAnalog(ANALOG2, 'C'); // Bundle C RobotOpen.publishAnalog(ANALOG3, 'D'); // Bundle D RobotOpen.publishAnalog(ANALOG4, 'E'); // Bundle E RobotOpen.publishAnalog(ANALOG5, 'F'); // Bundle F }
/* This is the main program loop that keeps comms operational * There's no need to touch anything here!!! */ void loop() { RobotOpen.pollDS(); if (RobotOpen.enabled()) enabled(); else disabled(); timedtasks(); RobotOpen.outgoingDS(); }
And my question is wether i could take the drive part out of Kiwi library's basic mecanum code /* Kiwi drive macros and functions * By Jonathan M. Guberman, 2011 * http://upnotnorth.net * * Use this code however you like, but don't blame me if it doesn't work! */
#include <Servo.h>
#define SPEED(x) (90 + (x)) #define DRIVE(x,y,z) servo1.write(90 + (x)); servo2.write(90 + (y));servo3.write(90 + (z)) #define MAXSPEED 20 Servo servo1; Servo servo2; Servo servo3; void setup() { } void loop() {
}
void setDrive(int angle, int maxspeed){ float x = cos(3.14159 * (float) angle / 180); float y = sin(3.14159 * (float) angle / 180); DRIVE((int)(x*maxspeed),(int)((-0.5*x + 0.866*y)*maxspeed),(int)((-0.5*x-0.866*y)*maxspeed)); }
void setDrive(int angle){ setDrive(angle, MAXSPEED); }
void stopDrive(){ DRIVE(0,0,0); }
void stopDrive(int time){ stopDrive(); delay(time); } And copy & paste it into the RobotOpen code, replacing the tank drive bit. This possible? and where would the code be inserted?
|
|
|
|
|