Go to Post There has to be a point where you go "I do not agree, but I can understand why they did it." - Lil' Lavery [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 09-04-2013, 11:43
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Clutter from autonomous

So this is my second year mentoring FRC, and the second year where MyRobot.cpp has absolutely exploded through the competition season due to autonomous routines being added.

I'm curious if many teams out there have similar issues, if they've solved them, and how?

My personal thinking is that a lot of this stems from the robot class being extremely tightly coupled with the game and driver station elements, and forced into a cpp file with no .h backer declaring things. While I understand this is to make things simple for people to start out, it seems like a better way should be available (in the form of an example project)

I'm thinking about doing some house-keeping during the off season to decouple the game and controls from the robot class, which should make it easy to spawn off autonomous helper functions and autonomous routines that don't all have to live in a single file to gain access to the robot parts.

Thoughts?
Reply With Quote
  #2   Spotlight this post!  
Unread 09-04-2013, 12:06
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Clutter from autonomous

Quote:
Originally Posted by DjScribbles View Post
I'm thinking about doing some house-keeping during the off season to decouple the game and controls from the robot class, which should make it easy to spawn off autonomous helper functions and autonomous routines that don't all have to live in a single file to gain access to the robot parts.
Yes, something like that is necessary once your robot code gets beyond a moderate level of complexity.

You may want to look at the WPILIB command based programming model which does that. You define every action as a class which extends the command class. You can define commands (or groups of commands) to run from button presses or other triggers, or to run in autonomous. We wrote our code in Java this year, using the command model. We ended up with 14 different commands in our 7 shot autonomous (some were called multiple times). Many of those commands were shared with our teleop code, which really simplified things. Some of our commands were things like spin up shooter, shoot a frisbee, move to pickup position, turn pickup on, drive to position, etc.

It also provided ways to manage hardware by defining subsystems, which group related hardware. A command can require a subsystem, which says it's the only command that can use that hardware. It can also require a subsystem but then be defined as interruptable, which says that another command can be scheduled to use that hardware, and the first will end when the second starts running. This is especially useful in teleop, where the operator may press multiple buttons before a command finishes, and gives the program a way to determine the correct way to proceed.

New this year, WPI provided RobotBuilder to make generating the code templates for the command model easier.
Reply With Quote
  #3   Spotlight this post!  
Unread 09-04-2013, 14:15
virtuald's Avatar
virtuald virtuald is online now
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,067
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Clutter from autonomous

Typically, we split the functions of the robot into different classes/modules that implement a portion of the robot functionality. Then all you do in myrobot.cpp is things like "if joystick button 1 is pressed, call this function". This helps keep things more organized and easier to debug.

More importantly, it makes autonomous mode really easy to implement and easy to understand, since it's only manipulating existing objects, and not creating new functionality. Most of the time, the functionality is shared between autonomous and teleoperated mode, so we get extra testing for free
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #4   Spotlight this post!  
Unread 10-04-2013, 00:42
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Clutter from autonomous

I have considered command based, but I feel it's a bit too abstract for a teaching tool, even if it would produce cleaner code.

We do currently break our code down into classes (shooter, collector, pid control, etc), however my gripe is these constructs still live in myrobot.cpp

Our teleop is pretty simple, and an autonomous routine taken by itself isn't so bad, but the sheer volume of autonomous routines (5 at the moment, with 3 or 4 deprecated, and at least one more on the way) leads to a large amount of code if it lives in one file. Moving the routines into seperate files would require passing all objects in myRobot.cpp by reference, or creating a .h file.
Reply With Quote
  #5   Spotlight this post!  
Unread 10-04-2013, 11:25
virtuald's Avatar
virtuald virtuald is online now
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,067
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Clutter from autonomous

Quote:
Originally Posted by DjScribbles View Post
. Moving the routines into seperate files would require passing all objects in myRobot.cpp by reference, or creating a .h file.
Yes, that is the C++ way of doing things.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #6   Spotlight this post!  
Unread 10-04-2013, 22:43
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: Clutter from autonomous

Having tried all of the textual language approaches, I think it's easier to teach kids to program with the command-based framework. There tends to be less code on the screen, and kids can focus on one particular aspect of the robot without having to understand the whole thing. There's a class of state machines that you avoid.

The result also contains useful building block pieces that you can easily combine into different autonomous routines.
__________________
2016-17 events: 10000 Lakes Regional, Northern Lights Regional, FTC Burnsville Qualifying Tournament

2011 - present · FRC 3081 Kennedy RoboEagles mentor
2013 - present · event volunteer at 10000 Lakes Regional, Northern Lights Regional, North Star Regional, Lake Superior Regional, Minnesota State Tournament, PNW District 4 Glacier Peak, MN FTC, CMP
http://twitter.com/MrRoboSteve · www.linkedin.com/in/speterson
Reply With Quote
  #7   Spotlight this post!  
Unread 29-04-2013, 10:47
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Clutter from autonomous

After watching Brad Millers presentation at CMP, I'm starting to come around to the command based template.

Definitely something I'm going to give a try and see how the kids like it.
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 14:36.

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