Asked — Edited
Resolved Resolved by DJ Sures!

ARC Control Via Sdk

Is it possible to enable and disable for example the color tracking check box in the camera control in ARC via the SDK while conected via the telnet server?

Thanks


ARC Pro

Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

PRO
Synthiam
#1  

The EZ-SDK and ARC are different things. The ARC is a graphical interface to the EZ-SDK. The EZ-SDK is a collection of libraries and functions for programmers to create their own interface. For example, with EZ-SDK you can make your own ARC.

If you have a program that you would like to communicate to ARC - you can do so with commands sent over the selected TCP port. You will have to put the ARC Connection Server into Script Mode. You can do that by pressing the Config Button on the Connection Control.

The Script Mode will allow the incoming connections on the selected port. You can now send EZ-Script commands to the Script Mode Server's TCP Port.

For what you're asking - you can send the ControlCommand() syntax. Reference the EZ-Script manual to obtain the appropriate syntax for your question.

Hope that helps!

#2  

I enabled the TCP server and script mode is enabled and I identified the correct EZ-Script command to send. If I send it via just a normal telnet client the string works but via my code it does not.

I am pretty new to EZB and C# and haven't coded in ages.

Is the Method:EZ_B.TCPClient.WriteLine(System.String) method the correct method to use to send the string?

I can post the code if that would help.

Thanks

#3  

Correct me if I am wrong but looking at the control commands it seems like it is not possible (unless I missed something) to read an external variable value sent via the TCP port so it can be used in EZ-Script.

Thanks

United Kingdom
#4  

As DJ stated if you are using ARC you do not need to use the SDK. It's one or the other. ARC is, in basic terms, a GUI for the SDK but has it's limits to the pre-defined controls.

You can send and receive variables and commands through TCP, I have it set up on Jarvis to do so. Your other application can use all of the control commands or anything within EZ-Script. If you wanted to send a variable to ARC you just need to send the code

$x = variable

in whichever language you are using to transmit via TCP.

To send the other way (ARC to Application) switch it around so

variable = $x

Where "variable" is the external applications variable name and "$x" is the ARC variable.

You could also use HTTPGet to pull data from other applications, web pages and sites or execute web based applications.

#5  

First let me say thanks to both of you for your answers. I value your input.

What I am trying to do is this:

  1. Read a value into my own APP from another application (This is working)
  2. Send that value from my own APP using an EZ-SDK built-in method if possible to the TCP server and store it in a variable so I can use it inside EZ-Script.

Perhaps I need to phrase the question in a better way.

Is there a built in method in the SDK that I can use to send a Control string for example cc("Camera", CameraColorTrackingEnable) or $x = variable to the TCP server?

Thanks

PRO
Synthiam
#6  

Here's an example of setting and getting EZ-Script variables over the Script Interface. Also, I used a ControlCommand() to set the Face Tracking (notice the checkbox next to Face on the camera control)

User-inserted image

I will whip up a quick little C# demo for you on connecting to ARC via script interface and post it here. But, I have to have lunch first:)

#7  

@DJ Sures That would be awesome and thank you very much. Your help is appreciated.

My App can wait, go have some lunch:)

I knew my connection to the TCP server was working using the EZ_B.TCPClient.Connect method to connect since I could read the response "ARC v2013.12.30.00 on TTY0" back into a c# variable in my app using the TCPCLient class and Networkstream method and I could see the connection come into the ARC debug window from the app.

I think my issue is how I am trying to send the string to the TCP server. An example would help very much indeed.

#9  

@DJ Sures This really helps fill in the blanks and will give me what I need to proceed.

Thanks so much.

PRO
Synthiam
#10  

No problem:) I separated some of the functionality into separate methods for you to get an idea of what is going on...

Firstly, I use the System.Net.Sockets.TcpClient instead of the EZ_B one. This is because the EZ_B one is made specifically for Shell prompts. The System.Net.Sockets.TcpClient is much more versatile for your needs.


    TcpClient _tcpClient = null;

In the connection method, I added code to allow you to specify the connection timeout. Without this code, simply using TcpClient.Connect() will timeout for 10 seconds or something ridiculous. My example allows you to specify the Timeout in the TimeSpan.FromSeconds()

