/r/FLL

Photograph via snooOG

The subreddit for FIRST Lego League


Welcome to the sub-reddit for the international First Lego League (FLL) competition. This is a engineering competition focused toward kids in aged 9-14. The competitions consists of two main parts: Robot Building and Problem Solving. They'll have from September to January to build their robot and solution around the varying themes from year to year. They will also provide an answer to a large question and show it to judges at local competitions, leading up to the FIRST Championship's FLL World Festival, where they will compete against the best 100 of the over 15,000 teams competing worldwide.

Rules

  • No spam.
  • All posts must be directly related to FLL or other FIRST programs.
  • Be respectful and appropriate to all other members of this sub-reddit. Since this is primarily a kids-oriented competition, please keep all language G Rated.
  • Follow all reddit-wide rules.
  • Follow general reddiquette.

FLL Links

Related Subreddits

/r/FLL

2,552 Subscribers

2

Using ChatGPT to Develop FLL Code

Lately I've been discussing the topic of coding a good "turn" algorithm for FLL. In other words, how can you make the robot turn toward a desired heading in an accurate and efficient manner. I decided to pose the problem to ChatGPT to see what it comes up with.

Prompt 1:

Given a robotic vehicle with two wheels, I need equations that can be used to accomplish turning the robot a certain number of degrees by rotating the wheels different amounts. I have a gyro sensor to measure the robot heading.

Reddit doesn't handle the equations well, so I'm editing the response from ChatGPT just a bit, but here's what it came up with:

----------------------------------

Using a gyro sensor simplifies turning the robot to a specific angle because you can continuously monitor the robot's actual orientation during the turn and adjust the wheel speeds accordingly. Here's how you can do it:

1. Setup

  • Gyro sensor: The sensor provides angular velocity (ω\omega) in degrees per second (or radians per second), which can be integrated over time to estimate the robot's heading (θ\theta).
  • Desired Turn Angle (θ desired): The target angle you want the robot to turn.
  • Control Strategy: Use feedback control to adjust the wheel speeds until the gyro reports the robot has reached θ desired.

2. Steps to Execute the Turn

a. Initial Setup

  • Reset the gyro sensor to 0
  • Determine the direction of the turn (clockwise or counterclockwise).

b. Feedback Loop

  • Use the gyro's current heading to adjust the wheel speeds dynamically during the turn.
  • Controller Logic:
    1. Compute the error: Error = θ desired − θ current
    2. Apply proportional control (or PID if necessary): Speed Difference = Kp⋅Error (Where Kp is the proportional gain. Larger errors lead to faster turns; smaller errors slow down the wheels to stop precisely.)

c. Wheel Speed Commands

  • For a spin turn:
    • Left wheel: +S
    • Right wheel: -S, where S is the speed adjusted based on the feedback.
  • For a pivot turn:
    • One wheel stops, and the other moves forward or backward at speed S.

3. Stopping Condition

  • Continuously monitor the gyro's heading. When θ current ≈ θ desired (within a small tolerance), stop the wheels.

----------------------------------

Alright, that looks pretty good, but there are several problems which I then explained to ChatGPT.

Prompt 2:

There are several problems with that proposal.

  1. Attempting to stop the turn when the robot's heading is within a desired tolerance of the target could easily cause the robot to dither back and forth around the target, constantly overshooting the desired tolerance in both directions. Modify the algorithm to stop as soon as the robot has surpassed the target heading rather than trying to correct for overshoot.
  1. Using a proportional controller is a good idea to more accurately hit the target heading, but the initial error will be very large which will cause a large jerk as the robot starts turning. Modify the algorithm to ramp up the speed gradually to avoid commanding too much speed too quickly.
  1. Using proportional control will cause the robot to slow to zero speed as the robot approaches the target heading and the error approaches zero. However, due to real-world limitations, a robot will not actually move at very low commanded speeds. There is a minimum commanded speed that is required to induce any robot motion at all. Modify the algorithm to include a minimum speed to ensure the robot keeps moving, even when the proportional control equation produces an unrealistically low, commanded speed.

Write out the entire algorithm in pseudo code for turning a robot using proportional control and a gyro sensor. Parameters will include, minimum speed, maximum speed, desired heading, and turning radius.

And wouldn't you know it, ChatGPT came up with a damn fine algorithm that would probably work quite well for FLL. Translating this to SPIKE Scratch might be challenging, but it's doable.

----------------------------------

Here’s a robust pseudo-code algorithm incorporating your suggestions to handle the issues of overshooting, jerky starts, and realistic speed thresholds:

