Go to Post Oh, and a general guiding principle: Don't be stupid. - Billfred [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #16   Spotlight this post!  
Unread 05-02-2015, 17:43
cstelter cstelter is offline
Programming Mentor
AKA: Craig Stelter
FRC #3018 (Nordic Storm)
Team Role: Mentor
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Mankato, MN
Posts: 77
cstelter will become famous soon enough
Re: How to Program Mecanum

Quote:
Originally Posted by LFRobotics View Post
Okay THANKS for all the help! I changed it and it works for forwards/backwards and straffing - I am going to program turning with the buttons. Now I am trying to program pnuematics and I did it last year and it was easy but all my button assignments don't work this year - I have the updated mappings too - here is the new code:

https://github.com/MrSTUDofCODE/NewM...team4623/robot

THANKS again!
Hooray! It's working.


I see you have created a subsystem and commands for pneumatics, and Scheduler is being run in telopPeriodic so lots looks right there.

You have buttons to schedule your commands to extend and retract, so that looks good.

But you took a shortcut and went away from subsystem/command for your drive train. I would reintroduce the old mecanum subsystem you used to have and move the motors and the mecanumDrive function you currently have on Robot to that subsystem.

I would set the defaultCommand (as in the old version) to DriveTele-- this will automatically schedule DriveTele at startup.

Then in execute() of DriveTele, you can make your call to Robot.mecanum.mecanumDrive() as you are currently doing in teleopPeriodic().

This will work better long term than the shortcut.

Flow *should* be
  1. Default Command DriveTele scheduled at statrup
  2. teleopPeriodic()
  3. Scheduler.getInstance().run()
  4. Scheduler calls DriveTele.execute()
  5. DriveTele.execute() calls mecanum.mecanumDrive()
  6. if you are pressing the one button, extend will be scheduled and you will next go to
    extend.execute()
    if pushing retarct, the retract.execute() will get called
    or if neither button pressed we are done with Sheduler.run
  7. Repeat back at step 2

You have taken a shortcut for your mecanumDrive call and gotten rid of steps 1, 3,4,5 and instead hardcoded what should be in DriveTele.execute and put it just before the last step to repeat.

It's better for Scheduler to schedule a default DriveTele command and manage calls to execute than for you to directly call mecanumDrive() on Robot without any command or subsystem.
Reply With Quote
 


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 13:05.

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