Also, the TCP NoDelay will increase the transfer speed. Without NoDelay, the tcp packets will have a minimum response speed of something like 20ms - which is way too slow:)


      _tcpClient = new TcpClient();

      IAsyncResult ar = _tcpClient.BeginConnect(tbAddress.Text, port, null, null);

      System.Threading.WaitHandle wh = ar.AsyncWaitHandle;

      try {

        if (!ar.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(3), false)) {

          _tcpClient.Close();

          throw new TimeoutException();
        }

        _tcpClient.EndConnect(ar);
      } finally {

        wh.Close();
      }

      _tcpClient.NoDelay = true;
      _tcpClient.ReceiveTimeout = 2000;
      _tcpClient.SendTimeout = 2000;

Send Command will send the command and send the response to the Debug Log window.


    /// <summary>
    /// Send command string to the ARC connection.
    /// The input buffer will be cleared, then it will send the command, finally it reads the response.
    /// There is always a response from the ARC Script Interface:
    ///  - If you are expecting to receive data, the response will be the received data.
    ///  - If you are not expecting to receive data, the response will be "OK"
    /// </summary>
    private void sendCommand(string cmd) {

      try {

        Log("Sending: {0}", cmd);

        clearInputBuffer();

        _tcpClient.Client.Send(System.Text.Encoding.ASCII.GetBytes(cmd + Environment.NewLine));

        Log(readResponseLine());
      } catch (Exception ex) {

        Log("Command Error: {0}", ex);

        disconnect();
      }
    }

The SendCommand() uses ClearInputBuffer() and ReadReponseLine(). The details are specified in their respective summary comments.


    /// <summary>
    /// Clears any data in the tcp incoming buffer by reading the buffer into an empty byte array.
    /// </summary>
    private void clearInputBuffer() {

      if (_tcpClient.Available > 0)
        _tcpClient.GetStream().Read(new byte[_tcpClient.Available], 0, _tcpClient.Available);
    }

    /// <summary>
    /// Blocks and waits for a string of data to be sent. The string is terminated with a \r\n
    /// </summary>
    private string readResponseLine() {

      string str = string.Empty;

      do {

        byte [] tmpBuffer = new byte[1024];

        _tcpClient.GetStream().Read(tmpBuffer, 0, tmpBuffer.Length);

        str += System.Text.Encoding.ASCII.GetString(tmpBuffer);
      } while (!str.Contains(Environment.NewLine));

      // Return only the first line if multiple lines were received

      return str.Substring(0, str.IndexOf(Environment.NewLine));
    }

Finally, to send a command - simply send the EZ-Script syntax and voila:)


    private void btnSetX_Click(object sender, EventArgs e) {

      sendCommand(string.Format("$x = {0}", tbX.Text));
    }

#11  

Let me just say that the quality and detail of your response blew away my expectations. If this is the passion you put into everything the revolution has a very rosy feature.

Based on this interaction I firmly believe I made the right choice in going with EZ-Robot in my feature robotic projects.

The fact that the EZB method is made specifically for Shell prompts at least explains why my send code did not work but my socket read did.

Thanks again.

#12  

By the way.

The reason for all of this is that I am going to try and write an application that sits between the roborealm AVM navigation module and ARC. I will pull values from the module, provide them to ARC and use EZ-Script to make the robot do the movements. That way I might be able to have the robot learn a path via the webcam and then navigate it again autonomously.

Should be a nice learning experience. Now I only need the EZ-B:)

#13  

@JD Sures

Just so you know your time spent on providing the information was not wasted I have successfully integrated and adjusted your code examples to pull the information I needed from Roborealm into ARC for use in EZ-Script.

Thanks again for your help

PRO
Synthiam
#14  

Really? That's excellent! I'm looking forward to seeing it:D Any chance you could share a video of your project when you're ready?

#15  

@DJ Sures At this point I can read the variable values from roborealm via their XML based API and I can get the variables into ARC for use in EZ-Script.

The next step requires me to having the EZB since I need to find a way to get the video from the robot's camera streamed into roborealm so the AVM module can do its job on the video stream and report back the movement variables.

Assuming I can get the whole thing working I have no issue posting what I did but don't want to get anyone's hopes up until I actually have the robot navigate using roborealm AVM navigate mode.

If you take a look at roborealm AVM you will see what it is I am trying to do especially the navigate mode.

Plus it's a nice way to learn c# even if the whole idea falls flat on its face in the end:)

#16  

Another project I was thinking of using your code examples for is having six doing a dance and having it send variables to another arduino based robot I have using xbee's and coordinating their dancing.