Pseudo-Code for Robot Turn Using Gyro Sensor

FUNCTION TurnRobot(desired_heading, min_speed, max_speed, turning_radius):
    # Initialization
    current_heading ← GyroSensor.get_heading()     # Initialize current heading from gyro
    heading_error ← desired_heading - current_heading
    direction ← SIGN(heading_error)                # Determine turn direction (+1 for clockwise, -1 for counterclockwise)
    proportional_gain ← 0.1                        # Tune this value to scale the response

    # Speed Ramp-Up Initialization
    ramp_up_rate ← 0.05                            # Speed increment per iteration
    current_speed ← min_speed                      # Start at minimum speed

    # Start Turn
    WHILE ABS(current_heading - desired_heading) > 0:  # Loop until surpassing the target heading
        # Update Current Heading
        current_heading ← GyroSensor.get_heading()
        heading_error ← ABS(desired_heading - current_heading)

        # Check if Target Heading Surpassed
        IF (direction > 0 AND current_heading >= desired_heading) OR
           (direction < 0 AND current_heading <= desired_heading):
            BREAK                                   # Exit loop as heading is surpassed

        # Compute Proportional Speed (Capped at Max Speed)
        proportional_speed ← proportional_gain * heading_error
        proportional_speed ← CLAMP(proportional_speed, min_speed, max_speed)

        # Gradually Ramp Up Speed
        current_speed ← MIN(current_speed + ramp_up_rate, proportional_speed)

        # Set Wheel Speeds for Turning
        inner_wheel_speed ← direction * current_speed * (1 - turning_radius / (turning_radius + wheel_base / 2))
        outer_wheel_speed ← direction * current_speed * (1 + turning_radius / (turning_radius + wheel_base / 2))

        MotorController.set_wheel_speeds(inner_wheel_speed, outer_wheel_speed)

    # Stop the Robot After Surpassing the Target Heading
    MotorController.stop()

END FUNCTION

Key Features of the Algorithm

  1. Stopping After Surpassing Target Heading:
    • The loop exits as soon as the robot's heading surpasses the target heading, preventing dithering or oscillation around the target.
  2. Proportional Control with Speed Limits:
    • The proportional speed is calculated based on the heading error and is clamped between the min_speed and max_speed to avoid excessive speed or robot immobility.
  3. Ramp-Up for Smooth Acceleration:
    • The ramp_up_rate ensures that the robot gradually accelerates from the min_speed to the computed proportional speed, avoiding sudden jerks.
  4. Minimum Speed Constraint:
    • A floor on the speed (min_speed) ensures the robot moves reliably even when the proportional control produces very small speed values.
  5. Differential Wheel Speeds for Turning Radius:
    • The inner and outer wheel speeds are adjusted based on the specified turning_radius and wheel_base to achieve the desired turn geometry.

Parameter Descriptions

  • desired_heading: Target orientation in degrees.
  • min_speed: Minimum speed to ensure motion occurs (e.g., determined experimentally).
  • max_speed: Maximum speed to limit rapid turns.
  • turning_radius: Radius of the turning arc (use 0 for spin turns).
  • ramp_up_rate: Incremental speed increase per iteration for smooth acceleration.
  • proportional_gain: Tuning parameter to control responsiveness of the turn.

Example Use

TurnRobot(desired_heading=90, min_speed=0.1, max_speed=1.0, turning_radius=0)

This call would execute a smooth, spin turn to 90 degrees with controlled acceleration and deceleration, ensuring no dithering or unnecessary corrections.

4 Comments
2024/12/04
19:18 UTC

3

Multitask in Spike Prime (Word Blocks)

Is it just me or sometimes the broadcast (for multitasking) cant work properly. Its like some programs are skipped. Is there solution for that?

3 Comments
2024/12/04
09:23 UTC

13

Smooth Acceleration and Deceleration for Improved Accuracy

4 Comments
2024/12/03
20:51 UTC

6

Coral tree

In the submerged challenge, the field setup says that the top of the coral tree must touch the mat. Ours does not. We've tried assembling the whole model again. We tried to make the change suggested in the first update (Update 1: coal nursery setup) as well (although it's very confusing). Does the black ring at the top of the tree touch the mat for all of you? Any suggestions about what we could be doing wrong?

3 Comments
2024/11/30
23:47 UTC

0

Please answer this survey for our innovation project!

2 Comments
2024/11/30
19:48 UTC

9

Sale on olf Challenge kits

Andymark has a great sale going on "ROBODEAL24" on prior years mission model kits. Just FYI

AndyMark, Inc

0 Comments
2024/11/28
13:38 UTC

8

Gift for FLL kid learning Python?

My son (13) is in FLL and has been loving learning Python this year. He would love to continue learning at home so I would love to give him a way to do that. The problem is I don’t know where to start! Is there a small kit or set that I can get for him where he can work on these skills & learning at home? I know there are books and things I can get him but he loves interacting with something tactile and learning with his hands…

6 Comments
2024/11/28
12:37 UTC

4

What does your Lego parts storage look like?

Hi all! I'm a new team supervisior, and I feel one of the limiting factors for my team is the way our lego is stored. Currently, there are thousands of pieces in 3 big tubs with no organization. If students had an easy system to find the parts they need I think they would be more motivated to innovate and make the necessary changes for their robot.

Just curious if any of you have a system that works. I understand that organizing it will take time, but I'm not really sure where to even start.

Thanks!

17 Comments
2024/11/26
14:20 UTC

0

Acceleration + Deceleration and gyrostrait in python version 3.4.3

I have made it through the entry coemption to get into regionals and I need some help developing moving code in python

1 Comment
2024/11/26
05:00 UTC

6

Proportional Control to Follow a Heading using Yaw Sensor. (More info in comments.)

4 Comments
2024/11/25
20:05 UTC

2

Lego RCX 2.0 communication error

I am using Oracle virtualbox v6.1.32. My virtual machine is running windows XP x32 and the laptops is is windows 10. The firmware loads onto the RCX just fine, but when it tries to load the programs onto the RCX it has a communication error.

1 Comment
2024/11/25
02:43 UTC

0

Help create a FLL team

Hi All - a local school teacher is helping some underprivileged kids raise funding for creating an FLL team. The School used to sponsor this program, however, they decided to not sponsor it this year and the students missed the timeline for grant applications. Your help would be greatly appreciated.

https://click.pstmrk.it/3/spot.fund%2FTechEducationForCommunity/aBUu/99_4AQ/AQ/654d9d40-611d-4b8e-bfb9-7bb4e5323ef8/2/inBYK5o4W6

0 Comments
2024/11/24
21:58 UTC

9

Can we change parts during match?

Can we change little things like arms or attachments on the robot in the home area during the 2.5 minutes?

This question is for FLL Submerged 2024.

7 Comments
2024/11/24
19:47 UTC

3

FLL - Michigan

Hi All,

Our team qualified for the regionals. We are based in SE Michigan.

I wonder if anybody in this group is willing to give their mat and the pieces which will greatly help us practice for the regionals. We have one set but a second one will be useful.

Anybody on this group willing to donate or sell their used mat and pieces (and maybe robot) to us.

This is Lego Submerged Kit for grade 4 and 5.

Thanks.

2 Comments
2024/11/24
18:52 UTC

3

How to go forward always the same?

I've seen systems with gyro and relative position of the motors to make a robot turn everytime the same, but I'm having the problem that sometimes the robot walks 10 cm, and then he walks more or less, does anyone have any code that makes he walks the same everytime?

5 Comments
2024/11/24
16:28 UTC

4

Tips & Tricks

Does anyone have any trick that they used during Qualifications that the judges really liked? We had a fun skit, colorful board, diagram on how our project would work, and we are considering making a social media for our team so we can reach out to different companies.

9 Comments
2024/11/24
03:15 UTC

2

Table Width 47±1/8”

Hello, looking to build a table for my kids. Looking the specified dimension on FLL website states.

The wall-to-wall dimensions must measure 93±1/8” by 45±1/8”

Would having a larger width at 47" effect anything?

11 Comments
2024/11/23
16:09 UTC

1

bug gyro turn

https://youtu.be/Iq7BIvdjDnM?si=bzygmHRjAtRzyMuC&t=1177

I'm not using the programming in this video, but I'm having the same problem. I understood that the robot, when it reaches the final angle, does not find it and keeps rotating around that value. Could you help me?

In my program I only use Proportional. I define a power of 15 or -15 for the robot at the beginning of the program, and then for each motor it will add a proportional value in relation to the angle, then it kind of slows down and always ends up with the value that I entered initially .

3 Comments
2024/11/23
12:52 UTC

2

Precise movements

Guys I'm now I'm FTC but I'm trying to improve fll movements, the turns and straight and back it's so unreliable, all I can find is about yaw, but with my experience, this sensor is extremely unreliable, does anyone know how to make turns and movements precise? I was thinking on position and relative position of the motors

13 Comments
2024/11/23
00:49 UTC

3

Spike prime read file

Hi, so my team and I started using pythfinder(a Python library with which you can create trajectories and make it easier to program the robot). Pythfinder gives one a txt file with different information, but I can't even read it in the spike app. Does anyone know if it would be possible to do this and how?

1 Comment
2024/11/22
19:42 UTC

3

Feedback survey request

Hello everyone!

Please consider taking this survey created by our FLL Challenge team Beta Artists to provide feedback on their innovation project idea:

https://forms.gle/ZCmL6t5127jwHTqEA

There is a presentation and prototype link in the first section with some explanation of their idea.

Thanks and all the best!

1 Comment
2024/11/22
16:07 UTC

5

Quick FLL Survey

Hey All!

We're an FLL team from Dover, NH and we'd love If you could fill out a quick survey! It's about 30 seconds long and it assists with our Innovation Project. It's linked here!

3 Comments
2024/11/21
23:48 UTC

5

Teams old and new, how many points are you getting?

My team did really well last season but just isn't motivated this year. I know it's still early, but they've got about 260 points. I don't think that will get them past the first qualifier. Where are you guys?

12 Comments
2024/11/21
11:19 UTC

3

Fll challenge question

First year team question - are teams required to wear matching shirts for the tournament?

4 Comments
2024/11/19
23:32 UTC

1

PID time to distance based.

Hi guys, I made a simple PID line follower but we don't know how we can change it from time based to distance based. If anyone could help change it to distance based it would be very helpful.

https://preview.redd.it/vcf9wg5qqw1e1.png?width=784&format=png&auto=webp&s=75d16de808e99695b3a024dd0c7fda544aba6b1b

4 Comments
2024/11/19
19:12 UTC

4

PROBLEMS WITH CONTACTING ORGANIZATIONS FOR FEEDBACK FOR THE INNOVATION PROJECT

Hey! I don´t know if It´s usual or not, but we´ve contacted over 20 organizations and they all tell us they are busy or that we´ve aren´t an interesting team nor company. Is it that we are contacting too high-rated organizations and that we should contact smaller ones?

6 Comments
2024/11/19
18:48 UTC

1

Help with spyke kot running any program

Hi! im starting saying im not english native, so im sorry if I say something the wrong way I was running programs on the spyke prime, from the lego education windows app, and suddenly it didnt recieve any program... the bluetooth is working, it does connect with my app, i can se the grades and its ok, gyroscope ok... its not a connection problem... but when i "download" or "send" a program to run on my spyke, the spyke dont recieve nothing...

  • I have tried factory reset (pressing green 10 seoconds, pressing again on red, it did reset the name)...
  • I have tried getting off the battery for 10 minutes.... nothing have worked...
  • Even tried to change firmware on pybrick, but it asked me to intall a driver on a list, (winusb) and i couldnt find it... and i dont know if that is the fix anyway...

somebody has an idea? im running out of them :/

0 Comments
2024/11/19
13:51 UTC

4

M12 Feed the Whale Question

I'm wondering if it's possible to complete the mission in ways not depicted in the original video. Specifically, my kids are wondering if they can knock down the whale and push the krill into the whale's mouth, then set it back upright in order to complete the mission. I'm looking at the rule book and I don't see anything that suggests they can't do this? Any advice would be appreciated. Thank you!

4 Comments
2024/11/19
00:18 UTC

8

Judging from the shadows

We didn't find out until the last week that although we will receive feedback from our judging session, we will not know how our overall scored compared to the other teams at the event. Effectively what happened is that the judges met in a room, debated amongst themselves, came out of their room, and announced who advanced, without any transparency. Is this normal for all qualifying tournaments in FLL Challenge?

For an engineering focused tournament, it seems odd that 75% of the points are subjective and kept secret.

For a bit of background, although we didn't expect to qualify, we did expect to know how close we came to qualifying. Missing by one is completely different than being ranked last, which would require a complete rethink of strategy.

20 Comments
2024/11/18
17:18 UTC

4

Offsetting tables at tournaments?

Since some FLL teams have already competed - my PDP is claiming we need to offest the competition tables by 3.75" and screw them together due to the submarine mission. He says this is coming from FIRST. Anyone else heard/seen this? My club built/stores our region's tables and I'm nervous about screwing and unscrewing them together over 4 competitions this season and not ruining them. I can't find anywhere public that says this.

7 Comments
2024/11/18
15:04 UTC

Back To Top