Cloud robotics demo code (now with actual code and links to BBC and FT)

The more technical aspects of Spirit, and carry-over discussion from Kickstarter updates.
sm7tix
Posts: 31
Joined: Sat Oct 28, 2017 4:21 pm

Re: Cloud robotics demo code (now with actual code!!)

Postby sm7tix » Fri Mar 23, 2018 12:03 am

Fixed y-axis on volt between 3 and 4 volts.

Code: Select all

p8 = win.addPlot(colspan=3, title="Battery Voltage (volts)")
p8.setYRange(3, 4, padding=0)
curve12 = p8.plot(data12)

Kind regards

Stefan / SM7TIX

headamage
Posts: 29
Joined: Mon Dec 04, 2017 5:27 pm

Re: Cloud robotics demo code (now with actual code!!)

Postby headamage » Fri Mar 23, 2018 9:43 am

very nice. Thanks.
Does the manual control work fine for you?

sm7tix
Posts: 31
Joined: Sat Oct 28, 2017 4:21 pm

Re: Cloud robotics demo code (now with actual code!!)

Postby sm7tix » Fri Mar 23, 2018 12:33 pm

Hi
Yes I think it works very good. One of my wheel servos are a little slower then the other so I can't drive straight. This I think i can fix some day.
The only thing that is not so good is that it take all keyboard input from all consoles. If i leave manual on and got to another ssh session it keep on feeling the keystrokes and the rover runs around when i type. Miner issue because when you drive you drive and do other things.
Kind regards

Stefan / SM7TIX

headamage
Posts: 29
Joined: Mon Dec 04, 2017 5:27 pm

Re: Cloud robotics demo code (now with actual code!!)

Postby headamage » Fri Mar 23, 2018 10:32 pm

:D :D :D

yes i have the same problem with manual control but that is inherent to the way i chose to implement it. The alternative would be to use some kind of game controller on usb. I don't have one so it isn't an option for me.

about the motors not running at the same speed, just go in the code and adjust one to run slower than the other until you find that it goes straight. Do it for the methods that control forward and backward movement.
That's how I solved my problem. Those motors are just dc so they are never going to run perfectly in sync and manufacturing inconsistencies will result in slightly different speeds for a given voltage.

sm7tix
Posts: 31
Joined: Sat Oct 28, 2017 4:21 pm

Re: Cloud robotics demo code (now with actual code!!)

Postby sm7tix » Sat Mar 24, 2018 6:47 pm

Ok! I will adjust the code.
Qustion: If i light up some lights from the arduino script, will it crash sd card also?
What name do i use to access the chirp in python?
Kind regards

Stefan / SM7TIX

headamage
Posts: 29
Joined: Mon Dec 04, 2017 5:27 pm

Re: Cloud robotics demo code (now with actual code!!)

Postby headamage » Sat Mar 24, 2018 9:59 pm

chirp does not exist in python yet. from arduino you can handle the pixels without affecting the pi.

sm7tix
Posts: 31
Joined: Sat Oct 28, 2017 4:21 pm

Re: Cloud robotics demo code (now with actual code!!)

Postby sm7tix » Sat Mar 24, 2018 10:17 pm

I solved the pixel thing!
I read this page
[url]
https://tutorials-raspberrypi.com/conne ... ed-strips/
[/url]
and made this code

Code: Select all

#!/usr/bin/env python
# NeoPixel library strandtest example
# Author: Tony DiCola (tony@tonydicola.com)
#
# Direct port of the Arduino NeoPixel library strandtest example.  Showcases
# various animations on a strip of NeoPixels.

import time
from neopixel import *
import argparse

# LED strip configuration:
LED_COUNT      = 27     # Number of LED pixels.
LED_PIN        = 18      # GPIO pin connected to the pixels (18 uses PWM!).
#LED_PIN        = 10      # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
LED_DMA        = 10      # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 10     # Set to 0 for darkest and 255 for brightest
LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL    = 0       # set to '1' for GPIOs 13, 19, 41, 45 or 53

def colorWipe(strip, color, wait_ms=50):
    """Wipe color across display a pixel at a time."""
    for i in range(strip.numPixels()):
        strip.setPixelColor(i, color)
        strip.show()
        time.sleep(wait_ms/1000.0)
 
def theaterChase(strip, color, wait_ms=50, iterations=10):
    """Movie theater light style chaser animation."""
    for j in range(iterations):
        for q in range(3):
            for i in range(0, strip.numPixels(), 3):
                strip.setPixelColor(i+q, color)
            strip.show()
            time.sleep(wait_ms/1000.0)
            for i in range(0, strip.numPixels(), 3):
                strip.setPixelColor(i+q, 0)
 
def wheel(pos):
    """Generate rainbow colors across 0-255 positions."""
    if pos < 85:
        return Color(pos * 3, 255 - pos * 3, 0)
    elif pos < 170:
        pos -= 85
        return Color(255 - pos * 3, 0, pos * 3)
    else:
        pos -= 170
        return Color(0, pos * 3, 255 - pos * 3)
 
