View unanswered posts | View active topics It is currently Tue Nov 12, 2019 7:43 am






Reply to topic  [ 9 posts ] 
setMotorTarget overshooting 
Author Message
Rookie

Joined: Fri Nov 27, 2015 11:06 pm
Posts: 4
Post setMotorTarget overshooting
I am trying to use setMotorTarget to move the robot back to its initial position after being pushed by someone, but it always overshoot. If I push it forward for around 400 degrees, it will move backward to around -500 degrees (total of 1100 degrees) instead of 0?

This doesn't seem to be an issue if the robot moved by itself instead of being pushed.

My code is as follow
Code:
#pragma config(Motor,  motorA,          right,         tmotorEV3_Large, PIDControl, driveRight, encoder)
#pragma config(Motor,  motorB,          left,          tmotorEV3_Large, PIDControl, driveLeft, encoder)
#pragma config(Motor,  motorC,           ,             tmotorEV3_Large, openLoop)
#pragma config(Motor,  motorD,           ,             tmotorEV3_Large, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main() {
    bFloatDuringInactiveMotorPWM = true;
    setMotorBrakeMode(right, 0);
    setMotorBrakeMode(left, 0);
    setMotorSpeed(right, 0);
    setMotorSpeed(left, 0);

    while (true) {
        delay(5000);
        setMotorTarget(right, 0, 20);
        setMotorTarget(left, 0, 20);
        while (getMotorRunning(right) || getMotorRunning(left)) {
            displayTextLine(2, "%d", getMotorEncoder(right));
            displayTextLine(3, "%d", getMotorEncoder(left));
            delay(10);
        }
        delay(200);
        resetMotorEncoder(right);
        resetMotorEncoder(left);
    }
}


Fri Nov 27, 2015 11:18 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: setMotorTarget overshooting
Hi there,

This is not the program that you mentioned in your post, is it? I am talking about the robot that you push?

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Wed Dec 16, 2015 12:52 am
Profile WWW
Rookie

Joined: Fri Nov 27, 2015 11:06 pm
Posts: 4
Post Re: setMotorTarget overshooting
mightor wrote:
Hi there,

This is not the program that you mentioned in your post, is it? I am talking about the robot that you push?

= Xander


It is, it wait 5s for me to push it, then it should move back the distance I pushed using
Code:
setMotorTarget(right, 0, 20);

during which it will print the encoder values on the display and then reset afterward.


Wed Dec 16, 2015 6:48 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: setMotorTarget overshooting
I am definitely seeing something strange going on, but I am not sure where that behaviour is coming from.

This piece of code works as exactly how you'd expect it to:
Code:
#pragma config(StandardModel, "EV3_REMBOT")
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
   setMotorTarget(leftMotor, 360, 20);
   sleep(3000);
   setMotorTarget(leftMotor, 0, 20);
   sleep(4000);
}

So the setMotorTarget() functions are working properly.

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Thu Dec 17, 2015 1:59 am
Profile WWW
Rookie

Joined: Fri Nov 27, 2015 11:06 pm
Posts: 4
Post Re: setMotorTarget overshooting
mightor wrote:
I am definitely seeing something strange going on, but I am not sure where that behaviour is coming from.
So the setMotorTarget() functions are working properly.


Yes the setMotorTarget() function works normally when the motor are not rotated by human, but somehow when the motor are moved by human, it over shoot the target


Thu Dec 17, 2015 2:21 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: setMotorTarget overshooting
I'll take a look at it and get back to you.

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Thu Dec 17, 2015 3:14 am
Profile WWW
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: setMotorTarget overshooting
Hey there,

I think the overshoot is due to the fact that the motor is coasting after. Try the following program and let me know if this fixes the issue. I did uncover another potential issue in the EV3 motor controlling code, which will be part of the next release.

Code:
#pragma config(StandardModel, "EV3_REMBOT")
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task readEncoder
{
   while (true)
   {
      displayTextLine(3, "%d", getMotorEncoder(leftMotor));
      delay(10);
   }
}

task main() {
   startTask(readEncoder);
   
   while (true) {
      setMotorBrakeMode(leftMotor, motorCoast);
      delay(5000);
      setMotorBrakeMode(leftMotor, motorBrake);
      setMotorTarget(leftMotor, 0, 20);
      while (getMotorRunning(rightMotor) || getMotorRunning(leftMotor)) {
         delay(10);
      }
      delay(200);
      resetMotorEncoder(leftMotor);         
   }
}

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Thu Dec 17, 2015 9:48 am
Profile WWW
Rookie

Joined: Fri Nov 27, 2015 11:06 pm
Posts: 4
Post Re: setMotorTarget overshooting
mightor wrote:
I think the overshoot is due to the fact that the motor is coasting after.

That made it work, not really sure why though, the motors shouldn't be powered even if it is coasting, so given a speed as low as 20, it should pretty much stop straight away?


Sat Dec 19, 2015 1:19 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: setMotorTarget overshooting
Nah, the motors can free wheel for quite a bit and combined with the inertia of the robot, you can get quite a roll out of it.

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat Dec 19, 2015 1:49 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.