robot navigation
 
Notifications
Clear all

robot navigation

46 Posts
5 Users
3 Likes
4,740 Views
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 
This post was modified 3 years ago by byron

   
Dryden reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
Topic starter  

@byron

So to cut a long story short you have a large image Blob.jpg and two smaller images bot.png and target.png? You move each small image over the larger image to find the best or sufficient match?

An image is simply an array of numbers so it would look something like this:

To enlarge image below right click image and choose Open link in new window.

imageArrays

 

I would have to look up the cv documentation to understand the "methods".
Python is new to me and indeed I haven't used numpy or cv yet and will have to start with learning how to install them. Up to now I have just used Python with text i/o to try and get my head around all these higher level data representation abstractions and the associated nomenclature. I am a very low level programmer.

 


   
Dryden reacted
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 

@robotbuilder

In principle thats correct, its just an array or in python terms a nested list where a list contains other lists that contain ... as so on.

When the image is loaded, say into a variable called img, info on the image is obtained by doing

(h, w, d) = image.shape 

For example if I do this on my small image containing the image I want to try to find in the main image I get  height=74, width=100, depth=3 showing that the image is 74 rows x 100 columns with 3 channels representing the Blue, Green, Red colours.

I can also just print the list data by just doing a print(img) which would show data in the following format.

