Commit 30af6076 authored by Thomas Muller's avatar Thomas Muller
Browse files

Affichage signaux et trajectoire

parent 08b48181
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 26 21:07:02 2021
@author: thomas
"""
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import cv2
def affiche_signaux(signaux):
nb_pas = signaux.shape[1]
### AFFICHAGE X
plt.figure(1)
temps_k = np.linspace(0, nb_pas-1, nb_pas)
plt.step(temps_k, signaux[0,:]) # consigneX
plt.step(temps_k, signaux[2,:]) # commandeX
plt.step(temps_k, signaux[4,:]) # positionX
plt.title("Signaux axe X")
plt.xlabel("Temps discret k")
plt.ylabel("Amplitude")
plt.legend(["consigne yc","commande u", "sortie y"])
### AFFICHAGE Y
plt.figure(2)
temps_k = np.linspace(0, nb_pas-1, nb_pas)
plt.step(temps_k, signaux[1,:]) # consigneY
plt.step(temps_k, signaux[3,:]) # commandeY
plt.step(temps_k, signaux[5,:]) # positionY
plt.title("Signaux axe Y")
plt.xlabel("Temps discret k")
plt.ylabel("Amplitude")
plt.legend(["consigne yc","commande u", "sortie y"])
plt.show()
def affiche_trajectoire(signaux, image):
nb_pas = signaux.shape[1]
coordX = signaux[4,:]
coordY = signaux[5,:]
img = np.copy(image)
for k in range(0, nb_pas-1):
print((coordX[k], coordY[k]))
cv2.circle(img, (240 + coordX[k], 240 + coordY[k]), 4, (0,233,255),-1)# Ajout point position bille
cv2.imshow("Frame", img)
cv2.waitKey(0)
# # Permet de sortir de la boucle si appuie sur 'q'
# key = cv2.waitKey(1) & 0xFF
# if key == ord("q"):
# return;
# sig = np.array([[1, 2, 3, 4, 5, 6, 9, 8, 7],
# [5, 3, 9, 7, 5, 2, 1, 0, 6],
# [2, 4, 3, 6, 8, 0, 0, 1, 6],
# [2, 4, 3, 6, 8, 0, 0, 1, 6],
# [5, 3, 9, 7, 5, 2, 1, 0, 6],
# [1, 2, 3, 4, 5, 6, 9, 8, 7],
# ])
sig = np.load("sig.npy")
# affiche_signaux(sig)
img = np.zeros((480, 480, 3), np.uint8)
cv2.rectangle(img, (0,0), (480,480), (255, 255, 255), cv2.FILLED)
image = cv2.imread("visuLaby.jpg")
affiche_trajectoire(sig, img)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment