andyp

  • **
  • 52
Interface arduino with object tracking / avoidance
« on: July 23, 2017, 09:42:17 pm »
I like to detect object with a separate arduino and give the FC commands where to fly or not to fly. E.g. interrupt pathplanner or add separate waypoints and continue, add visual processing and fly after a person on a camera, process LIDAR, sonar, optical sensors and avoid object collisions.

Certainly there a lots of sensors opportunities, but how do I Interface with the FC and give flight commands or interrupt / modify pathplanner flight?

Re: Interface arduino with object tracking / avoidance
« Reply #1 on: July 24, 2017, 04:42:26 am »
Sorry, but understanding the code is the best way to know how to do that.

I know the code, so I know that one way to implement "follow me" is to implement something like a moving "home location" (one of my pet projects I haven't started on yet).

The other piece you describe sounds like adding a waypoint before the current waypoint during flight switching to the new waypoint.

andyp

  • **
  • 52
Re: Interface arduino with object tracking / avoidance
« Reply #2 on: July 24, 2017, 05:26:37 am »
Ok, that is going to take more time than expected. Could you route flight mode to a pwm output, modify it if required and send it back to the FC?

You are right about the waypoints. Add a waypoint if something is in the flight path, before that switch to pos hold. After flightpoint is added switch to pathplanner.

Re: Interface arduino with object tracking / avoidance
« Reply #3 on: July 24, 2017, 08:35:52 am »
If you use PWM inputs from an RC receiver, you already have the flight mode on PWM.  Jut intercept it there and connect the modified flight mode PWM to the FC.

But this sounds "inelegant".  :)

If you are flying a waypoint flight plan and detect an obstacle, do as you suggested and insert an extra waypoint to the flight plan (code changes required).

If you want Arduino to control the quad completely, there are several different flight modes that would work well.  Just have the Arduino send commands to the FC as if they came from the RC receiver.  For instance, there are flight modes where center stick (roll/pitch) is position hold and stick proportionally controls speed when not at center like half stick is 5m/s and full stick is 10m/s.  One mode has left stick always moving west (regardless of where the nose is pointed) and another mode always has left stick moving left.

andyp

  • **
  • 52
Re: Interface arduino with object tracking / avoidance
« Reply #4 on: July 24, 2017, 01:19:34 pm »
I thinks that is really not intelligent.

What about defining restricted flight zones and the pathplanner is taking this zones into account. You can define these zones in the GCS as well as upload them via telemetry, which also can be done by arduino with some sensor array. You can also add a "GPS Assist" like feature called "obstacle assist" and the quad isn't moving forward, before flying into an obstacle / restricted flight zone.

This way you can define, max hight, restricted zones light city or houses, air field, an other things you do not want to flight into.

How do you like this?

Re: Interface arduino with object tracking / avoidance
« Reply #5 on: July 24, 2017, 05:23:46 pm »
I thought you were trying to avoid coding in the firmware.

We don't currently have "geo-fencing", but simple geo-fencing would be simple to implement.  Of course there are many additions that can be made to simple geo-fencing.

andyp

  • **
  • 52
Re: Interface arduino with object tracking / avoidance
« Reply #6 on: July 24, 2017, 07:35:33 pm »
Yes I wanted to avoid changing the code, but if it means very complex coding on the arduino side. I rather like to implement something like geofencing. This can be used elsewhere.

Do you know a good implementation? What do you mean by "simple" geofencing exactly?

Re: Interface arduino with object tracking / avoidance
« Reply #7 on: July 25, 2017, 05:20:55 am »
two points on the ground define a line
that line defines a vertical plane
three or more vertical planes plus a max altitude define a bounded region

no odd shapes
no different shapes at different altitudes
no different altitudes in different sections
not worrying about slowing down before going over the boundary, just about coming back afterward with minimal excursion
etc

andyp

  • **
  • 52
Re: Interface arduino with object tracking / avoidance
« Reply #8 on: July 25, 2017, 08:40:38 pm »
I did a little research and at the beginning I tought you need various shapes but this

https://stackoverflow.com/questions/924171/geo-fencing-point-inside-outside-polygon

covers nearly everything. Even a circle can be fairly apprioximated with 6 or 8 edges.

I would define whether the UAV must stay out or has be inside, so you can have one polygon for the entire boundary and other polygons for objects inside these boundary.

If possible I would keep the altitude inside the requirements, but check, whether no intersections between polygons occurr.

If you have a tree or a house you can overfly it. You can also define max altitude and a minimum altitude if you want to avoid crashing into ground.

The code is in Github, right? https://github.com/librepilot/LibrePilot

I found the code for the pathplanner, but not for manual flight, but I only checked for one hour.

I also see no trouble to check whether the speed vector together with the braking deceleration is used for the point inside the geofence or the UAV itself, but we can use last for the start.

You also have to define a vector to escape the geofence area and for the pathplanner a solution / strategy to go arround the geofence and follow your flight plan. Only movements in the direction of this vector are allowed. For pathplanner I would look for the shortest way to the target and if the target is inside the geofence I would calculate the two points entering and leaving the geofence and find a solution to get from the enter to the exit point.

The geofence objects can then be updated by any other method. GCS or separate arduino with sensors.

I am unsure whether the FC can handle the workload, but I found a queue for those kind of tasks. Is this used to guarantee flight maneuvers are real time?

andyp

  • **
  • 52
Re: Interface arduino with object tracking / avoidance
« Reply #9 on: July 25, 2017, 10:37:10 pm »
Pathfinding

https://en.wikipedia.org/wiki/A*_search_algorithm



Libraries are available in the Internet ...

Re: Interface arduino with object tracking / avoidance
« Reply #10 on: July 26, 2017, 05:18:28 am »
You asked me what I meant by simple geo-fencing.  Of course there are many additions to simple geo-fencing... and many examples of ideas and code.

andyp

  • **
  • 52
Re: Interface arduino with object tracking / avoidance
« Reply #11 on: July 26, 2017, 12:19:18 pm »
I would really like to implement this and also the sensors with the extra arduino, but my problem at the moment ist time.

Yesterday I read the developer manual, maybe I set up a virtual machine for the development ... maybe it has to wait until next holiday.

Still dreaming of a pathfinding UAV taking environment detections into account, which I can tell go there, then there and then there and take some pictures. Need this to scout valleys and gorges for wildwater kayaking expeditions.

I am also working for Hensoldt Sensors GmbH and we do this professionally and I will talk to some colleagues about this. By the way...

Re: Interface arduino with object tracking / avoidance
« Reply #12 on: July 26, 2017, 03:38:05 pm »
Visual navigation is an item on my list of things to do sometime...

My idea is to start with a computer vision replacement/enhancement for GPS, probably starting with something like LSD-SLAM or DSO running on a fairly high power SBC.  You naturally get depth/distance to everything from this for object avoidance without even detecting objects.

karla

  • *****
  • 629
Re: Interface arduino with object tracking / avoidance
« Reply #13 on: July 28, 2017, 09:24:44 am »
Visual navigation... yes
Have you checked out this Israel initiative?
http://www.percepto.co/devkit.html
They have a development kit and a hardware seems to be doing a lot of Visual things, but this is way beyond my level. Have no idea how to integrate this in to a vehicle of mine.
Maybe you guys do?