Asked — Edited
Resolved Resolved by DJ Sures!

Sonar For Universalbot

Hello,

First a little background: I have to do a senior project for my class. The thing is it had to use the raspberry pi. So I chose to use the raspberry pi and the Ez-Robot for my project. I have windows IOT on my raspberry pi and have the universalbot sdk/project. I have looked through the code and didn't find a class for the sonar.

My question is How would i get values from the sonar using the universalbot application? And do I have to do anything special in order to recieve the value from there? Any help would be appreciated. Thank YOU.


ARC Pro

Upgrade to ARC Pro

ARC Pro is your gateway to a community of like-minded robot enthusiasts and professionals, all united by a passion for advanced robot programming.

#1  

Hopefully DJ or one of our other programmers will answer, but instead of looking for Sonar, look for Ping sensor or Ultra-sonic sensor. The ARC Sonar control is a combination of the ping sensor, and a servo sweeping back and forth. You would need to program that functionality yourself if not using ARC, but the servo controls are certainly there, and I expect the Ping function is there and you just missed it by searching for the wrong term.

Alan

PRO
Synthiam
#2  

The distance sensor is in the ezb.hc_sr04 class

Also, you may find the mono library real good as well. The mono library does include some additional features, such as Auto Position that the uwp does not support.

PRO
USA
#3  

if you are using windows 10 IOT on your RPI2 or RPI3, only pcl assemblies targeting the .NETCore will be allowed in a UWP Project, you can't use mono library.

if you change to Linux (e.g. Raspbian), you can use the Linux MONO framework to run your application with EZB Mono SDK.

@DJ:

One quick question Mono SDK, is not compatible with the Xamarian development (Android or IOS). I know you have your priorities but if you some time using your current base code and through PCL assemblies you can create a single SDK targeting: UWP Xamarin (Android & IOS & Windows Store) Linux Mono.

Let me know if you have plans/date for that.

PRO
Synthiam
#4  

It is compatible with xamarin development - it's what the mobile app is built with. what issuse are you having?

PRO
USA
#5  
  1. add MONO ez_b.dll to the xamarin Droid
  2. Project Build
  3. Error

Quote:

Severity Code Description Project File Line Suppression State Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile? File name: 'System.Drawing.dll' at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel) at Xamarin.Android.Tasks.ResolveAssemblies.Execute() EZClient.Droid

I'm not using System.Drawing anywhere (does not exist in the Android profile).

PRO
Synthiam
#6  

Add the nuget packages for Shim

With xamarin, you will spend a lot of time in nuget installing supporting libraries. Xamarin is a great compiler but their support and implementation is absolutely terrible. Every release breaks your code. It's an absolute nightmare to deal with.

PRO
USA
#7  

does not work, i tried Shim & Shim.Image

Quote:

System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

the PublicKeyToken is used by Microsoft, unless you recompile the EZ_B.dll with a reference to Shim.*.dlls, i don't think you can force the binding.

Are you using Shim.Imaging ? Their website mentions a commercial license, I'm not sure what is being used from System.Drawing to justify using their (Shim.Imaging)...

PRO
Synthiam
#8  

No I use the system.drawing that's included with android and iOS xamarin.

Let me remove the requirement for you- or why not just use uwp library source from the software link?

PRO
USA
#9  

@DJ,

The UWP code does not compile, the main culprit is a TcpClient class.

i presume you coded for a replacement for the Net.Sockets.TcpClient not available when using UWP Apps, it uses SocketStream.

The problem is the UWP TcpClient does not have the same signature methods, unless you rewrite the calling code.

don't stress with that, when you have a break or an opportunity, take a look to the base codes, and if you find a solution let me know.

PRO
Synthiam
#10  

tcpclient is part of the uwp package. it's included in the source. User-inserted image

PRO
USA
#11  

I know but does not compile unless is a UWP project.

PRO
Synthiam
#12  

I guess i'm having a hard time understanding what you're asking. On the first page you asked for UWP and XAMARIN but now you're saying you don't want UWP?

If you can clarify it would be super useful to assist further

PRO
Synthiam
#13  

I removed the System.Drawing reference in the latest mono package. Get it from the Software->Mono link at the top menu of this website.

#14  

Thank you for the prompt response. I have decided to go with the mono sdk on raspian jessie. Though after installing the complete mono package , and tring the test file I Get this error:


test.cs(8,17): error CS1729: The type `EZ_B.EZB' does not contain a constructor that takes `0' arguments
/home/pi/EZTest/EZ_B.dll (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings

Any ideas on what might have caused it?

PRO
Synthiam
#15  

Without posting the code that you are using, it's impossible to diagnose. Please provide the code that you are attempting to compile. Also, the recommended distribution for raspberry pi is Debian, as stated in the mono page.

Mono is an open source project that has no real owner - or at least no one accountable for their mess ups. You will find that working with open source software will result in a nitemare of headaches:) but we'll get you rock'n.

Post the code and we'll start from there

#16  

The code I am using is exactly from the download page of mono-sdk. I also ran the test on the included example file and it gave the same error. It is occurring when it is creating a new instance of the ez-robot.


using System;
using EZ_B;
   
public class HelloWorld {
 
    static EZB _ezb;
 
    public static void Main() {
 
        _ezb = new EZB();  ///The Problem is here
 
        Console.WriteLine("Connecting to EZ-B v4...");
 
        _ezb.Connect("192.168.1.1");
 
        if (!_ezb.IsConnected) {
 
            Console.WriteLine("Unable to connect to EZ-B v4");
 
            return;
        }
 
        Console.WriteLine("Hello World, I am moving servo d0 to position 90!");
  
        _ezb.Servo.SetServoPosition(Servo.ServoPortEnum.D0, 90);
 
        _ezb.Disconnect();
    }
}


#17  

@dj-sures , is it possible that when I create an Ez-Robot object it needs an argument.

PRO
Synthiam
#18  

Oh right, the example needs updating. The ezb creator needs a string argument that is the name for the object. It's any name you wish to give it. This is incase you have many Ezbs and wish to display names to the user associated with each instance.

Check the ez_b.xml file included in the mono package for syntax parameters. The xml file should always be the first place for you to look for syntax assistance.

Here's the ezb create from the xml...

Quote:

<member name="M:EZ_B.EZB.#ctor(System.String)"> <summary> Create an instance of the EZCommunicator and assign unique name </summary>

I'm on my phone so it's tough to write code but the syntax would be something like


EZB ezb = new EZB(&quot;my ezb&quot;);

I'll update the example later today or tonight.

#19  

THank you so much for your help

PRO
Synthiam
#20  

Great to hear it's working for you Anthony! Looking forward to hearing more about your project as it progresses

#21  

Hello! I know this was posted 2 years ago and a solution was found I wanted to give a little heads up that the mono.sdk example code hasn't been updated yet!

For anyone who hasn't found a solution here's what I changed my code to:


using System;
using EZ_B;
  
public class HelloWorld {


    public static void Main() {

        EZB ezb = new EZB(&quot;my ezb&quot;);

        Console.WriteLine(&quot;Connecting to EZ-B v4...&quot;);

        ezb.Connect(&quot;192.168.1.1&quot;);

        if (!ezb.IsConnected) {

            Console.WriteLine(&quot;Unable to connect to EZ-B v4&quot;);

            return;
        }

        Console.WriteLine(&quot;Hello World, I am moving servo d0 to position 90!&quot;);
 
        ezb.Servo.SetServoPosition(Servo.ServoPortEnum.D0, 90);

        ezb.Disconnect();
    }
}