Jump to content

Recommended Posts

Posted (edited)

Hi,

I am experimenting with different systems in DCS and I'm currently trying to get a constantly computed impact point (CCIP) indicator/reticle or "pipper" working for air to ground weapons.

I think I got the basic prediction calculations right, like flight time and x,y,z coordinates of the launch and landing points, and factoring in gravity and altitude above ground.

The problem I have is turning it into a HUD element. The left/right movement (azimuth) seems to be OK, but the up/down movement (elevation) isn't working right. The main problem I have is this: when maintaining a downward pitch angle, the dot should move up on the HUD but never be above the nose. Maybe there's some equation or factor I'm missing or I'm doing something wrong, but I don't know.

Examples of something similar in other games seem to place the indicator in the actual 3D environment, which is not possible in DCS to my knowledge. Also, the two community mods that have CCIP functionality (A-29 Super Tucano and T-45 Goshawk) seem to do the calculations in a .dll file for which the source code has not been shared. 

Any ideas or suggestions are welcome, and code snippets will be greatly appreciated!

Edited by Sérvalpilot
Kind-of complete
Posted

I managed to get a little further, now I'm trying to incorporate drag.

Here's a breakdown of some of the code I have so far.

rpx, rpy, rpz = self.getSelfCoordinates() -- Release point coordinates, lat, alt, lon
vx, vy, vz = self.getSelfVelocity() -- Release point component velocities, lat, alt, lon
g = -9.81 -- Gravity

t = (-vy - math.sqrt(vy * vy - 2 * g * (math.abs(h))))/g -- Flight time to impact

ipx = rpx + (vx * t) -- Impact point x coordinate 
ipy = self.getBarometricAltitude() - self.getRadarAltitude() -- Ground level
ipz = rpz + (vz * t) -- Impact point z coordinate 

dx = -ipx + rpx -- Distance along x axis
dy = -ipy + rpy    -- This should be radar altitude
dz = -ipz + rpz -- Distance along z axis

dist = math.sqrt(dx * dx + dy * dy + dz * dz) -- Total distance scalar
horiz_dist = math.sqrt(dx * dx + dz * dz) -- Horizontal distance scalar

hdg = pi - self.getHeading()
ip_azimuth = (math.atan2(dz, dx) - hdg) % (2 * pi)
if ip_azimuth > pi then ip_azimuth = ip_azimuth - 2 * pi end

ip_elevation = -math.atan2(dy, horiz_dist)

-- Some stuff to correct for roll and pitch
cos_roll = math.cos(roll)
sin_roll = math.sin(roll)

azimuth_correction = ip_azimuth * cos_roll - ip_elevation * sin_roll
elevation_correction = ip_elevation * cos_roll + azimuth_correction * sin_roll

-- Final corrections, sent as parameters for HUD
ccip_x = azimuth_correction + pitch * sin_roll
ccip_y = elevation_correction - pitch * cos_roll

I tested this by making a custom gun that shot bullets with almost no mass or drag and it was very accurate.


Now the challenge is adding drag. Any ideas?

Posted
16 hours ago, Luiz Renault said:

This doesn't really work. The reticle's movement seems delayed compared to my method, and its also inaccurate like mine. 

I saw the latest A-29's weapon_system file has lines like this:

local valid, az, el, travel_dist = Calculate()

The calculations themselves seem to be done in avSimplest.dll, not in the Lua environment.

I thought you meant there was some built-in function in avSimpleWeaponSystem, similar to "WS_IR_MISSILE_LOCK" or "WS_GUN_PIPER_AZIMUTH" but specifically for CCIP. 

On the topic of drag, I tried several equations which didn't work, so I'll try using the Runge-Kutta method next.

Posted (edited)
Quote

Examples of something similar in other games seem to place the indicator in the actual 3D environment

You want to place elements on hud right? what you mean in "actual 3D environment"?

If you already have a 3d impact coordinate, and it is accurate,. You can just directly use view and projection transformation matrices to convert any 3D coord to your relative 2D coord in the Hud view plane.If you have vectors, then you can use rotation matrix transform vectors.

Hud is no different than another other view plane/screen. View transform is the most basic and direct approach in 3D world to local grid coordinate conversion.

 

I dig little bit about T-45 dll file, the CCIP_v is a lua-c callCCIP_v C++ function is just a partial rotation transform/projection the length of line between aircraft vector and bomb impact point on the Hud verical axis ( y ).

View and rotate transform involve lots of products and trigonometrics, which is kinda compute expensive via Lua, and Lua you cant directly get vel vector(need a extra rotation transform use sensor_data pitch/roll/yaw).  That's why they do it in C++. In lua It's expensive, but doable. 

there is a sample code i found long time draw a "locking box/file" on he HUD using the view transform . it converts object/aircrafts 3D coord to 2D hud coordinates, it's not the CCIP but you get the idea. 

But i cant find it in my browsing histories..

Edited by Insonia
  • Like 1
Posted

I got the HUD indicator correct. I tested it by using a custom gun that shoots bullets with almost no drag.

The problem now is adding drag to the calculations.

I'm going to try several methods, but no luck yet.

  • 1 month later...
Posted (edited)

UPDATE:

I finally managed to get something!
It's not perfect, and I still don't how the drag coefficient table works, but it's definitely usable.

The script I made essentially "simulates" the projectile's motion with all the physics calculations along a series of time steps.
It's fairly CPU intensive and there might be a better way to do it, but this works well for now.

I'll clean it up, add annotations, then probably share it at some point soon!

Edited by Sérvalpilot
  • Sérvalpilot changed the title to Programming a CCIP indicator in Lua
  • 1 month later...
Posted
On 1/12/2024 at 9:47 PM, Sérvalpilot said:

UPDATE:

I finally managed to get something!
It's not perfect, and I still don't how the drag coefficient table works, but it's definitely usable.

The script I made essentially "simulates" the projectile's motion with all the physics calculations along a series of time steps.
It's fairly CPU intensive and there might be a better way to do it, but this works well for now.

I'll clean it up, add annotations, then probably share it at some point soon!

 

Could you tell me what variable "h" was in this? 

t = (-vy - math.sqrt(vy * vy - 2 * g * (math.abs(h))))/g -- Flight time to impact
Posted

@Sérvalpilot I could actually use something like this for a mod I'm working on.  Is it to the point where you'd like to share it yet?

Website (DCS Content): https://sites.google.com/view/spinossimulationsite/home?authuser=0

Discord: discord.gg/V6W8gJSx83

YouTube: https://www.youtube.com/@SpinosSimulations?sub_confirmation=1

System Specs: Ryzen 7 5800X, RX 7800 XT, 32GB DDR4-3200 RAM

DCS Wishlist: F-8E/J Crusader, UH-1Y/AH-1Z, F-14B(U), F-14D/ST-21 Super Tomcat

  • 2 weeks later...
Posted (edited)
On 3/10/2024 at 4:06 AM, bigcomputerman said:

Could you tell me what variable "h" was in this? 

t = (-vy - math.sqrt(vy * vy - 2 * g * (math.abs(h))))/g -- Flight time to impact

h is altitude above the surface, so radar altitude.

 

On 3/17/2024 at 3:11 PM, Spino said:

@Sérvalpilot I could actually use something like this for a mod I'm working on.  Is it to the point where you'd like to share it yet?

Soon™.

It's pretty much done, I'm just doing some testing and documentation.

Edited by Sérvalpilot
  • 3 weeks later...
Posted

At last, here is a script!

CCIP_simple.lua

This is the simple CCIP method with no drag or wind is taken into account.

It works fairly well with light low-drag bombs like the Mk-82 and FAB-100 and with little to no wind.

Like with manual bombing, it's more accurate with steeper dive angles but it works pretty well at 10 degrees.

 

About the advanced method that does incorporate drag, it's taking a while to release because there's still some stuff to figure out.

The main thing is that it's computationally very heavy so I'm looking at ways to optimize it so it doesn't stress the CPU.

  • Like 2
  • Thanks 1
  • 2 weeks later...
Posted (edited)

Here is the advanced script!

CCIP_advanced.lua

 

This method "simulates" the motion of a bomb along a series of time steps until it hits the ground, calculating the acceleration then velocity and position at each time step. It also incorporates drag into the physics calculations.

This method is, as you might expect, more computationally expensive than the simple method. If you encounter performance issues, please let me know.

In theory this can also be expanded to work with guns, rockets, and high-drag bombs. I experimented with those types of weapons with little success.

Feedback is always welcome!

Edited by Sérvalpilot
Slight mistake fixed
  • Thanks 1
  • Sérvalpilot changed the title to Programming a CCIP indicator in Lua (scripts now available)
  • 4 months later...
Posted

Hi, just found this thread and it is very interesting since Im kinda working in a HUD modification for the Su-25 to upgrade it to Su-25SM.

Could you please explain the very basic concepts to add custom made simbology to an existing hud? I know a little lua.

Many thanks in advance

Posted
On 3/17/2024 at 7:11 AM, Spino said:

@Sérvalpilot I could actually use something like this for a mod I'm working on.  Is it to the point where you'd like to share it yet?

The EX?

PC specs:

Intel Core i7-13700K [Raptor Lake 3.4GHz Sixteen-Core LGA 1700] (stock clock)/64.0 GB RAM/RTX 3080 GPU (stock clock)/Windows 10 Home/Multiple M.2 SSD Drives/T.Flight HOTAS X/HP Reverb G2

  • 2 weeks later...
Posted (edited)

@AngelRR92The Su-25T avionics are very good in my opinion, so you can use that instead. The CCIP system it uses is way better than this.

About what you're asking, you would need to create a custom indicator device in the aircraft's cockpit folder.
There are several existing examples you can draw from, like the A-29B, C-130, and Su-30 mods.
I'm sure there are guides or tutorials on this forum that can help guide you through setting that up.

Once you figure it out, the parameters are what you would use to move the indicator elements.

Edited by Sérvalpilot
  • 3 months later...
Posted
En 6/9/2024 a las 22:02, Sérvalpilot dijo:

@AngelRR92The Su-25T avionics are very good in my opinion, so you can use that instead. The CCIP system it uses is way better than this.

About what you're asking, you would need to create a custom indicator device in the aircraft's cockpit folder.
There are several existing examples you can draw from, like the A-29B, C-130, and Su-30 mods.
I'm sure there are guides or tutorials on this forum that can help guide you through setting that up.

Once you figure it out, the parameters are what you would use to move the indicator elements.

Please can you provide some orientation on how to import Su-25T avionics into tje Su-25?? (Or another module).

Thanks in advance!

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...