No announcement yet.

Detect and compare the rotation for a while EV3-G

  • Filter
  • Time
  • Show
Clear All
new posts

  • Detect and compare the rotation for a while EV3-G

    Hello everyone, I have a problem with the programming of my robot, in fact, it is a car ... it goes through obstacles, only that sometimes it tries to pass and can not, I would check if it is more than 5 seconds with little engine rotation, to give it more force, how do I do this with the EV3-G?

  • #2
    Are you looking to determine when the car bumps into an obstacle and is stuck for more than 5 seconds, and that you would like the car to to push harder against the object?


    • #3

      basically this


      • #4
        This is not something you need to do as EV3 does it automatically with the Move or Motor blocks. Only with the unregulated motor blocks are you directly setting motor power. For the other move blocks you are commanding a speed, and the software automatically adjusts motor power to achieve the command speed.

        If you want to identify when you bump into obstacles and then do some kind of avoidance maneuver, that is a bit trickier. First you would want to use the unregulated motor blocks. The green move and motor blocks will ramp up motor power when the car drives into something and the wheels may spin instead of stall. Next you have to identify when the stall occurs and make a corrective action. Identifying a stall can be done by using the rotation sensor and looking at "current motor power". This is a really bad name because it is not a measurement of motor power, but of speed. When this sensor value is zero you know the motor is not spinning. Another test is to read the rotation sensor position, wait a short while and read it again. A difference of zero is a stall. This is a bit trickier to write because you really don't want waiting to prevent you from driving. Way back when my girls did FLL, they ran some stall detector code in parallel and it would stop the current move by stopping the motors. If their robot bumped into something and got stuck (or an attachment got stuck) the stall detector would quit the current move and the program automatically advanced to the next command. I remember one time when one of the field models was not reset and it caused the robot to stall. The ref said the team could rescue the robot without a penalty when the robot suddenly backed up and continued on to the next task all by itself.