How to control movement?

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

User avatar
RoboRobo
Novice
Posts: 36
Joined: Sat Jun 18, 2016 2:10 pm

How to control movement?

Postby RoboRobo » Fri Nov 10, 2017 2:22 pm

Hello,

I would like to ask you advice what would be the best solution for my problem. My robot moves in predetermined route and stops when an obstacle is detected and then has to do other movements from that point. I calculate movements using my own coordinate system (Navigator does not work well for me) and send to motors distance and angles through MovePilot travel(double distance, boolean immediateReturn) and rotate(double distance, boolean immediateReturn). When robot detects a barrier, it changes immediateReturn from false to true and goes through remained moves in predetermined route in "empty", or without actual movement. After that, current pose is got using OdometryPoseProvider. From this point, robot calculates the following movements, change immediateReturn from true to false, and sends to MovePilot as a travel() and rotate(). All calculations look well, but robot does not executes new movement well. It seems that travel() or rotate() methods are skipped and sometimes no actual movement is done, and sometimes everything moves nice. So, coming back to my question: do I cancel predetermined route and set new movements in a good way or there are any better solutions?

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: How to control movement?

Postby gloomyandy » Fri Nov 10, 2017 3:56 pm

That does not make a lot of sense to me. Why are you executing additional travel commands if you don't want the robot to move? Calling travel etc. with immediate returns will not simply skip the move request, it will be started, if you then call some other movement request rather than waiting for the travel/rotate to complete then that will be aborted and a new movement started, but this will still result in all sort of move notifications, and pose updates which is almost certainly not a good thing to do. Why not just skip calling the move requests rather than messing around with changing immediate return?

Why do you need to use your own coordinate system? What is it about the navigator that does not work for you? If you are having problems with the navigator and coordinate systems, then perhaps you are also having problems with things like the pose provider. As I have already said the more you explain what it is you are doing and why, the more likely you will get useful answers.
leJOS news https://lejosnews.wordpress.com/

User avatar
RoboRobo
Novice
Posts: 36
Joined: Sat Jun 18, 2016 2:10 pm

Re: How to control movement?

Postby RoboRobo » Fri Nov 10, 2017 6:41 pm

gloomyandy,

you can find our discussions about troubles using navigator here: viewtopic.php?f=18&t=7528&start=30
My simple algo to calculate coordinates works well, it s logic is the same as Navigator's. But then may I ask a simple question: if I set a move travel(100), how can I cancel it at the midpoint in a "civilized" way?

User avatar
gloomyandy
leJOS Team Member
Posts: 5899
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: How to control movement?

Postby gloomyandy » Fri Nov 10, 2017 7:36 pm

Yes I remember you never did report back on what happens if you consistently use the pose provider that is built into the chassis rather then the OdometryPoseProvider. I still don't understand what problems you have had with the coordinate system and why you have to use your own?

As to how to correctly abort a travel or rotate call then you simply need to call stop, so something like....

Code: Select all

pilot.travel(dist, true);
while(pilot.isMoving())
{
    if (abortMove)
        plot.stop();
    Delay.msDelay(1);
}


abortMove is a boolean class member (which should be volatile) that can be set my another thread to abort the operation. You could potentially call stop directly from the other thread, but this is not a good idea from a threading point of view unless you are very sure that you understand what you are doing.
leJOS news https://lejosnews.wordpress.com/

User avatar
RoboRobo
Novice
Posts: 36
Joined: Sat Jun 18, 2016 2:10 pm

Re: How to control movement?

Postby RoboRobo » Fri Nov 10, 2017 8:02 pm

Great, thanks, I’ll try! I could try navigation using chassis, but as I remember somehow no one method did not work fine for me...

User avatar
RoboRobo
Novice
Posts: 36
Joined: Sat Jun 18, 2016 2:10 pm

Re: How to control movement?

Postby RoboRobo » Sat Nov 11, 2017 9:53 am

Well, I did that how you advised me, a robot stops really nicely! :) Also I added additional "if" condition to prevent repeatedly input from ultra sensor while obstacle is in front the robot. Thanks, now I can move forward!


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 1 guest