Thread: Possessed robot
View Single Post
  #12   Spotlight this post!  
Unread 24-02-2011, 16:35
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Possessed robot

The reason the robot is possessed is that you are calling Wait inside if Elevator_get_the_heigh and Carriage_get_the_height. The tasking thread is told to wait for some time and cannot return back to get the next teleop packet containing new joystick values. The packets where the drivers let go of the joystick are being sent to the robot, but they are ignored because of the Wait().

There are many ways to fix this, but it is very easy to introduce. First make sure the explanation makes sense to you and any other programmers working on the robot.

Assuming time can be driven by the ~20ms arrival rate of new teleop packets, what you want to do is record the time that you started the carriage or elevator motor in a static variables, or perhaps if you do want to use objects, create a static object that holds the pending movements of the motors, the time movement started, and any other info that is helpful.

Each time you enter into teleop, do a quick check to see if a motor has been on long enough and should be turned off. This is also when you'd turn on the elevator motor.

Pay special attention to the initial values and any overrides that the drivers may need that turn the motors off before they reach their target.

Once you get rid of the waits, the exorcism should be complete, and perhaps you can even turn the watchdog back on. It will help identify any other placed in your code which wait or loop and block communications.

Greg McKaskle
Reply With Quote