Asked — Edited
Resolved Resolved by CochranRobotics!

Converting A String To Integer In Ez Scripting

I am using the plug in for the XV-11 Lidar. The output of the plug in an array in which each value is a string that represents the distance at the angle and the signal strength. To use this for control of the robot, I need numbers at these angles. The format is shown in the attached example. How do I parse and convert this in EZ Scripting into an integer?

In C there is the string.split command

https://msdn.microsoft.com/en-us/library/b873y76a(v=vs.110).aspx

and then the string to integer convert.

Is there a way to do this in the EZ scripting?

User-inserted image


ARC Pro

Upgrade to ARC Pro

With Synthiam ARC Pro, you're not just programming a robot; you're shaping the future of automation, one innovative idea at a time.

#25  

I just put the latest code out and updated the project.


      private void MainForm_Load(object sender, EventArgs e)
        {
            //button1.Enabled = false;
            
            loadConfig();

           // EZ_Builder.Scripting.VariableManager.CreateVariableArray("$LIDARDistance", 0, 360);
           // if (Convert.ToBoolean(_cf.STORAGE[ConfigDictionary.chkUseIntensity]))
           // { EZ_Builder.Scripting.VariableManager.CreateVariableArray("$LIDARIntinsity", 0, 360); }

            try {
                if (Convert.ToString(_cf.STORAGE[ConfigDictionary.comportname]).Length > 3)
                {
                    initializecomport();
                }
            }
            catch
            {
                MessageBox.Show("Select the COM port being used by the LIDAR on the config screen.");
            }
            backgroundWorker1_DoWork(null, null);
        }

       private void loadConfig()
        {
            drawline = Convert.ToBoolean(_cf.STORAGE[ConfigDictionary.DrawLines]);
            drawArea = panel1.CreateGraphics();
            string pc = Convert.ToString(_cf.STORAGE[ConfigDictionary.thePenColor]);
            string bc = Convert.ToString(_cf.STORAGE[ConfigDictionary.backgroundcolor]);
            Pen pointpen = new Pen(Color.FromName(pc));
            drawArea.Clear(Color.FromName(bc));
            drawArea.DrawRectangle(pointpen, panel1.Width / 2, panel1.Height / 2, 4, 4);
            drawArea.Dispose();

         private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            EZ_Builder.Scripting.VariableManager.CreateVariableArray("$LIDARDistance", 0, 360);
           if(Convert.ToBoolean(_cf.STORAGE[ConfigDictionary.chkUseIntensity]))
            {EZ_Builder.Scripting.VariableManager.CreateVariableArray("$LIDARIntensity", 0, 360); }
        }

      private void initializecomport()
        {
            try {
                _serialPort.BaudRate = _baudRate;
                _serialPort.DataBits = _dataBits;
                _serialPort.Handshake = _handshake;
                _serialPort.Parity = _parity;
                _serialPort.PortName = (string)_cf.STORAGE[ConfigDictionary.comportname];
                _serialPort.StopBits = _stopBits;
                _serialPort.ReadBufferSize = Convert.ToInt32(_cf.STORAGE[ConfigDictionary.BufferSizeValue]);
                _serialPort.DataReceived += new SerialDataReceivedEventHandler(_serialPort_DataReceived);
                _serialPort.Open();
                comportInitialized = true;
                //_cf = cf;
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                MessageBox.Show("COM port not initialized");
            }
        }

This is the portion that initializes the array(s) and also the comp port.

#26  

@David, mine also locks ARC up, yesterday was it working, the only this I changed today is updated the latest ARC. Now I can not get it working again.

#27  

I forgot to say, I loaded a new project when this happened, I also backup yesterdays plugin. What is funny is both my project's and new project have the latest ARC Version 2016.02.20.00

So with a new project and yesterdays plugin it still lockup. However, using my project and yesterdays plugin it works?

#28  

Okay, that would indicate that it is a config setting that isn't set by default. I wish I could duplicate the issue. I also downloaded the latest ARC to make sure it worked with the new version. I can't seem to get it to lockup. I do have an issue with my controller though. My new one should be here Monday so that I can do some testing and debugging.

#29  

I just checked your plugin date I am using and it was 2/18/1016 not yesterday, sorry about that. Thanks David.

#30  

@Mike and @DJ, I suspect that this release this morning will solve the issue you are seeing. Please let me know. I am hesitant to change the com port 3 default setting until I know if this works for you.

Thanks David

#31  

Morning David, it lets me configure the com port and then when I click start lidar it locks up ARC.

Thanks