Skip to content
Snippets Groups Projects
Commit b659b891 authored by Charles Javerliat's avatar Charles Javerliat
Browse files

Changed absolute path to relative path

parent 9d42b96f
No related branches found
No related tags found
No related merge requests found
from Robot import Robot
import globals
import os
sprite_file_dir = os.path.join(globals.RESOURES_DIR, "galere.png")
sprite_file_dir = "/home/thomas/docs/clubelek/coupe/ressources/galere.png"
class LaGalere(Robot):
def __init__(self):
......
import pyglet
from pyglet import image
from pyglet import sprite
from pyglet import gl
from DynamicObject import DynamicObject
import globals
import os
winWidth = 1500
winHeight = 1000
dynamicObjecsList = []
def loadBackground():
return image.load('/home/thomas/docs/clubelek/coupe/ressources/terrain_high.png')
return image.load(os.path.join(globals.RESOURES_DIR, "terrain_high.png"))
def update(up):
pass
def initVisualization():
#allow use of an extra sample buffer (antialiasing)
# allow use of an extra sample buffer (antialiasing)
config = pyglet.gl.Config(sample_buffers=1, samples=4)
window = pyglet.window.Window(config=config, width=winWidth,height=winHeight, resizable=False)
window = pyglet.window.Window(
config=config, width=winWidth, height=winHeight, resizable=False)
bg = loadBackground()
# scale to fit well terrain
x_scaling = winWidth/bg.width
y_scaling = winHeight/bg.height
gl.glScalef(x_scaling, y_scaling, 1)
print("window launched with scaling "+ str((x_scaling, y_scaling)))
print("window launched with scaling " + str((x_scaling, y_scaling)))
@window.event
def on_draw():
......@@ -37,9 +40,14 @@ def initVisualization():
for dynObj in dynamicObjecsList:
dynObj.sprite.draw()
@window.event
def on_close():
exit(0)
# enter in event loop until window is closed -> blocking
pyglet.clock.schedule_interval(update, 1/10)
pyglet.app.run()
def addDynamicObject(dynObj):
dynamicObjecsList.append(dynObj)
......@@ -5,31 +5,30 @@ import VisualizationCore
import rospy
from nav_msgs.msg import Odometry
import threading
import math
class DdvizNode:
def odomCallback(self, odom):
self.pos_x = (odom.pose.pose.position.x)
self.pos_y = (odom.pose.pose.position.y)
self.quat_z = (odom.pose.pose.orientation.z)
self.quat_w = (odom.pose.pose.orientation.w)
self.rot = math.atan2(2*(self.quat_w*self.quat_z),(1-2*self.quat_z*self.quat_z))
self.rot = math.atan2(2*(self.quat_w*self.quat_z),
(1-2*self.quat_z*self.quat_z))
math.atan
self.updateVisualization()
def __init__(self):
self.galere = LaGalere()
self.odomSubscriber = rospy.Subscriber("odom", Odometry, self.odomCallback)
self.odomSubscriber = rospy.Subscriber(
"odom", Odometry, self.odomCallback)
self.initVisualization()
rospy.spin()
def initVisualization(self):
......@@ -45,11 +44,11 @@ class DdvizNode:
self.galere.set_r(self.rot)
if __name__ == '__main__':
rospy.init_node("ddviz")
try:
DdvizNode()
except rospy.ROSInterruptException: pass
except rospy.ROSInterruptException:
pass
import os
from posixpath import dirname
ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)
RESOURES_DIR = os.path.join(ROOT_DIR, "ressources")
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