Beispiel #1
0
import at_talk
"""
Use `python -m serial.tools.list_ports` to find which port the XBee is using
ttySX, where X={0,1,2...} cannot be used by an XBee, exclude them from consideration.

This is a very rudimentry motor control that has been tested with `arduino/esc_control/manual_motors.ino`
All motors spin at the same speed.
"""
arduino = at_talk.radio('/dev/ttyUSB0', 115200)

pw = 620
while True:
	ch = input("> ")
	if ch.isalpha():
		if ch == 'a':
			pw += 20
		if ch == 'd':
			pw -= 20
		if ch == 's':
			pw = 1040
		if ch == 'm':
			pw = 1950
		#if ch == 'x':
	#		pw = 1350
		if ch == 'q':
			arduino.write( 1040 )
			print("Bye!")
			arduino.powerdown()
			break
		arduino.write( pw )
		recv = []
def variance(readings):
    sum1 = np.zeros(3)
    sum2 = np.zeros(3)
    i = 0
    while i < 10:
        sum1 += readings[i]
        sum2 += readings[i] * readings[i]
        i += 1
    num = (sum1 * sum1) / 10
    sd = (sum2 - num) / 9
    var = np.sqrt(sd)
    return var


plt.ion()
arduino = at_talk.radio("/dev/ttyACM0", 57600)
rpy = np.eye(3)

fig = plt.figure(figsize=(16, 6))
axes = fig.add_subplot(121)
# axesacc = fig.add_subplot(122)
a3d = fig.add_subplot(122, projection="3d")
# a3dacc = fig.add_subplot(224, projection='3d')

a3d.set_xlim(-1.2, 1.2)
a3d.set_ylim(-1.2, 1.2)
a3d.set_zlim(-1.2, 1.2)
a3d.scatter([0], [0], [0], s=40)
r, = a3d.plot([0, 1], [0, 0], [0, 0], lw=2)
p, = a3d.plot([0, 0], [0, 1], [0, 0], lw=2)
y, = a3d.plot([0, 0], [0, 0], [0, 1], lw=2)
Beispiel #3
0
def variance(readings):
	sum1 = np.zeros(3)
	sum2 = np.zeros(3)
	i=0
	while i<10:
		sum1 += readings[i]
		sum2 += readings[i]*readings[i]
		i+=1
	num = (sum1*sum1)/10
	sd 	= (sum2-num)/9
	var = np.sqrt(sd)
	return var


plt.ion()
arduino = at_talk.radio('/dev/ttyACM0', 57600)
rpy = np.eye(3)

fig = plt.figure(figsize=(16,6))
axes = fig.add_subplot(121)
#axesacc = fig.add_subplot(122)
a3d = fig.add_subplot(122, projection='3d')
#a3dacc = fig.add_subplot(224, projection='3d')

a3d.set_xlim(-1.2,1.2)
a3d.set_ylim(-1.2,1.2)
a3d.set_zlim(-1.2,1.2)
a3d.scatter([0], [0], [0], s=40)
r, = a3d.plot([0,1], [0,0], [0,0], lw=2)
p, = a3d.plot([0,0], [0,1], [0,0], lw=2)
y, = a3d.plot([0,0], [0,0], [0,1], lw=2)
Beispiel #4
0
def variance(readings):
    sum1 = np.zeros(3)
    sum2 = np.zeros(3)
    i = 0
    while i < 10:
        sum1 += readings[i]
        sum2 += readings[i] * readings[i]
        i += 1
    num = (sum1 * sum1) / 10
    sd = (sum2 - num) / 9
    var = np.sqrt(sd)
    return var


plt.ion()
arduino = at_talk.radio('/dev/ttyUSB0', 57600)
rpy = np.eye(3)

fig = plt.figure(figsize=(16, 6))
axes = fig.add_subplot(121)
#axesacc = fig.add_subplot(122)
a3d = fig.add_subplot(122, projection='3d')
#a3dacc = fig.add_subplot(224, projection='3d')

a3d.set_xlim(-1.2, 1.2)
a3d.set_ylim(-1.2, 1.2)
a3d.set_zlim(-1.2, 1.2)
a3d.scatter([0], [0], [0], s=40)
r, = a3d.plot([0, 1], [0, 0], [0, 0], lw=2)
p, = a3d.plot([0, 0], [0, 1], [0, 0], lw=2)
y, = a3d.plot([0, 0], [0, 0], [0, 1], lw=2)
Beispiel #5
0
args = parser.parse_args()
if args.wl:
  if args.port == None:
    args.port = "/dev/ttyUSB0"
else:
  if args.port == None:
    args.port = "/dev/ttyACM0"
#print(args)

import multiprocessing
import rxControl, at_talk, time, visual
import sys, numpy as np
from vispy.util.quaternion import Quaternion

# Serial objects are not pickle-able, hence they cannot be a part of a Manager.Namespace and thus serial port is a global.
arduino = at_talk.radio(args.port, 19200)

# There are multiple namespaces for flexibility
# {ns_comms, ns_qstate, ns_vis, ns_cfg}
mgr = multiprocessing.Manager()
ns_comms = mgr.Namespace()
ns_comms.name = "Communications:\n\tMode that rxControl operates in(comms_mode)\n\tRecieved packet from mpu(quat_packet)\n\tRecieved packet for GS(gs_packet)"
ns_comms.quat_packet = None
ns_comms.gs_packet = None
ns_comms.mode = 'att_est'