def rainbow(strip, wait_ms=20, iterations=1):
    """Draw rainbow that fades across all pixels at once."""
    for j in range(256*iterations):
        for i in range(strip.numPixels()):
            strip.setPixelColor(i, wheel((i+j) & 255))
        strip.show()
        time.sleep(wait_ms/1000.0)
 
def rainbowCycle(strip, wait_ms=20, iterations=5):
    """Draw rainbow that uniformly distributes itself across all pixels."""
    for j in range(256*iterations):
        for i in range(strip.numPixels()):
            strip.setPixelColor(i, wheel((int(i * 256 / strip.numPixels()) + j) & 255))
        strip.show()
        time.sleep(wait_ms/1000.0)
 
def theaterChaseRainbow(strip, wait_ms=50):
    """Rainbow movie theater light style chaser animation."""
    for j in range(256):
        for q in range(3):
            for i in range(0, strip.numPixels(), 3):
                strip.setPixelColor(i+q, wheel((i+j) % 255))
            strip.show()
            time.sleep(wait_ms/1000.0)
            for i in range(0, strip.numPixels(), 3):
                strip.setPixelColor(i+q, 0)


# Create NeoPixel object with appropriate configuration.
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
# Intialize the library (must be called once before other functions).
strip.begin()

strip.setPixelColor(3, Color(255,0,0))
strip.setPixelColor(4, Color(255,0,0))
strip.setPixelColor(8, Color(255,0,0))
strip.setPixelColor(9, Color(255,0,0))
strip.setPixelColor(10, Color(255,0,0))
strip.setPixelColor(14, Color(255,0,0))
strip.setPixelColor(15, Color(0,255,0))
strip.setPixelColor(16, Color(0,255,0))
strip.setPixelColor(20, Color(0,255,0))
strip.setPixelColor(21, Color(0,255,0))
strip.setPixelColor(22, Color(0,255,0))
strip.setPixelColor(26, Color(0,255,0))
strip.show()

and run it with sudo python <script name>
I have not figured out how to run it without sudo yet.
Kind regards

Stefan / SM7TIX

User avatar
TomTheWhittler
Posts: 29
Joined: Wed Sep 13, 2017 5:04 am

Re: Cloud robotics demo code (now with actual code!!)

Postby TomTheWhittler » Mon Apr 02, 2018 1:22 am

headamage wrote:You are very welcome. Yes, it might be related to pi losing power during shutdown. Just take out the SD card from the Pi and flash it with your PC/laptop (assuming you have a card reader). I am using the latest raspbian image and flash it directly on the card so I don't have to use NOOBs after to actually install the OS.
For my rover, I am using the lite raspbian version because I don't need the GUI or any of the extras. Boots up faster and generally is cleaner.

Best of luck and let me know if you need help.


Finally got some time and burned a new Raspbian image from the latest install source. After several tries I got the old 16gb chip out and the new SansDisck 64gb installed without having to dissect little Rovey. Did some surgery on my little Rovey back end to plug in a wired Ethernet cable. Hooked up keyboard, mouse and monitor. Fired little Rovey up and it is back to life. Yeah. Changed the Config.txt file to enable I2C and SPI. Put in a fixed IP address and got the internet to work. (typing this post on it right now) Downloaded the democode and clicked on Volts.py. It brings up Thonny 2.1.16 running Python 3.5.3 (32 bit). Press Run Script and then Bomb. Print is now a function and requires (). No problem. Fixed those. now it gives me

Traceback (most recent call last):
File "/home/pi/Downloads/rover/democode/volts.py", line 5, in <module>
import spirit_pixels as pixels #pixel functions - read over spirit_pixels.py for more info
File "/home/pi/Downloads/rover/democode/spirit_pixels.py", line 15, in <module>
s.connect((host, port))
ConnectionRefusedError: [Errno 111] Connection refused

Now I need a little help. Not sure how to fix this..
Research is the only place in a company where you can continually have failures and still keep your job.
I knew immediately that was where I belonged.

headamage
Posts: 29
Joined: Mon Dec 04, 2017 5:27 pm

Re: Cloud robotics demo code (now with actual code!!)

Postby headamage » Mon Apr 02, 2018 10:41 am

did you also install the software for the pixels as mentioned in the guide? without it, you cannot communicate with the pixels daemon and it seems you are missing that daemon.

User avatar
TomTheWhittler
Posts: 29
Joined: Wed Sep 13, 2017 5:04 am

Re: Cloud robotics demo code (now with actual code!!)

Postby TomTheWhittler » Tue Apr 03, 2018 1:24 am

headamage wrote:did you also install the software for the pixels as mentioned in the guide? without it, you cannot communicate with the pixels daemon and it seems you are missing that daemon.


Thank you. Forgot that. That is working. Volts is working. Servo_shake head does shake the head then returns 'write error'. Rangefinder is causing all the lights to flash and returns 'wrong register' sometimes. This is the behaviour others have mentioned so we are back in business, Next going to try to get the the cloud robotics demo code to work.
Research is the only place in a company where you can continually have failures and still keep your job.
I knew immediately that was where I belonged.


Who is online

Users browsing this forum: No registered users and 2 guests