u/ManySubstantial6418

AI Vision Sensor Object tracking code. (IQ)
▲ 10 r/vex

AI Vision Sensor Object tracking code. (IQ)

What does it do?

Robot drives to an object and when close enough, it stops moving.

Config:

-Set up drivebase.

-Config AI Vision sensor and set up any object you want to follow. (Its called "Tracker" in this example)

How does it work?

Robot Spins while vision sensor looks for any objects and if any are detected, it will go into drive mode. In drive mode, the robot will drive towards the object while attempting to rotate the drivebase to keep the object centred in its view. This is not proportional due to the drive base limitations on VexCode. The robot just checks whether the object is within a column of pixels sensed by the Vision sensor and attempts to rotate the robot to get the object centred it this column. The values for the column are 120-200 in this example. This is in pixels with 160 being in the centre of the screen on the x axis. So, it is ±40 pixels either side. If this value is to small, at longer distances, the robot will oscillate but if it is too large, at close distances, it wont be alined properly. This is a limitation of non-proportional control loops and why PID would in theory be better for this application.

The "broadcast" blocks are just displaying what the robot is doing.

Feel free to change values and modify the code to find any better ways of doing this!

If you need any help, feel free to ask!

Python Version:

def when_started1():
    global myVariable, error, turn, my_event, r, Search, Arrived, Driving, ai_vision_5_objects, screen_precision, console_precision, ai_vision_5_index
    drivetrain.set_turn_velocity(25, PERCENT)
    while True:
        ai_vision_5_objects = ai_vision_5.take_snapshot(ai_vision_5__Tracker)
        if ai_vision_5_objects and len(ai_vision_5_objects) > 0:
            if ai_vision_5_objects[ai_vision_5_index].centerX < 120:
                Driving.broadcast()
                drivetrain.turn(LEFT)
            if ai_vision_5_objects[ai_vision_5_index].centerX > 200:
                Driving.broadcast()
                drivetrain.turn(RIGHT)
            if ai_vision_5_objects[ai_vision_5_index].centerX > 120 and ai_vision_5_objects[ai_vision_5_index].centerX < 200:
                if ai_vision_5_objects[ai_vision_5_index].width < 80:
                    Driving.broadcast()
                    drivetrain.drive(FORWARD)
                else:
                    Arrived.broadcast()
                    drivetrain.stop()
        else:
            drivetrain.set_turn_velocity(30, PERCENT)
            Search.broadcast()
            drivetrain.turn(RIGHT)
        wait(20, MSEC)


def Driving_callback_0():
    global myVariable, error, turn, my_event, r, Search, Arrived, Driving, ai_vision_5_objects, screen_precision, console_precision, ai_vision_5_index
    brain.screen.set_cursor(1, 1)
    brain.screen.clear_screen()
    brain.screen.print("Driving...")
    wait(0.1, SECONDS)
    brain.screen.clear_screen()


def Search_callback_0():
    global myVariable, error, turn, my_event, r, Search, Arrived, Driving, ai_vision_5_objects, screen_precision, console_precision, ai_vision_5_index
    brain.screen.set_cursor(1, 1)
    brain.screen.clear_screen()
    brain.screen.print("Searching...")
    wait(0.1, SECONDS)
    brain.screen.clear_screen()


def Arrived_callback_0():
    global myVariable, error, turn, my_event, r, Search, Arrived, Driving, ai_vision_5_objects, screen_precision, console_precision, ai_vision_5_index
    brain.screen.set_cursor(1, 1)
    brain.screen.clear_screen()
    brain.screen.print("Arrived!")
    wait(0.1, SECONDS)
    brain.screen.clear_screen()
u/ManySubstantial6418 — 3 days ago
▲ 7 r/fpv

Air 75 Motor issues. Dshot esc failure?

Background:

I have an air 75 and i flew great until one of the motors stopped spinning randomly during an indoor flight. I was confused as it had happened while flying level and at about 30% throttle. I thought that one of the motor wires had come loose, so i re-soldered the motor with the issue but it still refused to rotate. I thought that that was odd, but i ordered a new replacement motor. I unsoldered the old motor and re-soldered the new motor to the fc. It worked again.

The next few flights went well until i had smashed the frame and transferred the electronics to a new frame. When i first tested it, one motor was just vibrating like the other one that i had already replaced. I checked that all of the wires were not damaged and that there were no shorted connections. It started working again. Then at the start of this flight, the same issue occurred, so i rebooted the drone and it went away. But then it happened mid flight. (Shown in the video)

I recovered the drone and all motors but one were working upon arming the drone. I rebooted the drone once again but now, upon arming, no motors spin. The OSD just shows the 'DSHOT_TELEM' error. I have rebooted the FC multiple times with no sucess. I haven't yet connected the drone to betaflight as i just wanna know what should be done next.

The video goes frame by frame to see if anyone catches anything i havent.

Could it be to do with crappy soldering joints as i used a cheap iron?

Is it an ESC issue?

Is it a loose signal wire from the motor?

u/ManySubstantial6418 — 13 days ago
▲ 0 r/drones

THIS IS NOT SELF PROMOTION!!!

THIS IS FOR THE COMMUNITY!!!!!

Self explanatory: I found the free way of 3d scanning any area with any drone.

u/ManySubstantial6418 — 24 days ago