Go to Post Give a group of engineers the choice of three options, and they'll pick choice number seven. - Taylor [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #16   Spotlight this post!  
Unread 13-08-2014, 14:20
pimathbrainiac's Avatar
pimathbrainiac pimathbrainiac is offline
Today, Regionals. Tomorrow, Worlds.
AKA: Philip N
FRC #1127 (Lotus Robotics)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Milton HS
Posts: 49
pimathbrainiac can only hope to improve
Re: Drivetrain Idea - "Box Drive"

That design uses pneumatic wheels, not traction wheels, though. Traction wheels might not actuate properly.

Also that design doesn't do diagonals or moving while rotating, which are key to be able to do for a field-centric system. I don't know of a non omni/mecanum/swerve/h drive that can do this, though.

That said, that drivetrain looks effective for Rebound Rumble, so it served its purpose well, and might serve another purpose later. It just won't serve my purpose currently.
  #17   Spotlight this post!  
Unread 13-08-2014, 20:18
pimathbrainiac's Avatar
pimathbrainiac pimathbrainiac is offline
Today, Regionals. Tomorrow, Worlds.
AKA: Philip N
FRC #1127 (Lotus Robotics)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Milton HS
Posts: 49
pimathbrainiac can only hope to improve
Re: Drivetrain Idea - "Box Drive"

I redid the Drivetrain code to normalize the motor values. How is the code? (Just ctrl-A ctrl-V'd it)

Code:
// RobotBuilder Version: 1.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.
package org.usfirst.frc1127.DevBot2014_2015.subsystems;
import org.usfirst.frc1127.DevBot2014_2015.RobotMap;
import org.usfirst.frc1127.DevBot2014_2015.commands.*;
import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.command.Subsystem;
/**
 *
 */
public class Drivetrain extends Subsystem
{
    //constants
    final double DISTANCE_X = 1.0;
    final double DISTANCE_Y = 1.0;
    
    //only needed for field-centric
    final double PI = 3.1415926;
    
    //wheel velocity values | positive x values are right | positive y values are forwards
    private double[] motorValues = {0.0, 0.0, 0.0, 0.0};
    
    //rotation is cw
    private double rotationX;
    private double rotationY;
    
    //field-centric stuff
    private double curr_gyro_angle_degrees = 0.0;
    private double curr_gyro_angle_radians = 0.0;
    private double cos;
    private double sin;
    private double temp;
    
    //for the for loop
    private int i;
    double maxValue = 1.0;
    
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
    CANJaguar cANJaguar1 = RobotMap.drivetrainCANJaguar1;
    CANJaguar cANJaguar2 = RobotMap.drivetrainCANJaguar2;
    RobotDrive robotDrive2X = RobotMap.drivetrainRobotDrive2X;
    CANJaguar cANJaguar3 = RobotMap.drivetrainCANJaguar3;
    CANJaguar cANJaguar4 = RobotMap.drivetrainCANJaguar4;
    RobotDrive robotDrive2Y = RobotMap.drivetrainRobotDrive2Y;
    Gyro gyro1 = RobotMap.drivetrainGyro1;
    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
    
    // Put methods for controlling this subsystem
    // here. Call these from Commands.
    public void initDefaultCommand()
    {
        // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND
        setDefaultCommand(new DriveWithJoysticks());
    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DEFAULT_COMMAND
	
        // Set the default command for a subsystem here.
        //setDefaultCommand(new MySpecialCommand());
    }
    
    public void TakeJoystickInputsAndDrive(Joystick left, Joystick right)
    {
        calculatedDrive(left.getY(), left.getX(), right.getX());
    }
    
    void calculatedDrive(double y, double x, double rotation)
    {
        //Field-centric adjustments. Comment out for robot-centric.
        curr_gyro_angle_degrees = gyro1.getAngle();
        curr_gyro_angle_radians = curr_gyro_angle_degrees * (PI / 180);
        cos = Math.cos(curr_gyro_angle_radians);
        sin = Math.sin(curr_gyro_angle_radians);
        temp = y * cos - x * sin;
        x = y * sin + x * cos;
        y = temp;
        
        //This code is needed for both robot-centric and field-centric
        rotationX = rotation * DISTANCE_X;
        rotationY = rotation * DISTANCE_Y;
        motorValues[0] = y - rotationY;
        motorValues[1] = y + rotationY;
        motorValues[2] = x - rotationX;
        motorValues[3] = x + rotationX;
        
        maxValue = 1.0;
        for(i = 0; i < 4; i++)
        {
            if(motorValues[i] > maxValue)
                maxValue = motorValues[i];
        }
        
        if(maxValue > 1.0)
            for(i = 0; i < 4; i++)
                motorValues[i] = motorValues[i] / maxValue;
        
        drive(motorValues[0], motorValues[1], motorValues[2], motorValues[3]);
    }
    
    void drive(double y1, double y2, double x1, double x2)
    {
        //left, right
        robotDrive2Y.drive(y1, y2);
        //front, back
        robotDrive2X.drive(x1, x2);
    }
    
    public void stop()
    {
        robotDrive2Y.drive(0, 0);
        robotDrive2X.drive(0, 0);
    }
}
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:57.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi