P3D v5.3 Hf2 How to run ISimObject it along the route&

For topics related to the creation of simulation objects (SimObjects). This includes development of aircraft, ground, and maritime vehicles.
Post Reply
dshef
Posts: 62
Joined: Tue Mar 03, 2020 11:59 am

P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by dshef »

Greetings to all!
Another question about ISimobject PDF - how to run it along the route? And how to create a PDK route?

dshef
dshef
Posts: 62
Joined: Tue Mar 03, 2020 11:59 am

Re: P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by dshef »

It looks like there are no developers of the ISimobject movement on the forum or the topic is not interesting. I will try to share my thoughts and questions, maybe someone will be interested and discussion and help will begin.

So, there is a PDF that allows you to develop your own ISimObject with its own behavior, properties, attachment of other objects, etc. This makes it tempting to create interesting situations and scenes that go beyond the limitations of the SDK and SimConnect.
So far I have seen three possibilities in the organization of such scenes:
1. The properties of the ISimObject itself, in which the AI function is provided;
2. The Custom PDK Objects function or service;
3. The WorldObject function or service.

dshef
dshef
Posts: 62
Joined: Tue Mar 03, 2020 11:59 am

Re: P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by dshef »

In the SimpleCar example there is such a fragment:
=====================================================
//Update AI control
//ISimObject's must use the CustomObjectAI AIType in SimDirector to enable waypoint following.
if (!m_spBaseObject->IsUser())
{
// Clear inputs
m_dThrottle = 0;
m_dSteering = 0;

CComPtr<ISimObjectAIV02> spAI;
if (SUCCEEDED(m_spBaseObject->QueryService(SID_SimObjectAI, IID_ISimObjectAIV02, (void**)&spAI)))
{
if (SUCCEEDED(spAI->UpdateSimulationFrame(dDeltaT)))
{
// Guide to current waypoint
UNITMODE eMode = spAI->GetPilotMode();
if (eMode == UNITMODE_WAYPOINT)
{
// Desired speed from the native AI system
double dDesiredSpeed = spAI->GetDesiredSpeed();
m_dThrottle = max(0.0, min(MAX_SPEED, dDesiredSpeed / MAX_SPEED));

// Desired heading from the native AI system
double dDesiredHdg = spAI->GetDesiredHeading();
double dDeltaHdg = dDesiredHdg - vOrient.dY;

// Wrap delta heading -PI to PI
if (dDeltaHdg < -PI)
{
dDeltaHdg += PI;
}
else if (dDeltaHdg > PI)
{
dDeltaHdg -= PI;
}

// Scale steering based on delta heading
static const double MAX_TURN_OFFSET = DEG_TO_RAD(90.0);
m_dSteering = max(-1.0, min(1.0, dDeltaHdg / MAX_TURN_OFFSET));
}
}
}
}
==========================================================
However, it is completely unclear how this fragment is used? How do I get SimpleCar to move along the route? And how to create a route with Waypoint PDK structures?
dshef
Posts: 62
Joined: Tue Mar 03, 2020 11:59 am

Re: P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by dshef »

The second way is from the Custom PDK Objects example. After loading the example, a new option appears in the main menu of the simulator:

Image

With its help, you can turn on or off user objects, including those moving relative to the ground. But how to organize such a move is still unclear.

dshrf
dshef
Posts: 62
Joined: Tue Mar 03, 2020 11:59 am

Re: P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by dshef »

View of the object set in the example by coordinates, airport KVPS:

Image
dshef
Posts: 62
Joined: Tue Mar 03, 2020 11:59 am

Re: P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by dshef »

And the third way of organizing the ISimObject movement is given, but unfortunately not described in the WorldObject example. The screenshot shows a mule that moves relative to a custom hang glider. The custom shapes from the previous example are also visible there.

Image

Movement and position change of ISimObject in this way is possible, but intermittent. Perhaps there are ways to set the discreteness to the frame rate, I don't know.
These are the observations so far.

dshef
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by Clifton Crane »

Hi dshef,
However, it is completely unclear how this fragment is used? How do I get SimpleCar to move along the route? And how to create a route with Waypoint PDK structures?
You can assign the ISimObject a waypoint list using SimDirector. When placing the entity in SimDirector, you must assign the CustomObjectAI type as mentioned in the comments:

Code: Select all

//ISimObject's must use the CustomObjectAI AIType in SimDirector to enable waypoint following.
Note that the waypoint lists are specific to the structured scenario created by SimDirector. If you wanted to programmatically control the waypoints in a plugin, you can use the ISimObjectAIV02 interface SetWayPoint function.

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.
dshef
Posts: 62
Joined: Tue Mar 03, 2020 11:59 am

Re: P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by dshef »

Clifton Crane wrote: Thu Sep 01, 2022 11:41 am You can assign the ISimObject a waypoint list using SimDirector. When placing the entity in SimDirector, you must assign the CustomObjectAI type as mentioned in the comments:
Hi, Clifton!
Thank you so much for the answer! I didn't pay attention to the note about SimDirector, I'll try.

But I want to do without SimDirector. I found the ISimObjectAIV02 interface only through a search, it is not in the list. It is referenced by ISimObjectAI510.
Image

But I want to do without SimDirector. I found the ISimObjectAIV02 interface only through a search, it is not in the list. It is referenced by ISimObjectAI510. Do I understand correctly that this is the class I should use to set waypoints and organize the movement of ISimObject? And do I need to create a separate DLL for this, or include this class in the SimpleCar DLL?

Regards,
dshef
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by Clifton Crane »

Hi dshef,

Yes, the ISimObjectAIV510 interface can also be used to set waypoints. This is a newer version of the interface and still supports functionality from the ISimObjectAIV02 interface. You'll want make sure you call QueryInterface with the correct IID version if you want to use the newer interface. In the SimpleCar sample, you can see it is targeting the V02 interface instead of the V510 interface.

Its up to you if you want to create a separate DLL or include the logic in the SimpleCar.dll. In either case you have access to the DLLStart function which could be used to new a class that manipulates the waypoints of the SimpleCar object.

You may also want to have a look at the ISimObjectManager PDK service. This service allows you to query objects within a given radius, which would give you access to the IBaseObject interface of other AI objects.

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.
dshef
Posts: 62
Joined: Tue Mar 03, 2020 11:59 am

Re: P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by dshef »

The direction of work is clear, it remains to try and experiment.
I will try to put information about the results in that topic.
Thank you again very much, Clifton!

Regards,
dshef
dshef
Posts: 62
Joined: Tue Mar 03, 2020 11:59 am

Re: P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by dshef »

Greetings to all!

While the result is negative, the very organization of the construction of the movement of simobjects is unclear.

We have - a visual model of the car.
It is required - to launch three copies of this car on three different routes.

The PDK instructions say that a DLL with three elements should be created for ISimObject:
- ISimObject class;
- factory function;
- Class GUID.

What is needed to solve this problem?:
- create three successor classes of ISimObjectAIV510, each with its own factory function and GUID in three DLLs, each for its own instance of the car? And if there are, for example, two dozen of them?
- or in one DLL, create three classes for each instance of the car and write factory functions for them? Or one function for three classes?
- where and how to specify the coordinates of the starting positions and each Waypoint?
- where and how to specify the start time of movement along the routes?

What a pity that in the instructions and examples there is nothing about the movement of AI ISimObject!
I tried to write a DLL for the different options listed above, but none managed to overcome the errors. These are redefinition and GUID errors.
I will be glad of any information on this task.

Regards,
dshef
dshef
Posts: 62
Joined: Tue Mar 03, 2020 11:59 am

Re: P3D v5.3 Hf2 How to run ISimObject it along the route&

Post by dshef »

While I'm dealing with the DLL, I decided to check the movement of the my model car in SimDirector.
A ISimpleCar based model from PDK examples. The model in SimDirector was installed normally, the route was also attached without problems.
I inform you for information, maybe someone will be interested.

Image

Image

Regards,
dshef
Post Reply