Australia
Asked — Edited

Getping

hi all I am writing my own radar script

how do i use the value return by getping(d13,d12) e.g. :loop tr if getping(d13,d12) < 20 then Right(200) goto(tr) else stop script and exit


ARC Pro

Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

Australia
#9  

hi DJ it would not do a right()?

PRO
Synthiam
#10  

Strange. Works in my test when I wrote it.

Australia
#11  

hi DJ i'll play with the timing of the scan etc.

PRO
Synthiam
#13  

Ah you know what? Maybe don't have it move from 10 to 80 because that might be what's happening. Have it move from 10 to 40. The. 40 to 80. Then 80 to 40. Then 40 to 10.

Repeat

PRO
Synthiam
#14  

Also, if you get the latest ARC... There is a C# example for a radar control. Look under File -> Examples -> Script C Radar Control

Australia
#15  

hi DJ Thanks i did a little mod:)

  1. it move forward after turning
  2. scan rate is faster
  3. it works

using System;
using System.IO;
using System.Windows.Forms;
using EZ_B;

namespace VName {

  public class VClass {

    public void Main(EZB ezb0, EZB ezb1, EZB ezb2, EZB ezb3, EZB ezb4) {

      bool dir     = true;
      bool weMoved = false;

      ezb0.Servo.SetServoPosition(Servo.ServoPortEnum.D5, 10);
      
      while (true) {
      
        int servoPos = ezb0.Servo.GetServoPosition(Servo.ServoPortEnum.D5);
        int distance = ezb0.HC_SR04.GetValue(Digital.DigitalPortEnum.D0, Digital.DigitalPortEnum.D1);
 
        if (distance  40)
            ezb0.Movement.GoRight();
          else if (servoPos  80)
            dir = false;
        
          if (servoPos < 10)
            dir = true;

          ezb0.Servo.SetServoPosition(Servo.ServoPortEnum.D5, servoPos);
        }

        System.Threading.Thread.Sleep(250);
      }
    }
  }
}