Board index FlightGear Development

Trucks models in and out

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

Re: Trucks models in and out

Postby Jabberwocky » Wed Jan 14, 2015 9:57 pm

Hi Philosopher, hi, Thorsten

please take a look at geo.nas. "geo" has the following getter and setter methods on a coordinate

geo.position.lat(), geo.position.lon(), geo.position.alt(), geo.position.x(), geo.position.y(), geo.position(z) respectively
geo.position.set_lat(), geo.position.set_lon(), geo.position.set_alt(), geo.position.set_x(), geo.position.set_y(), geo.position.set_z().
The x/y/z functions work on a metric system correlated to the geocentric coordinate system. They don't deliver anything related to the heading of the model, they are not turned, they are global. Independently, there is of course the model system which also works with x, y, z, but it otherwise referring to the model. An entirely different beat that only uses the same names for the axis.
So, since you both didn't even know, there are x/y/z coordinates in geo.nas, I assume, you have no idea how to solve my problem?
Any word about the missing aim9.missile file anywhere? Any idea, where to get that one?
Jabberwocky
Retired
 
Posts: 1319
Joined: Sat Mar 22, 2014 7:36 pm
Callsign: JWOCKY
Version: 3.0.0
OS: Ubuntu 14.04

Re: Trucks models in and out

Postby Thorsten » Thu Jan 15, 2015 6:34 am

So, since you both didn't even know, there are x/y/z coordinates in geo.nas, I assume, you have no idea how to solve my problem?


I guess because I wrote

If you ask for world coordinates, geo.nas has helper routines for conversion from (lat, long, alt) to world (xyz).

that means I didn't even know there are xyz coordinates in geo.nas, because why else would I write about them? And because I didn't know that, I also didn't sketch a solution to your problem by using geo to compute relative coordinates. I probably also didn't really use that solution for the weather system, I just wrote some random lines of text. :-)

Or you assume wrongly of course - could always be the case... :-)
Thorsten
 
Posts: 11191
Joined: Mon Nov 02, 2009 8:33 am

Re: Trucks models in and out

Postby Hooray » Thu Jan 15, 2015 2:11 pm

Jabberwocky wrote:Any word about the missing aim9.missile file anywhere? Any idea, where to get that one?


That's experimental stuff that's being worked on by Red_Leader as part of the scripted AI objects effort: http://wiki.flightgear.org/Scripted_AI_Objects
All the files listed there are avaliable in the topic branch (see the infobox on the right).
But why do you need the file ?

If you want to experiment with said code, you'll have to get all the files anyway, and aim9.missile is going to be a part of the checkout.
But so far it's really a fairly simple stub, so not much going on there: https://gitorious.org/fg/hoorays-fgdata ... f:Nasal/ai
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11376
Joined: Tue Mar 25, 2008 8:40 am

Re: Trucks models in and out

Postby Jabberwocky » Sat Jan 17, 2015 2:14 am

Hi Thorsten,

that's what I did, I got the x/y/z of the plane. Now I have to calculate from there the distance of the truck to a certain point of the plane (for example the real wheel) + a little bit for truck length (we are talking a military truck with a long rod here, pulling a taildragger backwards). So, it would nice to know if x/y/z is x growing to the east or the west, y growing to north or the south ... which is basically still the original question and we are still, with the help of geo.nas in the world x/y/z.

The other part of the problem is how to move the trucks in the FG world. As I wrote, Hooray gaven an example but there is no link to the source code nor any docu, I could find about something like model.set_model or where to look for it. So, there seems to be a way just to set models instead of removing and putting them.
The other, more elegant way, would be animation. But there is no way I can find, to use a translate from one position to the other because animations don't set the coordinate of the model, they just work out of a coordinate ... so, I have to figure that part out unless someone has a good idea for me.

J.
Jabberwocky
Retired
 
Posts: 1319
Joined: Sat Mar 22, 2014 7:36 pm
Callsign: JWOCKY
Version: 3.0.0
OS: Ubuntu 14.04

Re: Trucks models in and out

Postby Hooray » Sat Jan 17, 2015 2:42 am

Jabberwocky wrote in Sat Jan 17, 2015 2:14 am:The other part of the problem is how to move the trucks in the FG world. As I wrote, Hooray gaven an example but there is no link to the source code nor any docu, I could find about something like model.set_model or where to look for it. So, there seems to be a way just to set models instead of removing and putting them.



  • there's a whole bunch of examples in $FG_ROOT/Nasal - in fact, even just looking at tanker.nas (or running a forum search) would give you tons of examples and pointers
  • I stated that Red_Leader is currently working on a dedicated Nasal module for controlling AI objects
  • the link I posted is a wiki article that does contain the requested link to the corresponding gitorious topic branch
  • I also stated that in my previous resopnse
  • the AI system is the system you're looking for
  • it's the method used by tanker.nas, fox2.nas, missile.nas as well as the bombable addon
  • so yeah, my pointers were pretty much spot-on - including the link to Red_Leader's recent work
  • Red_Leader's wiki article contains a ton of pointers - because he's already done all the difficult research and ripped apart existing examples of scripted AI objects, which is also the reason why he's currently coming up with a dedicated Nasal module for doing just that.

so, I have to figure that part out unless someone has a good idea for me.

I did post more than just an "idea", several times in fact - and I expected you to read my response, and to ask for clarification if you don't understand it....
I'd suggest to look at my responses again, as it will save you tons of time
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11376
Joined: Tue Mar 25, 2008 8:40 am

Re: Trucks models in and out

Postby Thorsten » Sat Jan 17, 2015 6:40 am

that's what I did, I got the x/y/z of the plane. Now I have to calculate from there the distance of the truck to a certain point of the plane (for example the real wheel) + a little bit for truck length (we are talking a military truck with a long rod here, pulling a taildragger backwards). So, it would nice to know if x/y/z is x growing to the east or the west, y growing to north or the south ... which is basically still the original question and we are still, with the help of geo.nas in the world x/y/z.


Which is why I talked about introducing relative xyz values - do you know what these are?

It'd be really helpful if you state for every element what coordinate system you have... So you have the truck in (lat/lon/alt) and want it in plane coordinates?

-> use geo to create a coordinate object of the plane and of the truck, then geo can give you the direction pointing to the truck, the distance and the altitude difference, in other words the relative vector.

-> we want to convert that into plane coordinates, so we use the plane's heading to convert the direction to a relative direction, the plane's yaw to correct for the offset to the horizon plane - in other words, we need to rotate the relative vector by two angles - since it is already defined by one angle, one of the rotations is a difference, the other is trigonometry in the z-axis

-> and we're done

Alternatively you can simply use geo to create north - west - up unit vectors for your position and any relative vector into these to get local Cartesian coordinates.

There's in fact a gazillion of ways in which you could do it - it's about a five liner in any of them. The information is all there, the rest is down to the rotation matrix (I believe Wikipedia should have something on the general math background).
Thorsten
 
Posts: 11191
Joined: Mon Nov 02, 2009 8:33 am

Re: Trucks models in and out

Postby Hooray » Sat Jan 17, 2015 6:47 am

Thorsten wrote in Sat Jan 17, 2015 6:40 am:There's in fact a gazillion of ways in which you could do it - it's about a five liner in any of them. The information is all there, the rest is down to the rotation matrix (I believe Wikipedia should have something on the general math background).


To be honest, even for this, looking at the aforementioned examples would make sense, because xiii implemented exactly this in Nasal space by adapting Vivian's C++ code, for properly handling missiles in relation to the main aircraft: https://gitorious.org/fg/fgdata/source/ ... 2.nas#L132

IIRC, the mirage-2000 developer simply took the exact same code to come up with his own missile.nas implementation, without having to redo the transformation handling stuff.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11376
Joined: Tue Mar 25, 2008 8:40 am

Re: Trucks models in and out

Postby Jabberwocky » Sat Jan 17, 2015 5:02 pm

Oookay ... I asked and there it is ...

Hooray, I looked for example in tanker.nas. If you would look into it, you would find, it depends on a waypoint concept ... which was the issue already some posts ago. So please, no new iterration of the same posts again ...

Thorsten, relative coordinates would be fine if they would be calculabe with sufficient precision. That's one way I tried, but there is aboviously a factor involved that is nowhere documented, so using relative coordinates atm gives me a shift of about 2 meters with every iteration of the update_loop. I haven't figured out why.

All those missile examples are great ... alas, I have no missile to deal with. If a missile is positionened one or two meters off, nobody notices it and it moves so fast anyway, there is no way to prove, it was ever wrong unelss you wriite data to a log. A pushback truck is slow and it is near ... less than half a meter off is already annoying because it means, the truck model drives under your plane and makes it jump. And the truck will also not drive off with 1000 knots to hidfe he was a little bit in the wrong position to start with. So, this is an entirely different kind of beast I am dealing here with.

So ... what did I get? Iterations of well-meant but unusable suggestions and a little bit polemik about whether I know what relative positions are after I suggested that Thorsten would look into geo.nas (after he denied, there is such a thing like x/y/z on world level). Now, the next step is, Hooray will tell me, I was the one asking for help ... true ... and I have to behave. Even if I don't get real answers only iterations and polemics. Therefore, I do it as usual, figure it out on myself at some point, it will take longer though, and consider this thread as unsolved-closed as far as I am concerned. Sorry, that I asked.

J.
Jabberwocky
Retired
 
Posts: 1319
Joined: Sat Mar 22, 2014 7:36 pm
Callsign: JWOCKY
Version: 3.0.0
OS: Ubuntu 14.04

Re: Trucks models in and out

Postby Hooray » Sat Jan 17, 2015 5:15 pm

Jabberwocky wrote in Sat Jan 17, 2015 5:02 pm:Hooray, I looked for example in tanker.nas. If you would look into it, you would find, it depends on a waypoint concept ... which was the issue already some posts ago. So please, no new iterration of the same posts again ...


look, I completely remember what you posted, and I also remember what I responded.
Now, maybe just consider that I might be correct about this, or that I might be a little more familiar with the code or Nasal in general.
Thus, would you please consider that your understanding is currently incomplete and that I happen to be right ?
Otherwise, the whole exercise kinda moot - you're asking others to provide help/advice/pointers and code snippets.
I have provided exactly what you asked for - yet, you are obviously in a position not to recognize that.
Which is why I made additional references. So this is not about me being right or wrong: it is about you being able to apply the advice you're given.
So either you're able to apply that information or not - but based on what I've seen so far, you haven't even tried it yet, even if that would have just meant to read what's been posted, or to click a few links given to you.
Without doubt, there are at least a handful of other contributors around here who could have responded to your questions, or -equally- who would have come here to post "Hooray, you're wrong, Jabberwocky is right, your postings are not helpful". So far this hasn't happened - which either means that nobody else understands your questions, or that nobody disagrees with my responses so far.
It is your call.


Thorsten, relative coordinates would be fine if they would be calculabe with sufficient precision. That's one way I tried, but there is aboviously a factor involved that is nowhere documented, so using relative coordinates atm gives me a shift of about 2 meters with every iteration of the update_loop. I haven't figured out why.

this, also, is documented in the missile.nas code

All those missile examples are great ... alas, I have no missile to deal with.

which is fine, the missile is just a scripted AI object - it could be anything, including an aircraft, boat or a truck.

So, this is an entirely different kind of beast I am dealing here with.

nope, you are still mistaken - and please don't get this wrong: you're repeating the same mistake you've made in other instances: getting lost in irrelevant implementation details long before understanding the whole problem first, while arguing with contributors who are trying to fill in any gaps for you. Remember how the whole "Canvas menubar" thing worked out for you ? You spent days arguing about irrelevant details, even though people much more familiar with Nasal and Canvas told you that those woud be a no-brainer. That is exactly what is currently happening here.


I have to behave. Even if I don't get real answers only iterations and polemics. Therefore, I do it as usual, figure it out on myself at some point, it will take longer though, and consider this thread as unsolved-closed as far as I am concerned. Sorry, that I asked.


look, you've been given exceptionally detailed advice here, it is you who fails to recognize that and who fails to apply the information given here.
Honestly, FlightGear doesn't know at all whether an AI object is a missile, a truck, an aircraft or a vessel - the underlying technique is the same. Equally, computing relative offsets among independent objects is pretty much identical. It is your choice to process all the feedback you've been given here - but please don''t complain that our advice wouldn't be applicable, everybody who understands the technologies involved, knows much better obviously.

PS: the whole "relative offsets" issue has been solved in a number of places already, including even just those jetways (Nasal, too)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11376
Joined: Tue Mar 25, 2008 8:40 am

Re: Trucks models in and out

Postby Thorsten » Sat Jan 17, 2015 5:47 pm

after he denied, there is such a thing like x/y/z on world level


This is me denying that there is such a thing like x/y/z world coordinates:

If you ask for world coordinates, geo.nas has helper routines for conversion from (lat, long, alt) to world (xyz).

I specifically told you that geo.nas works with x/y/z world coordinates. Sorry, but the experience talking to you is more than a bit surreal - it's the second time that I tell you something to be told in return that I didn't know about it.

Thorsten, relative coordinates would be fine if they would be calculabe with sufficient precision.


*shrugs*

You know, I don't really care. I can do it, as Hooray mentioned a few other people can do it - if you don't want to learn from us, work it out yourself. I've made a good faith attempt in this thread to forget past arguments and help you - you prefer to ignore what I write and jumble everything upside down - fine, your call.

Back to the 'Ignore'-list with you.
Thorsten
 
Posts: 11191
Joined: Mon Nov 02, 2009 8:33 am

Re: Trucks models in and out

Postby Hooray » Sat Jan 17, 2015 10:20 pm

I am still very willing to help with this, so no hard feelings on my part - I am just a little surprised seeing someone not processing the very advice he's requesting, but instead telling us that we're wrong in some way. Among all currently active forum users, there's really just a handful of people who could answer this as well as we did - and the degree of pointers provided really is pretty remarkable, too. We've posted links to docs, wiki articles and even code snippets/Nasal modules doing exactly what you want to do - you keep claiming that our advice would not be applicable. So I suggest to read up on what we've posted. Red_Leader's ai.nas module would get you going within 90 seconds - but for that, you need to understand what people are telling you, which involves reading and processing information we're giving to you, even if that might mean that you may have been wrong in your statements and assumptions - there's no problem with that, it's part of learning something new - just don't assume that you understand everything correctly, your understanding certainly is incomplete at the moment, so there's no need for any authoritative statements that any of us could prove wrong within 5 seconds.

Adapting tanker.nas and applying its concepts/technology is pretty simple, and doesn't necessarily involve any "waypoints" at all:

Subject: Bird strikes script
Hooray wrote:Just to prove my point: It really doesn't take any longer than say 2-3 minutes to open the tanker.nas script, change the model file name to point to the 3D model of a bird, what you end up with is a "funny bird" flying at 330+ kts ground speed at 17000 ft AMSL (I took the first freely available bird model that I could find...):

Image


You really only need to understand how /models and /ai placement work/inter-operate - or simply look at existing Nasal modules doing the same thing. However, it would make sense to simply use Red_Leader's work here - in fact, you could even team up with him to help shape the new ai.nas module.

Alternatively, you could look at DFaber's walk view, too:
http://wiki.flightgear.org/Walk_View


For additional pointers, just refer to Red_Leader's list at: http://wiki.flightgear.org/Scripted_AI_Objects#Related
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11376
Joined: Tue Mar 25, 2008 8:40 am

Re: Trucks models in and out

Postby Red Leader » Sun Jan 18, 2015 7:12 pm

Hi Jabberwocky,
As Hooray has already said, you could use the Scripted AI Objects framework. This framework, although originally intended to cater for missiles, is now designed to support almost anything that you want. For more information on, you can see the wiki page, particularly the "Implementing a new Missile" section. Yes, I know that it talks about missiles, but you could use the same processes to implement an MP pushback truck. In fact, the most difficult part would be showing it over MP. You could probably do that by getting the actual 3D model to move according to an MP property, such as sim/multiplay/generic/float[19]. One big thing to note is that the code in the topic branch is now quite old (and should be considered decrepitated). This is because since the last commit to the topic branch, I have been developing the framework more on my machine. On day, though, it will be committed to GIT. However, it should still be possible to use the code in the topic branch.

Off topic:
In future, we should support MP properties using OOP, so that we can define an arbitrary number of properties to be transferred over MP. At the moment, we can only transfer sim/multiplay/generic/string[0 - 19], sim/multiplay/generic/float[0 - 19] and sim/multiplay/generic/int[0 - 19] (along with loads of other properties, see http://wiki.flightgear.org/Multiplayer_protocol). We could use an XML attribute, like this:
Code: Select all
<property-to-transfer transMP="true">[value]</property-to-transfer>

Anyway, that's just an idea I had.

Regards,
Red Leader

P.S. Please can we stop arguing. Remember, this is a public forum - anyone can look at any topic, and arguing may reflect against FlightGear. May I ask those involved to take a step back and look carefully at each post in this topic and "think before they post".
For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return.
Leonardo da Vinci

Projects:
BAe Sea Harrier FA2Scripted AI Objects frameworkDocumenting Nasal
Red Leader
 
Posts: 22
Joined: Sat Oct 25, 2014 7:52 pm
Location: United Kingdom
Callsign: Red-Led
Version: 2017.3.1
OS: Microsoft Windows 10

Re: Trucks models in and out

Postby Hooray » Sun Jan 18, 2015 7:45 pm

Red Leader wrote in Sun Jan 18, 2015 7:12 pm:In future, we should support MP properties using OOP, so that we can define an arbitrary number of properties to be transferred over MP. At the moment, we can only transfer sim/multiplay/generic/string[0 - 19], sim/multiplay/generic/float[0 - 19] and sim/multiplay/generic/int[0 - 19] (along with loads of other properties, see http://wiki.flightgear.org/Multiplayer_protocol). We could use an XML attribute, like this:
Code: Select all
<property-to-transfer transMP="true">[value]</property-to-transfer>


That is technically possible already by using AndersG's mp_broadcast.nas module (see wildfire.nas for examples) - it basically overloads generic properties and encodes custom data into it.
The same mechanism could be used to make the AI class agnostic to the way it is controlled, i.e. it could be just as well updated locally or remotely using MP messages.
"mp_broadcast" is the search term you'll want to use if you're looking for additional info on doing that.

But basically any update logic could be remotely managed and handled by local script instances just as well.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11376
Joined: Tue Mar 25, 2008 8:40 am

Re: Trucks models in and out

Postby Thorsten » Mon Jan 19, 2015 6:03 am

P.S. Please can we stop arguing. Remember, this is a public forum - anyone can look at any topic, and arguing may reflect against FlightGear. May I ask those involved to take a step back and look carefully at each post in this topic and "think before they post".


I have to confess, I find this equally baffling because it completely misses the fact that there is a very good cause for the argument.

This

Me: If you ask for world coordinates, geo.nas has helper routines for conversion from (lat, long, alt) to world (xyz).

JW: So, since you both didn't even know, there are x/y/z coordinates in geo.nas,
JW: after he denied, there is such a thing like x/y/z on world level

is outright bizarre. To first explain something and get the response that you didn't know about and denied the existence of the very thing you explained is not even resembling a normal conversation.

Can we agree on that? Because if we can't and there's the notion around that answering to the opposite of what a person actually wrote is somehow normal, then there's no point for me to discuss this further.

And if we can agree on that - are you seriously asking me to continue this bizarre conversation without pointing out its exceedingly strange nature - because otherwise it reflects badly on FG? Or what do you expect me to do?
Thorsten
 
Posts: 11191
Joined: Mon Nov 02, 2009 8:33 am

Re: Trucks models in and out

Postby Hooray » Mon Jan 19, 2015 3:13 pm

right, but I do think, Red_Leader has a point though: people new to FG/the forum will not find this particularly appealing. And contributors willing, and able, to answer questions like those posted by Jabberwocky, will not find this exchange very fruitful for all the reasons that we've explained previously.
However, the fact is, that for the forum to be fruitful, we need people able to answer such questions - and I think, we've had at least 3-4 contributors who basically posted "correct" answers (as well as useful pointers).
From my perspective, I am likely to stop responding to such threads, and to start ignoring people who are trying to have the kind of discussion we've had here, despite all of the original responders being very much correct, and only Jabberwocky being the one to point out how we would be mistaken, and how our advice would not be helpful at all.
Honestly, and unfortunately, that is the very definition of Dunning Kruger's Effect ...
We really are a helpful bunch of people, but I think it isn't unreasonable to expect having a constructive discussion.

And as blunt as this may sound, I'd rather not see even more new forum users who have the mistaken idea that this kind of exchange will be tolerated - I mean, just look at who's responded so far: it's mainly people with an actual track record, people who are responsible for many recent developments/features in FlightGear - so whenever someone is wasting a contributor's time by having childish arguments like these, that someone should reconsider their attitude - and this has nothing to do with Thorsten -or my persona- being involved here.

Under different circumstances, Jabberwocky would not have gotten any useful feedback, and people would just have kept ignoring him, without even telling him what the problem is.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11376
Joined: Tue Mar 25, 2008 8:40 am

Previous

Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest