Announcement

Collapse
No announcement yet.

What are we doing wrong for turns?

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • What are we doing wrong for turns?

    I am working with 4th and 5th graders and with removing the left and right turn option they are not having any success this year. They have tried the following two codes for turning:
    Example 1
    thumb_6469.jpg
    Example 2:
    thumb_6471.png

    In both these examples the robot will left or right ONCE. if they add in another turn block it is totally ignored. Their goal, among other objectives, is to make it go to an object, retrieve it, then come back to base/home. So there are many turns involved. What should we do differently? They have had zero luck with the "move right:30 for X degrees" so I would like something easier for younger kids. I am hoping this is just a small coding oversight we are making. Thanks!
    You do not have permission to view this gallery.
    This gallery has 2 photos.

  • #2
    I have often found it useful to add sounds to the program for debugging purposes. For example, play a sound inside the turning function. Then listen for how many times you hear the sound. Do you hear the sound once or twice? That lets you know how many times the function is being executed.

    You could try adding a variable and then "watch" the variable in the compiler window. Add a string variable and assign it the value "turning left" or "turning right" inside the turning functions. Then watch the variable.

    You could try adding a "wait for button" or "wait for force sensor" to various parts of the program to enable you to "step" through the code one function at a time.

    Comment


    • #3
      Don't have a Spike with me to test out, but from your code, I would guess that "set yaw angle to 0" may not be taking effect immediately. Perhaps try moving the "set yaw angle to 0" block above the "start moving" block.

      Comment


      • #4
        I ran your example 2 and it works fine for me

        When you run example 2, what happens? Describe as accurately as possible.

        Comment


        • #5
          Originally posted by Dean Hystad
          I ran your example 2 and it works fine for me

          When you run example 2, what happens? Describe as accurately as possible.
          straight for 6 inch
          left
          straight for 6 inch
          straight for 6 inch
          left
          straight for 6 inch

          So right now it is ignoring the "right turns" but completing both of the left turns.

          We ran this code 20 times with the same results 19 times
          once it did the following:

          straight for 6 inch
          left
          straight for 6 inch
          right
          straight for 6 inch
          left
          straight for 6 inch
          ignored final right​

          Comment


          • #6
            In program 2, if you look at the pink "Start moving at" you will see that the angle is being reset, the motor is being given power, and then the angle is being checked. Your problem is probably in one of these last few blocks. Here's what I would do. I would create a variable called: currentAngle. Then set that variable to the current Yaw angle right after you reset it. Then add a wait for button press and look for the variable in the compiler. Is it showing zero? If not, then you have a problem there. If it is showing zero, then create two new variables to store the power levels for both motors. Call the first variable: leftPower and the other one rightPower. Then set the variables using the same blocks you have in the Start moving block. Again, add another wait and check the values of the variables in your compiler window. Once you are satisfied that the values are correctly being calculated, then use those variables in the Start moving block.

            Now, let's check the action inside the loop. Change the "Wait Until" to a "While". Reverse the direction of the comparison (because 'while' is the opposite of 'until'). Then add another reset of the currentAngle variable to the current Yaw angle. Watch it in the compiler. Is it increasing? If not, you have a problem.

            Comment


            • #7
              I would add a wait before and immediately after movement in the gyro turn myblock. Run the program and look at the yaw feedback while the program is running.

              Comment


              • #8
                rwoodams​, did you ever find out what the problem was with your program and turning the robot?

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