def showGravity(self):
		if (not IMU.isAvailable()):
			return self.unavailable()
		
		self.open()
		
		self.serviceManager()
		
		self.gridrow += 1
		
		self.widgets['frameLabel'] = Tkinter.Label(self.widgets['tframe'],text='IMU / Gravity', anchor=NW, bg=self.colours['bg'], fg=self.colours['headingfg'], font=self.fonts['heading'])
		self.widgets['frameLabel'].grid(column=0,row=self.gridrow,sticky='W')
		
		self.gridrow += 1
		
		self.widgets['gframe'] = Tkinter.Frame(self.widgets['tframe'], bg=self.colours['bg'])
		self.widgets['gframe'].grid(column=0,row=self.gridrow, columnspan = 3, sticky='EW')
		self.widgets['gframe'].columnconfigure(0, weight=1)
		self.widgets['tframe'].columnconfigure(0, weight=1)

		self.widgets['rollLabel'] = Tkinter.Label(self.widgets['gframe'],text='TBD', bg=self.colours['bg'], fg=self.colours['fg'], font=self.fonts['heading2'])
		self.widgets['rollLabel'].grid(column=0,row=self.gridrow,sticky='EW')
		
		self.gridrow += 1
		
		self.widgets['hCanvas'] = Tkinter.Canvas(self.widgets['gframe'], borderwidth=0, bg=self.colours['bg'], highlightthickness=0, width=474, height=474)
		self.widgets['hCanvas'].grid(column=0,row=self.gridrow, padx= 10,sticky='EW')
		self.shapes['skyplane'] = self.widgets['hCanvas'].create_polygon([(0, 0), (474, 0), (474, 474), (0, 474)], fill='#fff')
		self.shapes['groundplane'] = self.widgets['hCanvas'].create_polygon(self.groundcoords, fill='#828282')
		self.shapes['mask'] = self.widgets['hCanvas'].create_image(self.centre.real, self.centre.imag, image=self.getImage('mask',0))
		self.shapes['reticle'] = self.widgets['hCanvas'].create_image(self.centre.real, self.centre.imag, image=self.getImage('reticle',0))
		
		self.widgets['pitchLabel'] = Tkinter.Label(self.widgets['gframe'],text='TBD', anchor=W, bg=self.colours['bg'], fg=self.colours['fg'], font=self.fonts['heading2'])
		self.widgets['pitchLabel'].grid(column=1,row=self.gridrow,sticky='NS')
Exemple #2
0
import sys

from math import pi
from IMU import IMU
from sensor_msgs.msg import Imu as ImuMessage
import tf


if __name__ == '__main__':
    rospy.init_node('ImuPublisher', log_level = rospy.INFO)

    rospy.sleep(2)
    rospy.loginfo("Initializing ImuPublisher node")

    imu = IMU('/dev/ttyUSB0')
    #
    # see the rename in the import above
    #
    imuPublisher = rospy.Publisher('imu_data', ImuMessage)

    imuMessage = ImuMessage()
    imuMessage.header.frame_id = 'imu'

    imuMessage.orientation.x = 0.0
    imuMessage.orientation.y = 0.0
    imuMessage.orientation.z = 0.0
    imuMessage.orientation.w = 0.0
    imuMessage.orientation_covariance = [0.0001, 0.0, 0.0,
                                         0.0, 0.0001, 0.0,
                                         0.0, 0.0, 100.0]
Exemple #3
0
from Bluetooth		import Bluetooth
from IMUtoBT		import IMUtoBT
from Motor			import Motor
from Stablizer		import Stablizer

print "RollE - A Ballbot"
print "Final Year Project"
print "Ghulam Ishaq Khan Institute of Engineering Sciences and Technology"
print "https://github.com/alyyousuf7/RollE"
print ""

signal.signal(signal.SIGTSTP, config.cleanup)
print "Press CTRL+Z to exit."
print ""

imu = IMU()
imu.start()

bt = Bluetooth()
bt.start()

imu2bt = IMUtoBT(imu, bt)
imu2bt.start()

motor1 = Motor(config.Motor1_D1, config.Motor1_D2, config.Motor1_EN, 0)
motor2 = Motor(config.Motor2_D1, config.Motor2_D2, config.Motor2_EN, 1)
motor3 = Motor(config.Motor3_D1, config.Motor3_D2, config.Motor3_EN, 2)

stablizer = Stablizer(imu, motor1, motor2, motor3)

# Send PID Values over Bluetooth
    def showOrthographic(self):
        if not IMU.isAvailable():
            return self.unavailable()

        self.open()

        self.serviceManager()

        self.gridrow += 1

        self.widgets["frameLabel"] = Tkinter.Label(
            self.widgets["tframe"],
            text="IMU / Orthographic",
            anchor=NW,
            bg=self.colours["bg"],
            fg=self.colours["headingfg"],
            font=self.fonts["heading"],
        )
        self.widgets["frameLabel"].grid(column=0, row=self.gridrow, sticky="W")

        self.gridrow += 1

        self.widgets["oframe"] = Tkinter.Frame(self.widgets["tframe"], bg=self.colours["bg"])
        self.widgets["oframe"].grid(column=0, row=self.gridrow, columnspan=3, sticky="EW")

        self.widgets["rollLabel"] = Tkinter.Label(
            self.widgets["oframe"],
            text="Roll",
            bg=self.colours["bg"],
            fg=self.colours["headingfg"],
            font=self.fonts["heading2"],
        )
        self.widgets["rollLabel"].grid(column=0, row=self.gridrow, sticky="EW")

        self.widgets["pitchLabel"] = Tkinter.Label(
            self.widgets["oframe"],
            text="Pitch",
            bg=self.colours["bg"],
            fg=self.colours["headingfg"],
            font=self.fonts["heading2"],
        )
        self.widgets["pitchLabel"].grid(column=1, row=self.gridrow, sticky="EW")

        self.widgets["yawLabel"] = Tkinter.Label(
            self.widgets["oframe"],
            text="Yaw",
            bg=self.colours["bg"],
            fg=self.colours["headingfg"],
            font=self.fonts["heading2"],
        )
        self.widgets["yawLabel"].grid(column=2, row=self.gridrow, sticky="EW")

        self.gridrow += 1

        self.widgets["rollCanvas"] = Tkinter.Canvas(
            self.widgets["oframe"], borderwidth=0, bg=self.colours["bg"], highlightthickness=0, width=280, height=280
        )
        self.widgets["rollCanvas"].grid(column=0, row=self.gridrow, padx=10, sticky="NE")
        self.shapes["rollImage"] = self.widgets["rollCanvas"].create_image(150, 150, image=self.getImage("roll", 0))

        self.widgets["pitchCanvas"] = Tkinter.Canvas(
            self.widgets["oframe"], borderwidth=0, bg=self.colours["bg"], highlightthickness=0, width=280, height=280
        )
        self.widgets["pitchCanvas"].grid(column=1, row=self.gridrow, padx=10, sticky="NE")
        self.shapes["pitchImage"] = self.widgets["pitchCanvas"].create_image(150, 150, image=self.getImage("pitch", 0))

        self.widgets["yawCanvas"] = Tkinter.Canvas(
            self.widgets["oframe"], borderwidth=0, bg=self.colours["bg"], highlightthickness=0, width=280, height=280
        )
        self.widgets["yawCanvas"].grid(column=2, row=self.gridrow, padx=10, sticky="NE")
        self.shapes["yawImage"] = self.widgets["yawCanvas"].create_image(150, 150, image=self.getImage("yaw", 0))