Move foot bot to coordinates

Requests regarding how to set up experiments in ARGoS.
ahyoussef
Posts: 13
Joined: Sat Sep 03, 2016 3:15 pm

Move foot bot to coordinates

Postby ahyoussef » Mon Oct 31, 2016 12:36 am

Dears,

This sounds very naive and trivial, but, im honestly having trouble making a footbot move along a vector, in other words, i have the robot location based on

Code: Select all

CVector3 position = m_pcPositioningS->GetReading().Position;
and i want to move it towards a specific point

Code: Select all

CVector2 target(12,8);
so i basically calculate the displacement vector via

Code: Select all

CVector2 diff (target - position)
and use the SetWheelSpeedFromVector and pass the diff vector to it (from the foraging example)

Code: Select all

SetWheelSpeedsFromVector(diff)
however, this only resulted that the robots are rotating around their z-axis and nothing is happening.

so i thought that i should be adding this diff vector to the current location could work, and couple of robots actually moved towards the target, others went in other ways.

Code: Select all

SetWheelSpeedsFromVector(diff + position);
this made me think of angles and signs, so i used the following

Code: Select all

CQuaternion q = m_pcPositioningS->GetReading().Orientation; CRadians cZAngle, cYAngle, cXAngle; q.ToEulerAngles(cZAngle, cYAngle, cXAngle); Real newX = position.GetX() + diff.GetX() * cos(cZAngle); Real newY = position.GetY() + diff.GetY() * sin(CZAngle); SetWheelSpeedsFromVector(CVector2(newX, newY);
still the same thing, few robots move towards the target and rest in another direction.

so my question is, how can i make them all move towards a specific location?

pincy
Site Admin
Posts: 632
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: Move foot bot to coordinates

Postby pincy » Wed Nov 02, 2016 5:48 pm

Hi ahyoussef,

Say the target position is in the variable target and your current pose is in pos and orient, as follows:

Code: Select all

CVector2 target; // given by you CVector2 pos; // given by positioning sensor CRadians orient; // given by positioning sensor
All of these variables are expressed in world coordinates. But the robot needs to move in its local reference frame. The transformation is:

Code: Select all

CVector2 me2target(target - pos); me2target.Rotate(-orient);
Now me2target contains the vector you want:

Code: Select all

SetWheelSpeedsFromVector(me2target);
Cheers,
Carlo
I made ARGoS.

ahyoussef
Posts: 13
Joined: Sat Sep 03, 2016 3:15 pm

Re: Move foot bot to coordinates

Postby ahyoussef » Sun Nov 06, 2016 9:09 pm

Professor Carlo,
You are always helpful and always supportive, thank you so much.

it finally worked that the robots are moving "obeying" what im telling them to goto :D the orientation was the problem, i didnt re-orient the robots so everyone moved to it's direction alone, giving a semi random motion.


Return to “How to... ?”