ns_qstate = mgr.Namespace()
ns_qstate.name = "QuadState:\n\tAttitude Quaternion(heading)\n\tRPY calc. from the heading(rpy)"
ns_qstate.heading = Quaternion()
ns_qstate.rpy = (0.0, 0.0, 0.0)
Beispiel #6
0
def variance(readings):
  sum1 = np.zeros(3)
  sum2 = np.zeros(3)
  i=0
  while i<10:
    sum1 += readings[i]
    sum2 += readings[i]*readings[i]
    i+=1
  num = (sum1*sum1)/10
  sd  = (sum2-num)/9
  var = np.sqrt(sd)
  return var


plt.ion()
arduino = at_talk.radio('/dev/ttyUSB0', 57600)
rpy = np.eye(3)

fig = plt.figure(figsize=(16,6))
axes = fig.add_subplot(121)
#axesacc = fig.add_subplot(122)
a3d = fig.add_subplot(122, projection='3d')
#a3dacc = fig.add_subplot(224, projection='3d')

a3d.set_xlim(-1.2,1.2)
a3d.set_ylim(-1.2,1.2)
a3d.set_zlim(-1.2,1.2)
a3d.scatter([0], [0], [0], s=40)
r, = a3d.plot([0,1], [0,0], [0,0], lw=2)
p, = a3d.plot([0,0], [0,1], [0,0], lw=2)
y, = a3d.plot([0,0], [0,0], [0,1], lw=2)
Beispiel #7
0
def variance(readings):
    sum1 = np.zeros(3)
    sum2 = np.zeros(3)
    i = 0
    while i < 10:
        sum1 += readings[i]
        sum2 += readings[i] * readings[i]
        i += 1
    num = (sum1 * sum1) / 10
    sd = (sum2 - num) / 9
    var = np.sqrt(sd)
    return var


plt.ion()
arduino = at_talk.radio('/dev/ttyACM0', 57600)
rpy = np.eye(3)

fig = plt.figure(figsize=(16, 6))
axes = fig.add_subplot(121)
#axesacc = fig.add_subplot(122)
a3d = fig.add_subplot(122, projection='3d')
#a3dacc = fig.add_subplot(224, projection='3d')

a3d.set_xlim(-1.2, 1.2)
a3d.set_ylim(-1.2, 1.2)
a3d.set_zlim(-1.2, 1.2)
a3d.scatter([0], [0], [0], s=40)
r, = a3d.plot([0, 1], [0, 0], [0, 0], lw=2)
p, = a3d.plot([0, 0], [0, 1], [0, 0], lw=2)
y, = a3d.plot([0, 0], [0, 0], [0, 1], lw=2)
Beispiel #8
0
args = parser.parse_args()
if args.wl:
    if args.port == None:
        args.port = "/dev/ttyUSB0"
else:
    if args.port == None:
        args.port = "/dev/ttyACM0"
#print(args)

import multiprocessing
import rxControl, at_talk, time, visual
import sys, numpy as np
from vispy.util.quaternion import Quaternion

# Serial objects are not pickle-able, hence they cannot be a part of a Manager.Namespace and thus serial port is a global.
arduino = at_talk.radio(args.port, 19200)

# There are multiple namespaces for flexibility
# {ns_comms, ns_qstate, ns_vis, ns_cfg}
mgr = multiprocessing.Manager()
ns_comms = mgr.Namespace()
ns_comms.name = "Communications:\n\tMode that rxControl operates in(comms_mode)\n\tRecieved packet from mpu(quat_packet)\n\tRecieved packet for GS(gs_packet)"
ns_comms.quat_packet = None
ns_comms.gs_packet = None
ns_comms.mode = 'att_est'

ns_qstate = mgr.Namespace()
ns_qstate.name = "QuadState:\n\tAttitude Quaternion(heading)\n\tRPY calc. from the heading(rpy)"
ns_qstate.heading = Quaternion()
ns_qstate.rpy = (0.0, 0.0, 0.0)
def variance(readings):
    sum1 = np.zeros(3)
    sum2 = np.zeros(3)
    i = 0
    while i < 10:
        sum1 += readings[i]
        sum2 += readings[i] * readings[i]
        i += 1
    num = (sum1 * sum1) / 10
    sd = (sum2 - num) / 9
    var = np.sqrt(sd)
    return var


plt.ion()
arduino = at_talk.radio("/dev/ttyUSB0", 57600)
rpy = np.eye(3)

fig = plt.figure(figsize=(16, 6))
axes = fig.add_subplot(121)
# axesacc = fig.add_subplot(122)
a3d = fig.add_subplot(122, projection="3d")
# a3dacc = fig.add_subplot(224, projection='3d')

a3d.set_xlim(-1.2, 1.2)
a3d.set_ylim(-1.2, 1.2)
a3d.set_zlim(-1.2, 1.2)
a3d.scatter([0], [0], [0], s=40)
r, = a3d.plot([0, 1], [0, 0], [0, 0], lw=2)
p, = a3d.plot([0, 0], [0, 1], [0, 0], lw=2)
y, = a3d.plot([0, 0], [0, 0], [0, 1], lw=2)