Giter Site home page Giter Site logo

corebot-2017's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

corebot-2017's Issues

A while loop in a task will continue running even after disabling and reenabling?

We had a bug on Saturday. What happened is if we disabled in the middle of our autonomous code and then reenabled, the motors would sometimes continue at the same values they had before and would not accept input. I found a tricky infinite loop and fixed it, and from then on we didn't see the issue again:

581d9e3#diff-2094e283bb3890e841571da6ac09c6b1R133

Here's my attempt at figuring out what the issue is.

Consider the following TaskRunner and example task:

new TaskRunner(
    new ExampleTask(),
    new UpdateMotorsTask()
);
public class ExampleTask extends Task {
    public void run() {
        while (true) {
            Robot.motors.allDrive.set(1.0);
            wait.forFrame();
        }
    }
}

If you enable the robot, this task will run and work fine. However, if you make the logic slightly more insidious:

public class ExampleTask extends Task {
    public void run() {
        while (true) {
            if (condition) {
                continue;
            }
            Robot.motors.allDrive.set(1.0);
            wait.forFrame();
        }
    }
}

If condition is true, then this task will get caught in an infinite loop and will not ever wait, and thus will not ever terminate. This loop will continue to run as long as condition is true...

Actually, I can't seem to get something that'd replicate the issue we saw on Saturday.

Repeating tasks never exit

There is currently no task cancellation policy. For example, RepeatingTask.run method should return when the robot is disabled and/or switches out of the current mode (autonomous/teleop). Currently it never returns (has a while(true)). The iterator logic thread (collection thread) will never exit - will just be stuck waiting for a yield that never returns. It's not clean and it will leak threads each time there is a mode switch (when a new taskRunner instance is created, leaving the old one still hanging around stuck in some Task's yield call.) Suggestion: cancel task, and yield code should throw an exception. This support may already be there in the underlying Generator framework -need to investigate.

Cannot dynamically add tasks

Cannot currently dynamically add a Task (after teleop/autonomous operation mode has started). Workaround: add all anticipated tasks during init, and if needed a Task yields until it is triggered by some future "start" condition. Can get tricky if the logical task needs to be run multiple times. We should check if this scenario can possibly arise for the competition robot, and if so try to try to test a comparable scenario earlier rather than later.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.