[[[26 37 53]
[40 52 69]
[43 56 74]
...
[62 75 95]
[61 72 88]
[36 43 56]]

[[25 36 52]
[41 54 71]
[42 55 73]

etc.

I've mainly been using OpenCV on my mac, but I have also installed on a raspberry pi.  For testing purposed its best to create a python virtual environment and install the opencv into this.   From memory I think it was just a case of activating the virtual environment and doing a pip3 install opencv but I did not make any notes and the installation instructions are readily available with a google.

Here is a handy link to some OpenCV on python docs

https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_core/py_image_arithmetics/py_image_arithmetics.html

 


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
Topic starter  

   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 
Posted by: @robotbuilder

Mustered up some motivation to work on coding my robot base.  It is somewhat hard to share because all visual processing code is written in FreeBASIC and a Python version would be much too slow.

Good to see you are getting back in to a robot project again. 😀  Depending on what you mean by visual processing, then python may not be too slow as the openCV libraries are all written in C as is the numpy library.  

The encoder ticks program could be written in python, but I think a good option may also be to count the encoder ticks with a microprocessor running C and just to pass more summarised data to the visual display. And indeed I think thats what you are saying.

Maybe the start point could be using openCV in python to determine the position and direction the robot is facing, then to issue commands to the microprocessor to so something like rotate 90 degrees and the proceed for 100 cm etc.  The microprocessor then keeps the robot robot on the straight and narrow by means of checking the encoder feedback.

Posted by: @robotbuilder

What I would like to get around to doing on a connected laptop is a graphics display of the 2d position of the robot as it moves around.  To share I would have to write a Python version.

However I think you are saying you want to represent the robot on the screen as a visual 'blob' (were the front of the robot is indicated) and then, as the robot moves, you want to display its movements as a trace on the screen.?  (and from its second position, I'm not quite with that yet).  But any help I can be in producing any python programs you need I will chip in as time allows.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
Topic starter  

@byron 

 

Last month I installed opencv for Python.  This works for me gets and displays video from the webcam,

 

import cv2 as cv

capture = cv.VideoCapture(0)

while True:
    isTrue, frame = capture.read()
    cv.imshow('Video',frame)

    if cv.waitKey(20) & 0xFF==ord('d'):
        break

capture.release()
cv.destroyAllWindows()

 

I am using Python39, I ran your above Python program with three images

# the file names of the images:
myImage = 'C:/cvImages/image.jpeg'
myBot = 'C:/cvImages/tabasco.jpeg'
myTarget = 'C:/cvImages/tape.jpeg'

but got errors,

Traceback (most recent call last):
File "C:\Users\casey\AppData\Local\Programs\Python\Python39\bryonCV1.py", line 23, in <module>
cv2.imshow('Untidy Office', cv2.imread(myImage))
cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-1i5nllza\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

image
tabasco
tape

 


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 

@robotbuilder

A quick post on your AttributeError: module 'serial' has no attribute 'Serial' problem.

I use a mac so I ran the following code, putting the serial port of an unsupecting wemos Esp8266 board 

import serial
import time
for in range(10):
    with serial.Serial('tty.usbserial-14140', 9800, timeout=1) as ser:
        time.sleep(0.5)
        ser.write(b'H')   # send the byte string 'H'
        time.sleep(0.5) # wait 0.5 seconds
        ser.write(b'L')   # send the byte string 'L'
 
And it worked OK. 
 
So I had a peruse of google and found that pyserial and serial do work work well together 
 
 
I suggest you try to uninstall the serial package.
 
I have never installed serial   I have not had any issues just communicating with the whatever 'serial' it is that gets installed from the python website.
 
I will have a look at your previous post relating to openCV later on today.
This post was modified 2 years ago by byron

   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 
Posted by: @robotbuilder

I am using Python39, I ran your above Python program with three images

I copied your images and put them in my images directory.  This images directory sits under the directory where the python code is located.  

myImage = 'images/robot_builder.jpeg'
myBot = 'images/tabasco.jpeg'
myTarget = 'images/tape.jpeg'

And it all works as expected, the robot_builder image pops up, focus on the image and keep pressing a key to see the sequence unfold, ending in the bearing calc as shown below.

image

 So it must be something to do with the way the image paths are resolved, so I think it will all work if you create the image directory as mentioned above.

 


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 

@robotbuilder

and dont forget the bearing calc shown on the output terminal will need adjusting as per 

# 3. from the angle calculate the compass bearing
# Note that this needs to be developed into a function that adjusts the calculation for where
# the target is in relation to an imaginary compass placed on the bot. Deducting the angle from 90 degrees
# is for where the target is in the North to East quadrant.
bearing = 90 - angle
print('Compass bearing from bot to target' ,bearing)
 
and the centre to centre of the 'bot' and 'target' for your images is in the SW quadrant.  
 
Sometime I may get to properly finish that bit of code, but as my main target is outdoor bots, and a video on RTK-GPS is in the offing, my efforts will be all to do with bearing calcs based on GPS (and maybe I can pinch the bearing cals that @dronebot-workshop may have done. 😀 )

   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
Topic starter  

@byron 

Thanks for the feedback. Will have to work on

... my main target is outdoor bots ...

For me I have no use for an outdoor bot but even then I would be more interested in visual location and navigation than using GPS just for the challenge. You wanted to chase rabbits and foxes away from the veg patch? I would use a quadrocopter which have the GPS and a camera.

Quadrocopter Ball Juggling


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 
Posted by: @robotbuilder

You wanted to chase rabbits and foxes away from the veg patch? I would use a quadrocopter which have the GPS and a camera.

I've morphed the robotic intentions, initially at least, to making it go on periodic rabbit / surveillance patrols, maybe sending a squirt of water in the general direction of rabbit activity.   It will also serve as a mobile camera mount so I can see whats up (doc) around the premises and it will be summoned when the drive gate is opened to see who is visiting.   I want to build one that can run for extended periods, probably using car batteries, sort of a mini golf buggy.  

Those little quadcopter are only good for about 20 minutes, and the bigger ones too expensive.  But a little quadcopter drone would be a fun addition to compliment foxbot so maybe.. 😎 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2504
 
Posted by: @byron
Posted by: @robotbuilder

You wanted to chase rabbits and foxes away from the veg patch? I would use a quadrocopter which have the GPS and a camera.

I've morphed the robotic intentions, initially at least, to making it go on periodic rabbit / surveillance patrols, maybe sending a squirt of water in the general direction of rabbit activity.   It will also serve as a mobile camera mount so I can see whats up (doc) around the premises and it will be summoned when the drive gate is opened to see who is visiting.   I want to build one that can run for extended periods, probably using car batteries, sort of a mini golf buggy.  

Those little quadcopter are only good for about 20 minutes, and the bigger ones too expensive.  But a little quadcopter drone would be a fun addition to compliment foxbot so maybe.. 😎 

So, why not have the quadcopter sit on the top of the robot and be charged by it and launched by it. Then you can have the bot cruise the grounds casually and launch the quad to check out visitors as well as scare off rabbits, buskers and estate agents as required 🙂

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 
Posted by: @will

So, why not have the quadcopter sit on the top of the robot and be charged by it and launched by it.

Very ambitious thoughts there!  (and maybe a whole squad of such bots to serve as the ultimate defence of my realm)


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2504
 

@byron 

Absolutely, have you seen the drones that fly up to a wall and hang themselves vertically ? You could have up to 5 drones (one on each side and one on the "roof") and customize each one for a different kind of varmint 🙂

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
Topic starter  

@byron 

The idea is to have the drone on standby. Using a camera to detect movement (and size of moving object) then the drone can be activated to dive bomb the rabbits or fox for 15 minutes like a buzzing swarm of bees. It could get to the drive gate to send back video so you can see who is visiting. They are great little devices and can navigate themselves back to home base before the battery runs out. One day I suspect with future warfare thousands of them will appear on the horizon to take us out, something to think about in terms of drone defence.

It was the drone keyword in a google search that I first came across Bill's dronebot workshop.

 


   
ReplyQuote
Page 2 / 4