Object avoidance with raspberrypi3-px4 and tfmini

hello @rmackay9 @ppoirier @rishabsingh3003

could you please help me in obstacle avoidance in guided mode
i am using raspberrypi3,pix4,s500 body,tf mini, and drone is a quad copter
i had an rc transmitter flysky with 6 channels

so what i tried till now is

my raspberrypi3 code

    msg = vehicle.message_factory.distance_sensor_encode(
        milliseconds,          # time since system boot
        5,          # min distance cm
        10000,      # max distance cm
        int(d),       # current distance, must be int
        0,          # type = laser?
        0,          # onboard id, not used
        mavutil.mavlink.MAV_SENSOR_ROTATION_YAW_45, #direction
        0           # covariance, not used
    vehicle.send_mavlink(msg)   #Simple function to measure the distance using ultrasonic sensor

and my response with the code in mission planner

my full parameter list
suryaparams.param (18.4 KB)

but drone is not responding to obstacles
i could not understand why

do i need to change any parameters in full parameters list

1 Like

Hi @suryaprakash_lokula . You need to follow our documentation. You do not need a Rpi if you are working with a TF-Mini. Simply connect it to the Flight controller directly, configure the parameters correctly, and switch to Loiter mode (after configuring Simple Avoidance AVOID_*) or Auto Mode (After configuring OA_TYPE parameter). It should work fine for you. I would also suggest moving to the latest Copter 4.1 Firmware. If something isn’t clear from the documentation, let me know. Thanks

1 Like

@rishabsingh3003 thanks for you detailed reply

actually i wish to have a 360 horizontal and vertical top and bottom object detection
if i would like to make it with raspberry pi how can i make it

1 Like

@rishabsingh3003 @ppoirier

i would like to make an obstacle avoidance using raspberrypi and four tfmini modules and send mavlink message as below to pixhawk


def send_body_ned_velocity(velocity_x, velocity_y, velocity_z, duration=0):
    msg = vehicle.message_factory.set_position_target_local_ned_encode(
        0,       # time_boot_ms (not used)
        0, 0,    # target system, target component
        mavutil.mavlink.MAV_FRAME_BODY_NED, # frame Needs to be MAV_FRAME_BODY_NED for forward/back left/right control.
        0b0000111111000111, # type_mask
        0, 0, 0, # x, y, z positions (not used)
        velocity_x, velocity_y, velocity_z, # m/s
        0, 0, 0, # x, y, z acceleration
        0, 0)
    for x in range(0,duration):

velocity_x = 0
velocity_y = -1
velocity_z = 0
duration = 2
send_body_ned_velocity(velocity_x, velocity_y, velocity_z, duration)

`and i would like to know after vehicle.goto() command, while vehicle is moving towards the destination location can this command work if i code for obstacle avoidance using tfmini

i would like to develope my own obstacle avoidance with this using raspberrypi

Thank you

1 Like

Hello @rishabsingh3003 @ppoirier
I would like to do it with lidar and raspberry Pi can I
If yes how to make it
Thank you

1 Like


hello i would like to integrate pixhawk and raspberry pi4 and rplidar 360 degrees for obstacle avoidance

from docs i think to use MAVLink_obstacle_distance_message but i dont know how to set its data using rplidar in python

1 Like

You can use rplidar directly with the Flight Controler

1 Like

Thank you for your reply but how can we make it using raspberry pi

1 Like

Well… that’s a lot of work to make a degraded and suboptimal system :wink:

actually i had a3 rp 360 lidar wich is not working with this configs


mission planner has only a2 lidar in telemetry1, even though can we use this a3 rp lidar

if yes how to set it up


What is your flight controller ?
What is your connection point between RPi 4 and Flight controller
Is the TF mini lidar connected by i2c into the RasPi 4