Ez Line Chart icon Ez Line Chart 4-series historical line chart to log and compare robot sensor values over time with customizable titles, colors, time axis and EZ-Script control Try it →
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

ARC Pro is your passport to a world of endless possibilities in robot programming, waiting for you to explore.

Author Avatar
Australia
#9  

hi DJ it would not do a right()?

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#10  

Strange. Works in my test when I wrote it.

Author Avatar
Australia
#11  

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

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#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

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#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

Author Avatar
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);
      }
    }
  }
}