Example #1
0
def tf_mini():
    tf = TFmini('/dev/tty A choisir !', mode=TFmini.STD_MODE)
    try:

        while True:
            d = tf.read()
            if d:
                print('Distance: {:5}'.format(d))
            else:
                print('No valid response')
            time.sleep(0.1)

    except KeyboardInterrupt:
        tf.close()
Example #2
0
#!/usr/bin/env python
from __future__ import division, print_function
import rospy
import time
import smbus
from tfmini import TFmini
from std_msgs.msg import Float32

bus = smbus.SMBus(1)       				# 0 = /dev/i2c-0 (port I2C0), 1 = /dev/i2c-1 (port I2C1)
DEVICE_ADDRESS = 0x36      				# 7 bit address (will be left shifted to add the read write bit)
tf = TFmini('/dev/ttyAMA0', mode=TFmini.STD_MODE)	# ttyAMA0 = hardware serial

def readAngle():	# Read angle value from AS5600
	bus.write_byte_data(DEVICE_ADDRESS, 0x0D, DEVICE_ADDRESS)
        bus.write_byte_data(DEVICE_ADDRESS, 0x0D, 0x1)
        position_angle = float((bus.read_word_data(DEVICE_ADDRESS, 0x0D)*360)/4096)
	return position_angle

def readDistance():	# Read distance value from TFmini lidar
	d = tf.read()
	if d:
		return d
	else:
		return -1

###############################################################################################
if __name__=='__main__':
	rospy.init_node('lidar')
	lidar = rospy.Publisher('lidar', Float32, queue_size=10)
	rate = rospy.Rate(5)
#!/usr/bin/env python3
#
# MIT License
#

import time
from tfmini import TFmini

port = "/dev/tty.usbserial-A904MISU"

# mode = TFmini.PIX_MODE # Pixhawk - ascii
mode = TFmini.STD_MODE  # packet

tf = TFmini(port, mode=mode)

try:
    print('=' * 25)
    # while True:
    for _ in range(100):
        d = tf.read()
        if d:
            print(f'Distance: {d:5}')
        else:
            print('No valid response')
        time.sleep(0.01)

except KeyboardInterrupt:
    tf.close()
    print('bye!!')
Example #4
0
#!/usr/bin/python
from __future__ import division, print_function
from tfmini import TFmini
import time
import sys
import RPi.GPIO as GPIO
import math

tf = TFmini('/dev/ttyAMA0', mode=TFmini.STD_MODE)

GPIO.setmode(GPIO.BCM)

GPIO_Yaw = [2, 3, 4, 17]
for pin in GPIO_Yaw:
    GPIO.setup(pin, GPIO.OUT)
    GPIO.output(pin, False)

Seq = [[1, 0, 0, 0], [1, 1, 0, 0], [0, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 0],
       [0, 0, 1, 1], [0, 0, 0, 1], [1, 0, 0, 1]]

SeqCount = len(Seq)
WaitTime = 1 / float(1000)


################################################################
def main():
    while True:
        step(GPIO_Yaw, 4074 / 2, WaitTime, 1, 2, "Yaw")
        step(GPIO_Yaw, 4074 / 2, WaitTime, -1, 2, "Yaw")

Example #5
0
#!/usr/bin/env python
#
# MIT License
#

from __future__ import division, print_function
# from serial import Serial
import time
from tfmini import TFmini


tf = TFmini('/dev/tty.usbserial-A506BOT5', mode=TFmini.STD_MODE)

try:
    print('='*25)
    while True:
        d = tf.read()
        # d = tf.read()
        # s = q = 0
        if d:
            print('Distance: {:5}'.format(d))
        else:
            print('No valid response')
        time.sleep(0.1)

except KeyboardInterrupt:
    tf.close()
    print('bye!!')
from __future__ import division, print_function
import time
from tfmini import TFmini
print('Hello')

tf = TFmini('/dev/ttyAMA0', mode=TFmini.STD_MODE)

try:

    print('=' * 25)
    while True:
        d = tf.read()
        if d:
            print('Distance: {:5}'.format(d))
        else:
            print('No valid response')
        time.sleep(0.1)

except KeyboardInterrupt:
    tf.close()
    print('bye!!')
Example #7
0
from __future__ import division, print_function
from tfmini import TFmini
import pyttsx3
import time

# Voice Thingy
engine = pyttsx3.init()
engine.startLoop(False)
engine.say("Program initiated Velo at your service")
engine.iterate()
while engine.isBusy():
    time.sleep(0.05)

tf = TFmini('/dev/ttyS0', mode=TFmini.STD_MODE)
print('=' * 25)
print("\a")
try:
    print('=' * 25)
    expectedDistance = tf.read()
    count = 0
    Sumofcurrentdistances = 0
    Avg = 0
    while True:
        currentdistance = tf.read()

        if currentdistance:
            print('Distance: ' + str(currentdistance))
        else:
            print('No valid response')
            continue
from __future__ import division, print_function
import time
from tfmini import TFmini

# create the sensor and give it a port and (optional) operating mode
#tf = TFmini('/dev/tty.usbserial-A506BOT5', mode=TFmini.STD_MODE)
tf = TFmini('/dev/serial1', mode=TFmini.STD_MODE)

try:
    print('=' * 25)
    while True:
        d = tf.read()
        if d:
            print('Distance: {:5}'.format(d))
        else:
            print('No valid response')
        time.sleep(0.1)

except KeyboardInterrupt:
    tf.close()
    print('bye!!')