Announcement

Collapse
No announcement yet.

EV3 Python API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • EV3 Python API

    Looking through the API docs:
    https://le-www-live-s.legocdn.com/sc...e.pdf?la=en-us

    I don't see anything like drive_rotations. There's a drive(speed, steering) function, and a drive_time function, but no drive_rotations. There is an angle() and a reset_angle() method, so I think we should be able to create a move_rotations function easily enough.

    Similarly, I don't see anything like move_tank. And in fact, I think that may be hard to write using the drive(speed, steering) function. I don't think the Motor class would be a good idea because you'd lose synchronization???

    Hard to tell for sure without testing.

    Anyone try any of this out yet?
    Norfolk, Virginia, USA
    FLL Coach and Regional Tournament Head judge since 2014

  • #2
    I'll add it to the list to test, I'm going to be working through the beginner's lessons on EV3 Lessons this week and translating to python
    Coach, FLL Team 3146 Peace By Piece 2013 - 2016; Team 29410 The Dragon Bots 2016-2018
    Judge, FTC 2014-2015; Field Technical Advisor, FTC 2016-2018; Robot Inspector, FRC 2018

    Comment


    • #3
      I think the stuff you want to look at are the run_angle, gears, run_target, and track_target functions.
      Coach, FLL Team 3146 Peace By Piece 2013 - 2016; Team 29410 The Dragon Bots 2016-2018
      Judge, FTC 2014-2015; Field Technical Advisor, FTC 2016-2018; Robot Inspector, FRC 2018

      Comment


      • #4
        I was going to start doing some of the same thing (translating some basic programs into python). I was eventually going to turn them into PowerPoint presentations to help the team decide which coding method they wanted to use. If you want any help, let me know. I also hope to do some testing starting next week.

        By the way, I have installed the ev3 extension into VS Code and one really nice feature is that it writes a lot of the imports for you. I can see how those would look scary to a new kid.
        Norfolk, Virginia, USA
        FLL Coach and Regional Tournament Head judge since 2014

        Comment


        • #5
          Hah! I'm also making presentations for that. As they get more complex I'm going to have to do more thinking about direct translation vs. pythonic code organization. At least I don't think any of the code is going to require lambdas, because as much as I love them that's probably over the level of 'intro programming for 6th graders'
          Coach, FLL Team 3146 Peace By Piece 2013 - 2016; Team 29410 The Dragon Bots 2016-2018
          Judge, FTC 2014-2015; Field Technical Advisor, FTC 2016-2018; Robot Inspector, FRC 2018

          Comment


          • #6
            run_angle, gears, run_target, and track_target are all part of the Motor class, which I think is going to be unsynchronized, but I am not sure. In fact, unless you put those in separate threads, I think each motor would end up running by itself with those commands. Yeah, I am pretty cure they will not be synchronized using the Motor class.

            This is gonna be interesting.
            Norfolk, Virginia, USA
            FLL Coach and Regional Tournament Head judge since 2014

            Comment


            • #7
              It looks like the DriveBase class has at least some motor synchronization capabilities (page 38 of the Lego Education python doc). It probably wouldn't be overly difficult to build a drivetrain controller using the target tracking function and PID settings.
              FLL alumni, mentor, referee, judge

              Comment


              • #8
                driveTime would probably work fine.

                I know my approach to FLL is a bit different, so take this with a big old salt lick, but shouldn't the team be figuring out how to drive the robot around in instead of giving them a tutorial that says how the coach thinks the robot should drive around? My approach is to present the team with a problem and let them figure out how to solve it. Sure you should help them learn how the tools work (How to use the editor and downloader, basic program structure, how to import and what you need to import, etc), but beyond "Hello World!" isn't it supposed to be the team solving problems? I'd start out with a really simple program like start a motor and run for 5 seconds. Start and stop a motor when I press a button. Start a motor and stop when the light sensor sees black. I would do all this with a simple single motor robot and no steering. Then I would go to a two wheeled robot and the team could investigate how to make it drive straight and how to make a turn.

                Most of my favorite FLL memories have nothing to do with the challenge. I remember a coach telling me a story about design judging. The team was unusually quiet and the coach thought the session was going poorly until one of the kids said "We discovered PI". That unleashed a torrent where the team described how they learned to control the robot and how this number kept showing up all the time, and how the number was the same for different sized wheels and how they researched what was going on and found out that strange number had a name, Then they talked about how important circles are and how you can use circles to make the robot drive a measured linear distance and how circles can be used to control turns, even how circles determine how accurate the robot position will be when you drive out of base to a model or how much the robot can lift or how fast it can drive. This kind of thing does not happen when you have a tutorial that runs through the step of driving the robot around a 1' square.

                Comment


                • #9
                  Originally posted by BotDesigner View Post
                  It looks like the DriveBase class has at least some motor synchronization capabilities (page 38 of the Lego Education python doc). It probably wouldn't be overly difficult to build a drivetrain controller using the target tracking function and PID settings.
                  I'm curious to see what the max speed (rev/sec) is for the python driving vs the EV3 Move Tank/Steering blocks. As pointed out elsewhere, the unregulated motor block cant replicate the full speed of those drive blocks. Might the python blocks be limited as well, or can they achieve the highest speed? Only testing will tell.

                  Comment


                  • #10
                    Dean, what I am trying to do is make sure I understand the basics of ev3 python, so I can expalin the difference to the kids and let them make the choice. Then, if they do decide to use python, I want to at least have some ideas of how it can and can't work so when they get stuck, the coach can say "yeah, I think I am going to have to teach you about threads." Yikes.

                    No, I am not going to write a tutorial on how to write a line follower or gyro drive. I might write a tutorial on how to make the robot drive and maybe make a turn, but that's about it. Just enough to get them started.
                    Norfolk, Virginia, USA
                    FLL Coach and Regional Tournament Head judge since 2014

                    Comment


                    • #11
                      Originally posted by SkipMorrow View Post
                      I might write a tutorial on how to make the robot drive and maybe make a turn, but that's about it. Just enough to get them started.
                      This is no different than the tutorials that come with the EV3 Education software. No harm at all. Others do more in-depth "testing" here to learn the ins and outs of the EV3. Nothing wrong with your trying to understand that either when it comes to using python.

                      Comment


                      • #12
                        Not quite to the level of tutorial for a complete beginner, but it's a start.
                        https://www.icloud.com/keynote/0Nud4...s_Python_Notes
                        I need to add more explanation of the python language: variables, loops, functions, and debugging notes (especially the print statement)
                        Also need to add explanation of the basics of adding sensors
                        EV3Lessons is also preparing a tutorial for EV3 and Spike Python interfaces
                        Coach, FLL Team 3146 Peace By Piece 2013 - 2016; Team 29410 The Dragon Bots 2016-2018
                        Judge, FTC 2014-2015; Field Technical Advisor, FTC 2016-2018; Robot Inspector, FRC 2018

                        Comment


                        • #13
                          On your slide 5, you talk about getting the wheel diameter. Shouldn't we need the TIRE diameter?
                          Norfolk, Virginia, USA
                          FLL Coach and Regional Tournament Head judge since 2014

                          Comment


                          • #14
                            True, thanks!
                            Coach, FLL Team 3146 Peace By Piece 2013 - 2016; Team 29410 The Dragon Bots 2016-2018
                            Judge, FTC 2014-2015; Field Technical Advisor, FTC 2016-2018; Robot Inspector, FRC 2018

                            Comment


                            • #15
                              Originally posted by cschaffer View Post
                              As pointed out elsewhere, the unregulated motor block cant replicate the full speed of those drive blocks. Might the python blocks be limited as well, or can they achieve the highest speed? Only testing will tell.
                              Not true. The drive blocks cannot faster than unregulated motor blocks. Granted, 50% power (unregulated motor block) is usually slower than 50% speed (Motor and Move blocks), but 100% unregulated motor blocks will spin the motor as fast as it can spin.

                              One thing that has been noticed is using a regulated speed block inside a loop runs motors slightly slower than max speed. In this case the unregulated motor blocks can actually go faster.

                              Even if there was no motor synchronization in Python, I think the regulated motor blocks would work fine for controlling the robot. I tested this quite a lot with EV3, and unless you intentionally stall a motor it is tough to tell the difference between synchronized motors with speed regulation vs just speed regulation.

                              Comment

                              Working...
                              X