Jump to content

Recommended Posts

Posted
  On 11/24/2018 at 9:58 PM, MajorAlvega said:

And for visual browsing the file system I think WinSCP does that, it's like Filezilla but uses SSH instead of FTP.

Expand  

Sweet! That's working like a charm.

I know this will be a journey with a lot of testing, trial and error and asking for help, but I really do like the setup so far. I love that I can access my brick and use it as a real client.

  On 11/24/2018 at 10:15 PM, MajorAlvega said:

You will have to wait for @dwalton76 to answer... I'm just a googler wise-guy, not a real programmer :)

Expand  

Hehe no problem. Your help is appreciated and you just fixed two of my issues.

I would love to be able to consume my own Web Api. That will open up lots of cool options.

  On 11/24/2018 at 10:10 PM, Jim said:

Another question; is it possible to use the requests class in the EV3 bricks?

Expand  

I do see a lot on info on how to consume a Web Api, so that won't be a problem, as long as I can get the requests library available on the brick. 

@dwalton76 any help on that would be appreciated :sweet:

Posted
  On 11/25/2018 at 1:32 AM, dwalton76 said:

Try “sudo pip3 install requests” to get that module installed 

Expand  

Thanks! That almost did the trick. Had to install pip3 first.

So I ran this command to update the packages:

sudo apt-get update

And then this command to get pip3. This did take quite a while (about 15-20 minutes). I was under the impression that the entire python3 sdk/runtime was installed on my brick again.

sudo apt-get install python3-pip

And then this command to install the requests package

sudo pip3 install requests

Working like a charm! :wub:

Now is probably the right time to start a generic Python course. I am getting really enthusiastic about Pyhton. And about Linux...for the first time in my life :laugh:

I have just been able to call my .NET Core Web Api from my EV3 brick!! :wub:

giphy.gif

Posted
  On 11/24/2018 at 9:26 PM, Jim said:

I have edited the hostname file in etc with sudoedit from ev3dev to EV3A, but it still shows ev3dev in Putty and in VSCode. Any idea why?

Expand  

This problem has been solved too. Of course, a simple reboot did the trick.

Posted

I have found that one. I even listed it in the first post. Thanks :thumbup: 

I will give some feedback.

Posted

This is a matter of opinion, but `sudo pip3 install ...` is a good way to break things. Eventually, you will install a package that breaks something else that is used by the system. It is probably not so much a problem on ev3dev since there isn't much, if anything, installed by default that can be broken this way. But I think it is better to not get into this habit in the first place. (I learned this the hard way with my desktop.)

Since ev3dev is based on Debian, most popular Python packages are already available as Debian packages. So, `sudo apt update && sudo apt install python3-requests` would install the Debian version of this library. This is also really good for Python packages that include a binary component. The Debian package will contain a pre-compiled binary whereas compiling on a RPi can be tricky to install all of the correct dependencies and the EV3 has the same issues plus it is 10x slower.

If there is a Python package you want to install that does not already have a Debian package, then it is still better to install it with pip3 as a user package rather than installing it system-wide. To do this, just don't put `sudo` in front of `pip3`. Then packages will be installed to the local user directory `~/.local/lib/python3.5/site-packages/` instead of the system-wide python packages directory.

Posted

Hi David,

First of all, welcome to EB.

Second, thanks for the tip. I was wondering about installing packages and how it would effect the brick and the solution. Your insights are very useful. I am new to Python, but I do have .Net experience, so I know how (nuget) packages can make or break a solution, when not handled correctly.

I am in the midst of flashing two new Micro SD Cards for two of my bricks, so I will try to use the 'sudo apt' commands and see how it goes.

Posted

Fascinating topic!

I work with Python on a daily basis but within the Windows ecosystem, so not that familiar with Linux in general.

Why would you want your EV3 to talk to a .NET API? Would you store the commands within the API and then create something that consumes the JSON in a flexible manner so you can just generate the commands dynamically?

Posted
  On 11/27/2018 at 6:41 PM, Basiliscus said:

Why would you want your EV3 to talk to a .NET API?

Expand  

Because I can! :laugh:

Actually, I am/was working on a .Net Core Web Api for serving high scores for my mobile games (another hobby I have). So, I wondered if I could let my bots communicate with the Api. If I can send and retrieve info to and from an Api, I can do a lot of stuff. But it is mainly a proof of concept for now. 

One thing would be to enter commands online, which the robot will polll and execute. Even better would be to be able to send commands directly from a website (or mobile phone) to the device, via Websockets or something similar. Basically, I am trying out different communication scenarios.

  On 11/27/2018 at 4:36 PM, David Lechner said:

So, `sudo apt update && sudo apt install python3-requests` would install the Debian version of this library.

Expand  

Works like a charm! Thanks

  On 11/27/2018 at 6:41 PM, Basiliscus said:

I work with Python on a daily basis but within the Windows ecosystem, so not that familiar with Linux in general.

Expand  

I am a Windows guy myself and I have never touched Python, until last week. I am totally in love with the EV3, VS Code and Python combo. 

Next stop is socket communication, so two bricks communicating via a LAN.

Posted
  On 11/27/2018 at 7:32 PM, Jim said:

Because I can! :laugh:

Actually, I am/was working on a .Net Core Web Api for serving high scores for my mobile games (another hobby I have). So, I wondered if I could let my bots communicate with the Api. If I can send and retrieve info to and from an Api, I can do a lot of stuff. But it is mainly a proof of concept for now. 

One thing would be to enter commands online, which the robot will polll and execute. Even better would be to be able to send commands directly from a website (or mobile phone) to the device, via Websockets or something similar. Basically, I am trying out different communication scenarios.

****

I am a Windows guy myself and I have never touched Python, until last week. I am totally in love with the EV3, VS Code and Python combo. 

Next stop is socket communication, so two bricks communicating via a LAN.

Expand  

Ha! Yeah I totally get the "because I can attitude", my current side project is building a website served on my home LAN which will allow my wife to undertake searches on all of our photos - it will do face and image content recognition (I'm a data scientist) so she doesn't ask "Remember that photo of our daughter on a slide", she can search the keywords and it will find the images! I'll share the GitHub repository later when it's a bit more advanced.

Rather than using websockets you'd be better off using MQTT - set up a broker and make the web app send messages to the broker and the EV3 a subscriber. The architecture handles packet loss and general web instability a lot better and it's used a lot in IOT applications.

Whatever you do, good luck!

Posted

This is exactly why I created this forum. A place for people doing interesting stuff...because we can :wink: 

Thanks for the MQTT pointer. These are the things that are really helping me out. I appreciate that a lot.

Please stick around :classic: 

In the future I would like to do face recognition with a camera on my robot. Maybe you have ideas for that too.

Posted
  On 11/27/2018 at 8:37 PM, Jim said:

This is exactly why I created this forum. A place for people doing interesting stuff...because we can :wink: 

Thanks for the MQTT pointer. These are the things that are really helping me out. I appreciate that a lot.

Please stick around :classic: 

In the future I would like to do face recognition with a camera on my robot. Maybe you have ideas for that too.

Expand  

No worries!

I will stick around but I probably won't be in this forum every day so feel free to @ me if you want me to look at something (or send me a PM). I've followed you on Flickr and you're welcome to browse my GitHub - the "photos-categoriser" project is the one I was talking about earlier. I haven't done much on it in ages.

Will be interested to see how this project progresses!

Posted
  On 11/28/2018 at 9:04 AM, Basiliscus said:

No worries!

I will stick around but I probably won't be in this forum every day so feel free to @ me if you want me to look at something (or send me a PM). I've followed you on Flickr and you're welcome to browse my GitHub - the "photos-categoriser" project is the one I was talking about earlier. I haven't done much on it in ages.

Will be interested to see how this project progresses!

Expand  

Cool. No worries about not being around every day. There are nine Technic sets underway for review, so I will take a detour (from Robotics) the next couple of weeks anyway. 

I will surely take a look at your Git repository and check out your project. And I know where to find you :wink:

Edit: some interesting stuff on your Git page :thumbup:

Posted
  On 11/28/2018 at 3:46 PM, Jim said:

Cool. No worries about not being around every day. There are nine Technic sets underway for review, so I will take a detour (from Robotics) the next couple of weeks anyway. 

I will surely take a look at your Git repository and check out your project. And I know where to find you :wink:

Edit: some interesting stuff on your Git page :thumbup:

Expand  

Thanks! I moved jobs in April 2018 and prior to that I made a bit of an effort to make some things available to show during interviews.

If you have a GitHub account feel free to follow me or share it here so I can see all the code.

Best of luck!

Posted
  On 11/29/2018 at 8:44 AM, Basiliscus said:

Thanks! I moved jobs in April 2018 and prior to that I made a bit of an effort to make some things available to show during interviews.

If you have a GitHub account feel free to follow me or share it here so I can see all the code.

Best of luck!

Expand  

Having a portfolio with interesting projects is always helpful. Wise choice.

I use Azure DevOps with Git. 

Posted
  On 11/27/2018 at 8:33 PM, Basiliscus said:

Rather than using websockets you'd be better off using MQTT - set up a broker and make the web app send messages to the broker and the EV3 a subscriber. The architecture handles packet loss and general web instability a lot better and it's used a lot in IOT applications.

Expand  

Have you used Mosquitto for MQTT? I have been playing around with it, but I can't get my first message accross.

O never mind....I just sent my first message. Not sure why it is working :laugh:

I was going through these instructions:

https://www.instructables.com/id/Installing-MQTT-BrokerMosquitto-on-Raspberry-Pi/

 

When I use this command:

mosquitto_pub -h test.mosquitto.org -t newtopic/test -m 'Hello'

I sometimes get the error that -m is an invalid option. And sometimes it is working. I had a feeling it has something to do with copy-paste from the interwebs, because the behavior is erratic. But now a command that previously failed is also working. Strange.

Posted

Hmm seems strange that the error is occuring intermittently! That's the worst type of error to debug. To me I'd be pointing the finger at the broker in that case.

Where are you running the broker? In Azure? Despite recommending it I've never actually used MQTT - ironically given your skillset I've only used the less lightweight AMQP protocol via Event Hubs in Azure. I think RabbitMQ might be a shout if you are struggling with what you have now.

I'm off work until Wednesday but I could spare some time then to check for you? I don't have an EV3 module or a Raspberry Pi though so I'd be working blind.

Hope that helps!

Posted

test.mosquitto.org may fail sometimes, they don't offer SLA's. But I really never had problems, perhaps you are using topics with spaces and missing the quotes?

you can also use your own mosquitto broker (laptop or even ev3dev itself, is very light). I use on my laptop, this way don't need to ask my networking team to open MQTT port on the corporate firewall.

paho-mqtt is good if you want to use python for MQTT - I've been using mostly bash scripts so mosquitto_pub and mosquitto_sub are enough but when things get more complicated and bash isn't enough I use paho-mqtt (not very often... I'm still learning python).

Posted

I was starting with my own broker on EV3, but I got some permission errors. So I changed to test.mosquitto.org which did work....sort of.

  On 12/3/2018 at 12:49 AM, MajorAlvega said:

test.mosquitto.org may fail sometimes, they don't offer SLA's. But I really never had problems, perhaps you are using topics with spaces and missing the quotes?

Expand  

I tried every variant hehe.

But no worries guys. Yesterday was my first deep dive into MQTT, so I need to learn the ropes. I will do some more testing and share my experience.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...