Go to Post The pie is as large as you make it. - boomergeek [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 21-03-2013, 07:24
austpet1230's Avatar
austpet1230 austpet1230 is offline
Registered User
FRC #4459 (Leotechs)
Team Role: Leadership
 
Join Date: Mar 2013
Rookie Year: 2011
Location: United States
Posts: 9
austpet1230 is an unknown quantity at this point
A few questions about C++

Hello everyone,

I am part of a rookie (well not anymore) team and in the 2014 FRC Competition, we plan on using C++ to program the robot.

My first question is C++ or Java better to program in?

My second question is that is this code appropriate to initialize two joysticks?
Code:
#include "WPILib.h"

class RobotDemo : public SimpleRobot
{
	RobotDrive myRobot; // robot drive system
	Joystick stick1, stick2; // only joystick

public:
	RobotDemo(void):
		myRobot(1, 2),	// these must be initialized in the same order
		stick1(1),		// as they are declared above.
		stick2(2)
	{
		myRobot.SetExpiration(0.1);
	}
Thank you to everyone and anyone who answers my question.

Austin P. //Programming Captain | The Leotechs FRC#4459
Reply With Quote
  #2   Spotlight this post!  
Unread 21-03-2013, 08:57
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,708
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: A few questions about C++

C++ and Java are extremely similar. I'd recommend you go with whichever language you're more familiar with.

Yes, that code is a reasonable start at making a driveable SimpleRobot.

Whether you're using C++ or Java, I'd highly recommend you take a look at Command Based Programming with the CommandBasedTemplate. You end up with more files, but I think it makes building autonomous routines and automated functions a good bit easier. Once you get basic commands set up, it's incredibly simple to tie them together an autonomous routine like aim and fire 3 frisbees, switch to loading position, turn 30 degrees and back up 5 feet. And then build another routine that does other things.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #3   Spotlight this post!  
Unread 21-03-2013, 09:30
Tanaythan's Avatar
Tanaythan Tanaythan is offline
Programmer
AKA: Tanay Nathan
FRC #3256 (Warriorborgs)
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2010
Location: San Jose
Posts: 27
Tanaythan is an unknown quantity at this point
Re: A few questions about C++

Similar to the previous post, C++ and Java are very similar and it's a matter of preference. However, my take on the Command Based robot is it's good for new people to C++ so it makes it easier to develop a multi-file project. So, because you're switching to it next year, you should use it as a starting point. Once you become more proficient in C++ development, I highly suggest you write the code from scratch to develop yourselves as programmers and as a learning process.
__________________
Tanay Nathan
Programmer
Team #3256 Warriorborgs
Reply With Quote
  #4   Spotlight this post!  
Unread 21-03-2013, 11:10
Mastonevich's Avatar
Mastonevich Mastonevich is offline
Andrew
AKA: Andrew Elsen
FRC #1987 (BroncoBots)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Missouri
Posts: 221
Mastonevich is a jewel in the roughMastonevich is a jewel in the roughMastonevich is a jewel in the rough
Re: A few questions about C++

Java was written with C++ used as a base in many instances so they are very similar. For FIRST robots, you would find that you could port your code from one to the other fairly easily. The underlying WPI library has all of the same classes and functions.

While I am a huge fan of the command based robot, I believe that some new people may have trouble with it. It some instances it may be best to start with the simple or iterative template to get the feel for it, but then move to the command based.

I will say we had all new programmers this year, and we are using the command based robot. We had several programming mentors though that were there to help through the stumbling blocks. After it was all said and done, our students seem to love the advantages. Changing our code is a breeze now, where as without the command based robot it would take much longer. You can not get any easier coding for autonomous, the toughest part of coding a FIRST robot.

In answer to Java or C++, pick one and go. As far as FIRST robots go, neither will really be easier or better than the other in my opinion.
__________________
~Andrew

Regional Chairman's: 2013-Alamo, 2010-Oklahoma, 2009-Colorado
Engineering Inspiration: 2016-Hub City, 2012-St. Louis, 2008-Minnesota
Regional Wins: 2010-Oklahoma
Reply With Quote
  #5   Spotlight this post!  
Unread 21-03-2013, 20:35
austpet1230's Avatar
austpet1230 austpet1230 is offline
Registered User
FRC #4459 (Leotechs)
Team Role: Leadership
 
Join Date: Mar 2013
Rookie Year: 2011
Location: United States
Posts: 9
austpet1230 is an unknown quantity at this point
Re: A few questions about C++

Thank you for all of the responses!
Reply With Quote
  #6   Spotlight this post!  
Unread 21-03-2013, 21:06
austpet1230's Avatar
austpet1230 austpet1230 is offline
Registered User
FRC #4459 (Leotechs)
Team Role: Leadership
 
Join Date: Mar 2013
Rookie Year: 2011
Location: United States
Posts: 9
austpet1230 is an unknown quantity at this point
Re: A few questions about C++

Just have one more question... How would one go about modifying the speed that the robot moves when the joystick is fully pushed forward in Teleop mode, like in Autonomous, the speed is set
Code:
myRobot.Drive(-0.5, 0.0);
is there a teleop version of this (if that makes sense)
Reply With Quote
  #7   Spotlight this post!  
Unread 22-03-2013, 00:56
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: A few questions about C++

probably something like
Code:
myRobot.TankDrive(Stick1->GetRawAxis(2)*.5 , Stick2->GetRawAxis(2)*.5);
I'm not sure which axis is which for your controller (where the number 2 should be substituted with the Y axis of your controller for tank drive). I'm also not sure that you're using tank drive Just multiply your joystick value by whatever you want to reduce the speed by, regardless of whether you're using arcade or tank or holonomic or whatever.
Reply With Quote
  #8   Spotlight this post!  
Unread 22-03-2013, 04:59
austpet1230's Avatar
austpet1230 austpet1230 is offline
Registered User
FRC #4459 (Leotechs)
Team Role: Leadership
 
Join Date: Mar 2013
Rookie Year: 2011
Location: United States
Posts: 9
austpet1230 is an unknown quantity at this point
Re: A few questions about C++

Thank you!
__________________
If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. And, like any great relationship, it just gets better and better as the years roll on.
-Steve Jobs

R.I.P. Steve Jobs 1955 - 2011. The Greatest Innovator of all time.
Reply With Quote
  #9   Spotlight this post!  
Unread 23-03-2013, 23:19
MrRoboSteve MrRoboSteve is offline
Mentor
AKA: Steve Peterson
FRC #3081 (Kennedy RoboEagles)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Bloomington, MN
Posts: 578
MrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond repute
Re: A few questions about C++

Looking at the code for RobotDrivie, it looks like you can also say

myRobot.SetMaxOutput(.5)

to apply a global factor to your drive output.

I'm a big fan of the command-based robot framework, even for sophisticated teams. It makes the robot code much easier to understand.
Reply With Quote
  #10   Spotlight this post!  
Unread 24-03-2013, 14:30
austpet1230's Avatar
austpet1230 austpet1230 is offline
Registered User
FRC #4459 (Leotechs)
Team Role: Leadership
 
Join Date: Mar 2013
Rookie Year: 2011
Location: United States
Posts: 9
austpet1230 is an unknown quantity at this point
Re: A few questions about C++

thank you!
__________________
If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. And, like any great relationship, it just gets better and better as the years roll on.
-Steve Jobs

R.I.P. Steve Jobs 1955 - 2011. The Greatest Innovator of all time.

Last edited by austpet1230 : 24-03-2013 at 15:12.
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 03:22.

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