Hi All,
" i'm not expert programmer, just a biologist student :-/
with self-teached python experience
so apologize my questions if they are based on wrong assumptions "
for my study i need to write a code to inteface a joystick device
with an open source application similar to google earth.
this application is a 3d globe based on openscenegraphic (OSG),
it has a "tcp listner interface" that accept xml message to move a
camera-view around the globe
the message to move the globe is something like :
go_to_lat_lon(latitude longitude roll picth head)
i tried to code in python using pygame, the results is (my fault) an
"ugly" code
that is not able to update the position according with heading changes
(view direction).
exactly i have a 3 axis joystick
axis_x -> +/- longitude
axis_y -> +/- latitude
axis_z -> +/- 0-360° (heading)
axis_v = 0-1 (speed)
the code i wrote use the axis_x and axis_y to change longitude and
latitude and axis_z to change the view direction.
but it is totally wrong beacouse if i have heading = 0 = 360 (e.g.
look to north)
the code works as aspected ... but if i change direction (view turns)
the axis code is not update.
so if i look yo east and put the joysrick up (go ahead) it don't go to
east .. but go ever to north.
move the axis_y up move the planet to north
move the axis_y down move the planet to south
move axis_y left and right move the planet to west and east
but beacouse my code is totally separated by the heading changes, if i
change heading the joystik x/y axis action is immutate.
this beacouse i connect the x/y action to a code that simply do an
increase/decrease lon-lat values.
increase :
for i in arange(j , j+1):
lati = [sum(zlat)]
a = abs(axis_v) * abs(axis_x)
lati.insert( i+1,a )
zlat = array(lati)
lat = sum(zlat)
j = 0.1
for i in arange(j , j+1):
lati = [sum(zlat)]
a = abs(axis_v) * abs(axis_x)
lati = [sum(lati) - a]
zlat = array(lati)
lat = sum(zlat)
j = 0.1
i used the increase decrease code to handle all the avaiable
condition, North, South, East, Ovest, Ne, Nw , Se , Sw :
1)
axis_x < 0
axis_y == 0
2)
axis_x == 0
axis_y > 0
3)
axis_x > 0
axis_y == 0
4)
axis_x == 0
axis_y < 0
5)
axis_x < 0
axis_y > 0
6)
axis_x > 0
axis_y > 0
7)
axis_x > 0
axis_y < 0
8)
axis_x < 0
axis_y < 0
i hope exists already a function in opengl that can help me to solve
this problem
reading a lot on google seems my problem can be solved using complex
math like quaternion
or rotation around an arbitrary axis.
i can ignore roll and pich, beacouse i can chenge them using the
joystick hat .. an roll and pich are ininfluent on the lon-lat
position ... while the heading is strictly related to the position
beacouse it represent the movment direction.
plese apologize again my ugly code, this what i'm actually using :
http://www.geofemengineering.it/data/epi_joy.py
this the results :
http://www.geofemengineering.it/Site/Media/ossimplanet_joystick-2.mp4
while here i tried to learn quaternion .. but my brain is not hable
"yet" to undstand how to works with quaternion in a
"longitude - latitude" space :-(
http://www.geofemengineering.it/data/epiquath.py
i hope some one can help me!
please i'm italian so it is a bit hard to find the right word to
describe my problem
for eny more detailed explanaton, please ask me where i need to give
more precise informations.
thanks to help me!
ciao,
Massimo.