Example #1
0
        public NavigationManager()
        {
            movement = Movement.stop;
            monitor = new object();
            actualPosition = new Position();

            //TODO
            //Waiting for the magnetometer...
            Thread.Sleep(1500);
            initialHeading = this.MAG_Heading;

            contingency = new Contingency(left, right, this);
            //integration = new Timer(new TimerCallback(this.Integrate), new object(), GlobalVal.integrationPeriod * 10, GlobalVal.integrationPeriod);
        }
Example #2
0
 public void SetObject(Position position)
 {
     //map[position.x][position.y].isObject = true;
 }
Example #3
0
 public void setActualPosition(Position p)
 {
     this.actualPosition.x = p.x;
     this.actualPosition.y = p.y;
     this.actualPosition.angle = p.angle;
 }
Example #4
0
 public void SetMapped(Position position)
 {
     //map[position.x][position.y].mapped = true;
 }
Example #5
0
 public bool isMapped(Position position)
 {
     //return map[position.x][position.y].mapped;
     return false;
 }
Example #6
0
 /*public short calibrarZ(short cz)
  {
    return cz;
  }*/
 private Engine()
 {
     actualPosition = new Position();
 }
Example #7
0
 public void UpdatePosition(Position p)
 {
     Position _p = navigation.getActualPosition();
     Debug("Position: " + _p.x + " : " + _p.y + " : " + _p.angle + " | " + p.x + "  :" + p.y + " : " + p.angle);
     navigation.setActualPosition(p);
 }
Example #8
0
        public void DataReceived(byte[] buffer, int offset, int length, TransportAddress t)
        {
            byte[] tmpBuff = new byte[length];
            for (int i = 0; i < length; i++)
            {
                tmpBuff[i] = buffer[offset + i];
            }

            switch ((char)tmpBuff[0])
            {
                case 'f':
                    Engine.getInstance().ManualForward(ToShort(tmpBuff, 1));
                    break;
                case 'b':
                    Engine.getInstance().ManualBackward(ToShort(tmpBuff, 1));
                    break;
                case 'r':
                    Engine.getInstance().ManualRight();
                    break;
                case 'l':
                    Engine.getInstance().ManualLeft();
                    break;
                case 's':
                    Engine.getInstance().ManualStop();
                    break;
                case 'm':
                    Engine.getInstance().ManualMode();
                    break;
                case 'M':
                    Engine.getInstance().StopManualMode();
                    break;

                case 'V':
                    Engine.getInstance().ManualSpeed(ToShort(tmpBuff, 1));
                    break;
                case 'v':
                    Engine.getInstance().ManualTurningSpeed(ToShort(tmpBuff, 1));
                    break;

                case 'p':
                    int readen = 1;
                    int temp;
                    Position p = new Position();
                    double x = ToDouble(tmpBuff, readen, out temp);
                    readen += temp;
                    //Engine.getInstance().Debug("X: " + x.ToString());

                    double y = ToDouble(tmpBuff, readen, out temp);
                    readen += temp;

                    double angle = ToDouble(tmpBuff, readen, out temp);
                    readen += temp;

                    p.x = x;
                    p.y = y;
                    p.angle = angle;

                    Engine.getInstance().UpdatePosition(p);
                    break;
                case 'c':
                    short value = 0;
                    switch ((char)tmpBuff[1])
                    {
                        case 'x':
                            value = ToShort(tmpBuff, 2);
                            Engine.getInstance().calibrarX(value);
                            break;
                        case 'y':
                            value = ToShort(tmpBuff, 2);
                            Engine.getInstance().calibrarY(value);
                            break;
                    }
                    break;

            }
        }