Avoidance Experiments with the POC and Benewake TFMINI

Hello
If it is set to look forward, you should be able to see it work on the “radar” screen of Mission Planner (invoke with Ctrl-F and select Proximity)

thanks @ppoirier for your reply
Although right now its not showing anything in proximity but i am checking it, i want to know what happen if i pass (distance , orientation) # orientation(0,1,2,3,4,5,6,7,24,25) and distance from lidar
in the below function does it will avoid collision.
def sensor_data(d,o):
msg=vehicle.message_factory.distance_sensor_encode(
0,
5,
250,
d,
0,
1,
o,
0,
)
vehicle.send_mavlink(msg)

or else share if you have any github repository or any documents (any material)
i want to do collision avoidance drone using lidar sensor (tf-mini), pixhawk and raspberry pi

thanks
Akash

The reference to code is in the blog

thanks@ppoirier I have set prs_type =2 but it’s not showing anything in proximity
I am following this Github sensor is reading the data and i don’t know “vehicle.send_mavlink(msg)” is pushing the data to the pixhawk
this line is also working fine “vehicle = dronekit.connect(’/dev/ttyS0’, wait_ready=True, baud=57600)”, i am able to fetch data and there is no errors in code I am getting
but still, I am unable to see anything in proximity (ctrl+f)
please provide the saved params of yours
I am using raspberry py as a companion computer and ultrasonic sensor for distance measure and pixhawk as a flight controller.

Regards

You should get data out of /dev/ttyS0, have you checked with a serial converter (FTDI) connected to a terminal at 57600 bps?

thanks @ppoirier
serial port is working correctly, i am able to communicate with drone and getting data also like
print(" Attitude: %s" % vehicle.attitude)
print(" Velocity: %s" % vehicle.velocity)
print(" GPS: %s" % vehicle.gps_0)

All the above commands are working perfectly still there is issue probably i think there might be some issue with parameters i kept
serial2_protocol = 1
serial2_baud =57600
prx_type =2

is there any other things i have to consider

regards
Akash

@ppoirier I also tried serial converter but same no response nothing in radar
still the drone is communicating
Can you tell why “vehicle.send_mavlink(msg)” command is not working on the drone.

I tested your script and it works fine sending fixed values( as I don’t have a sonar).
Double check everything, and if your require assistance, I suggest you open a new issue on the forum so you will get more attention than here, as this blog is not rally related to python script.

Regards

thanks @ppoirier for giving time I got the problem , the problem was in firmware version i.e in version 3.4.6 it don not detect the proximity
I simply upgraded the pix hawk firmware its now able to detect but how to check that collision avoidance is working perfectly
Because now on arming and giving throttle (without propeller) there is no variation in the speed of motor
thank you very much for your support

1 Like

@ppoirier my drone is sensing the distance but its performing collision avoidance.

I think i have missed something in full parameter list.
provide the list of parameter i need to change.

As written on my blog:

On Mission Planner you set Proximity and Avoidance (as per Avoidnce wiki above) and you can set the avoidance enabling using a transmitter switch, I used ch7 = 40 for Object Avoidance.

Here are the options for rc7
https://ardupilot.org/copter/docs/parameters.html#rc7-option-rc-input-option

Thank you @ppoirier now my drone is able to have collision avoidance … when i was testing in position hold mode it worked 2 times but after that it got flip the quad get crashed what would be the reason for this.
currently i am using tf mini lidar

I don’t think the avoidance makes the drone flip (that never occurred during my tests)
Check your setups an look at logs for clues.

@ppoirier avoidance is working perfectly but i am facing one problem i.e raspberry pi getting disconnect(NO heart beat in 5 sec) automatically on flying,
currently I am using uart port “vehicle = dronekit.connect(’/dev/ttyS0’, wait_ready=True, baud=57600)” to connect
What all are the possible reason for that?

Hi
Make sure you have good ground continuity and adequate power on UBEC. You could add some capacitor on VCC to filter noise.

Otherwise reduce UART speed so it keeps connected

hii @ppoirier
I am also facing similar problem in my case I am getting distance in proximity (PRX)
but no collision avoidance is happening.
I tried in position hold mode (suggest the best flight mode to test ? )
I am using pixhawk (suggest the firmware version I should use ?)
I am using Raspberry Pi as companion computer.

Have you set a RC switch to activate the avoidance function ?

@aananthi_g which firmware are you using??

Last I checked avoidance only works in Loiter, not PosHold. That was the case when I was testing an A2 lidar.

A question for Patrick im revisiting my avoidance project and would be very grateful if you could please give me the 2 sets of numbers to write for serial and I2C fo the TF mini,many thanks and thank you for this project