Go to Post Dean will make America gracious again - seth.brugler [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-01-2012, 04:20
whcirobotics's Avatar
whcirobotics whcirobotics is offline
Registered User
FRC #1514 (Vikings)
 
Join Date: Nov 2008
Rookie Year: 2009
Location: WHCI
Posts: 174
whcirobotics is an unknown quantity at this point
Custom RobotDrive

Hi CD, I was wondering how to make a new class that implements the obejcts and methods from the RobotDrive. Right now all the code, which runs works fine, is all in one file. Which is not very neat so I am trying to create seperate classes for everything such as the arm ,etc. Since we used mecanum we had to invert the motors and set the pwm channels and everything which took up a lot of space, so, I want to make something like this: (just as an example)

DriveTrainMecanum DriveSystem = new DriveTrainMecanum(1,2,3,4);

In which DriveTrainMecanum implements all the methods and objects from RobotDrive but it also does the inverting of the motors and everything else. This is what i have so far but its saying "no suitable constructor" :S How do i fix this:

This is what i have written so far:

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.SimpleRobot;

public class DriveTrain extends RobotDrive {

//This is going to be set by the user but iam just making it for now
Jaguar frontLeft = new Jaguar(1);
Jaguar frontRight = new Jaguar(2);
Jaguar rearLeft = new Jaguar(3);
Jaguar rearRight = new Jaguar(4);


public DriveTrainMecanum(int cone, int ctwo, int cthree, int cfour){

}

}
__________________
"A team back in training !"
Reply With Quote
  #2   Spotlight this post!  
Unread 06-01-2012, 11:43
Thad House Thad House is online now
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,094
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: Custom RobotDrive

The easiest way to to this would be to remove the need for RobotDrive, and just copy the methods you need from that class to your custom class.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-01-2012, 11:51
linuxboy linuxboy is offline
Registered User
AKA: Oliver Graff
FRC #3780
Team Role: Alumni
 
Join Date: Nov 2010
Rookie Year: 2009
Location: MI, USA
Posts: 217
linuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud oflinuxboy has much to be proud of
Re: Custom RobotDrive

When subclassing you need to call a super constructor with the proper arguments. This has a few impacts. First of all, in your constructor, you need to call super(cone, ctwo, cthree, cfour). You should also not need your own instance variables to keep track of those jaguars, since RobotDrive already does.

If my train of thought was a little confusing let me know. Here is how I would modify the code.

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.SimpleRobot;

public class DriveTrain extends RobotDrive {

public DriveTrainMecanum(int cone, int ctwo, int cthree, int cfour){
super(cone, ctwo, cthree, cfour);
}

}
Reply With Quote
  #4   Spotlight this post!  
Unread 06-01-2012, 13:01
whcirobotics's Avatar
whcirobotics whcirobotics is offline
Registered User
FRC #1514 (Vikings)
 
Join Date: Nov 2008
Rookie Year: 2009
Location: WHCI
Posts: 174
whcirobotics is an unknown quantity at this point
Re: Custom RobotDrive

Quote:
Originally Posted by linuxboy View Post
When subclassing you need to call a super constructor with the proper arguments....you need to call super(cone, ctwo, cthree, cfour).
What do you mean by "super constructor"?
__________________
"A team back in training !"
Reply With Quote
  #5   Spotlight this post!  
Unread 06-01-2012, 14:21
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Custom RobotDrive


Quote:
Originally Posted by whcirobotics View Post
What do you mean by "super constructor"?
perhaps a superclass constructor?

http://docs.oracle.com/javase/tutori...ndI/super.html


Reply With Quote
  #6   Spotlight this post!  
Unread 06-01-2012, 14:49
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: Custom RobotDrive

Personally, I always just deal with the PWM class. I don't even bother with anything higher level than that. It just simplifies things by writing everything from scratch.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Reply With Quote
  #7   Spotlight this post!  
Unread 08-01-2012, 10:58
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: Custom RobotDrive

Quote:
Originally Posted by davidthefat View Post
Personally, I always just deal with the PWM class. I don't even bother with anything higher level than that. It just simplifies things by writing everything from scratch.
If that were simpler, there would not be any other classes on top of it. It's bad form to make your project more complicated for other team members and call it "simpler". If you want to increase the amount you code you write, simply admit your desire to your team and others who may be reading this. Please don't mislead others with claims like this.

Using the PWM class is the least simple way to control your robot drive base.

Joe
Reply With Quote
  #8   Spotlight this post!  
Unread 10-01-2012, 13:41
gixxy's Avatar
gixxy gixxy is offline
Programming and Arduino Mentor
AKA: Gustave Michel III
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Ruston, LA
Posts: 207
gixxy is on a distinguished road
Re: Custom RobotDrive

Quote:
Originally Posted by jhersh View Post
If that were simpler, there would not be any other classes on top of it. It's bad form to make your project more complicated for other team members and call it "simpler". If you want to increase the amount you code you write, simply admit your desire to your team and others who may be reading this. Please don't mislead others with claims like this.

Using the PWM class is the least simple way to control your robot drive base.

Joe
I think what he meant was that when you write it all yourself you assure yourself it works exactly as you need it to. You have the greatest understanding of your code.
Reply With Quote
  #9   Spotlight this post!  
Unread 10-01-2012, 13:44
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Custom RobotDrive


Quote:
Originally Posted by gixxy View Post
You have the greatest understanding of your code.
But what about the rest of the programming team?



Reply With Quote
  #10   Spotlight this post!  
Unread 10-01-2012, 18:29
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: Custom RobotDrive

Quote:
Originally Posted by Ether View Post



But what about the rest of the programming team?



Comments, comments, comments. Just like how the rest of the world does it.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Reply With Quote
Reply


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 22:17.

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