Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update Motors.cpp #3018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cedricbellec wants to merge 1 commit into arduino:master
base: master
Choose a base branch
Loading
from cedricbellec:patch-2
Open

Conversation

Copy link

@cedricbellec cedricbellec commented Apr 22, 2015

changed test on direction from if(direction>0) to if(direction<0) to make it right !
also recomputing diff and stopping if < 1
work great for my Arduino Robot

changed test on direction from if(direction>0) to if(direction<0) to make it right !
also recomputing diff and stopping if < 1
work great for my Arduino Robot
Copy link
Member

@ArduinoBot build this please

@facchinm facchinm self-assigned this Apr 23, 2015
Copy link
Contributor

X-Y commented Apr 25, 2015

Hi Cedos,
Probably you don't need to measure and calculate the diff twice in every loop? You can do it before moving the motors(after line 31)

Copy link
Author

Hello, I tried without recomputing the diff but it wasn’t enough accurate when turning, I will try again and test if it works well with your suggestion.
Best regards
Cédric

Le 25 avr. 2015 à 18:09, X-Y <notifications@github.com mailto:notifications@github.com> a écrit :

Hi Cedos,
Probably you don't need to measure and calculate the diff twice in every loop? You can do it before moving the motors(after line 31)


Reply to this email directly or view it on GitHub #3018 (comment).

Copy link
Contributor

X-Y commented Apr 25, 2015

Would something like this work?

 while(1){
 int currentAngle=compassRead();
 int diff=target-currentAngle;
 if(abs(diff)<1){
 motorsStop();
 return;
 }
 direction=180-(diff+360)%360;
 if(direction<0){
 motorsWrite(speed,-speed);//right
 delay(10);
 }else{
 motorsWrite(-speed,speed);//left
 delay(10);
 }
 }

Copy link
Author

Hi again, I tried your suggestion and it works , but it far less accurate , tried this code :
void RobotControl::pointTo(int angle){
int target=angle;
uint8_t speed=80;
target=target%360;
if(target<0){
target+=360;
}
int direction=angle;
while(1){
int currentAngle=compassRead();
int diff=target-currentAngle;
if(abs(diff)<2){
motorsStop();
return;
}
direction=180-(diff+360)%360;
if(direction<0){
motorsWrite(speed,-speed);//right
delay(10);
}else{
motorsWrite(-speed,speed);//left
delay(10);
}
//if(diff<-180)
// diff += 360;
//else if(diff> 180)
// diff -= 360;
//direction=-diff;

 //currentAngle=compassRead();
 //diff=target-currentAngle;
 /*if(abs(diff)<1){
 motorsStop();
 return;
 }*/
}

}

Le 25 avr. 2015 à 18:15, Cédric Bellec cedric.bellec@hotmail.com a écrit :

Hello, I tried without recomputing the diff but it wasn’t enough accurate when turning, I will try again and test if it works well with your suggestion.
Best regards
Cédric

Le 25 avr. 2015 à 18:09, X-Y <notifications@github.com mailto:notifications@github.com> a écrit :

Hi Cedos,
Probably you don't need to measure and calculate the diff twice in every loop? You can do it before moving the motors(after line 31)


Reply to this email directly or view it on GitHub #3018 (comment).

Copy link
Author

I agree with you it looks like it would be working but the fact is that it works less accurately, with my code it turns perfectly well at right angle every times.

Maybe you can do testing on your side with both versions ?

I use the robot logo example.

Regards
Cédric

Envoyé de mon iPhone

Le 25 avr. 2015 à 18:21, X-Y notifications@github.com a écrit :

Would something like this work?

while(1){
 int currentAngle=compassRead();
 int diff=target-currentAngle;
 if(abs(diff)<1){
 motorsStop();
 return;
 }
 direction=180-(diff+360)%360;
 if(direction<0){
 motorsWrite(speed,-speed);//right
 delay(10);
 }else{
 motorsWrite(-speed,speed);//left
 delay(10);
 }
 }


Reply to this email directly or view it on GitHub.

Copy link
Contributor

X-Y commented Apr 25, 2015

I don't have a robot by hand at the moment, will do some tests Monday when I get back to my work place

@cmaglie cmaglie added Board: Arduino Robot Applies only to the Arduino Robot feature request A request to make an enhancement (not a bug fix) labels May 6, 2015
Copy link
Member

Hi @X-Y, did you manage to test the fix on real hardware? Did it behave correctly?

Copy link
Author

Hello Martino, yes I’ve tested it on real hardware and it behave correctly.

Best regards,

Cédric

De : Martino Facchin [mailto:notifications@github.com]
Envoyé : lundi 18 mai 2015 09:33
À : arduino/Arduino
Cc : Cedos14
Objet : Re: [Arduino] Update Motors.cpp (#3018)

Hi @X-Y https://github.com/X-Y , did you manage to test the fix on real hardware? Did it behave correctly?


Reply to this email directly or view it on GitHub #3018 (comment) . https://github.com/notifications/beacon/ACpYkpgHh5he4-R289mf6u9cLwErB-_Qks5oKY1HgaJpZM4EGIkV.gif

Copy link
Member

@Cedos14 I'm sure it works in your setup but I need at least one more feedback before merging 😏

Copy link
Author

I understand very well your opinion and I would do the same :)

De : Martino Facchin [mailto:notifications@github.com]
Envoyé : lundi 18 mai 2015 14:31
À : arduino/Arduino
Cc : Cedos14
Objet : Re: [Arduino] Update Motors.cpp (#3018)

https://github.com/Cedos14 @Cedos14 I'm sure it works in your setup but I need at least one more feedback before merging https://assets-cdn.github.com/images/icons/emoji/unicode/1f60f.png


Reply to this email directly or view it on GitHub #3018 (comment) . https://github.com/notifications/beacon/ACpYkt6tpkBHeeM0YR6gJUWk1PFXteWsks5oKdMcgaJpZM4EGIkV.gif

Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees

@X-Y X-Y

Labels
Board: Arduino Robot Applies only to the Arduino Robot feature request A request to make an enhancement (not a bug fix)
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /