Problem Sikorsky R4 in C++ (port from Lua)

I have this line in the clbkPreStep
sprintf(oapiDebugString(), "pitch %2.2f rudder %2.2f POWER %2.2f,MAINROTORTHRUST %2.2f", pitch, tail_rotor_dir,power, main_rotor_thrust);
When I run it the pitch and rudder are 0.0 with no change with using the keypad. the power changes when I strt the enginge and the main rotor thrust changes. Collecetive changes the thrust

In the scenario I have the LUA ranger copter and I can steer it. It seems for some reason it is not getting the values of the ruddder,.....

So I made a copy of the copter code and removed most of it. But still no pitch reading????
 
Last edited:
I have this line in the clbkPreStep
sprintf(oapiDebugString(), "pitch %2.2f rudder %2.2f POWER %2.2f,MAINROTORTHRUST %2.2f", pitch, tail_rotor_dir,power, main_rotor_thrust);
When I run it the pitch and rudder are 0.0 with no change with using the keypad. the power changes when I strt the enginge and the main rotor thrust changes. Collecetive changes the thrust

In the scenario I have the LUA ranger copter and I can steer it. It seems for some reason it is not getting the values of the ruddder,.....

So I made a copy of the copter code and removed most of it. But still no pitch reading????
I recall that an airfoil needed to be defined for flight controls to be active. Ensure that there is an airfoil defined for vertical lift. Set all the areas to 0.
 
Last edited:
Thanks
So in my gutted version I have this:
void R4::clbkSetClassCaps(FILEHANDLE cfg) {
...
//Define vertical stabilizer

CreateAirfoil3(LIFT_HORIZONTAL, tail_rotor_axis, LiftFlatPlate, 0, 4, 4, 0.25);



//Define artificial ailerons, elevator, and rudder to take control inputs

CreateControlSurface(AIRCTRL_ELEVATOR, 0, 0, _V(0, 0, 0), AIRCTRL_AXIS_AUTO, 1);

CreateControlSurface(AIRCTRL_AILERON, 0, 0, _V(0, 0, 0), AIRCTRL_AXIS_AUTO, 1);

CreateControlSurface(AIRCTRL_RUDDER, 0, 0, _V(0, 0, 0), AIRCTRL_AXIS_AUTO, 2);

and then this:
void R4::clbkPostStep(double simt, double simdt, double mjd)
{
//Get flight control inputs

pitch = GetControlSurfaceLevel(AIRCTRL_ELEVATOR);

roll = GetControlSurfaceLevel(AIRCTRL_AILERON);

// tail_rotor_dir = -GetControlSurfaceLevel(AIRCTRL_RUDDER);

tail_rotor_spec.prop_eff = std::abs(tail_rotor_dir);

throttle_level = GetThrusterGroupLevel(THGROUP_MAIN);

main_rotor_spec.prop_eff = GetThrusterGroupLevel(THGROUP_HOVER);

double i3 = GetControlSurfaceLevel(AIRCTRL_RUDDER);

//Main rotor axial torque (realistic, but hard to fly with keyboard)

//main_rotor_torque = main_engine_torque/main_rotor_ratio

//vi:add_force({x=0, y=0, z=-main_rotor_torque}, {x= 0.5, y=main_rotor_axis.y, z=main_rotor_axis.z})
//vi:add_force({x=0, y=0, z= main_rotor_torque}, {x=-0.5, y=main_rotor_axis.y, z=main_rotor_axis.z})


sprintf(oapiDebugString(), "pitch %2.2f rudder %2.2f POWER %2.2f", pitch, i3, main_rotor_spec.prop_eff);

}

and when I press the keypad no change in the pitch, rudder,......
 
Thanks
So in my gutted version I have this:
void R4::clbkSetClassCaps(FILEHANDLE cfg) {
...
//Define vertical stabilizer

CreateAirfoil3(LIFT_HORIZONTAL, tail_rotor_axis, LiftFlatPlate, 0, 4, 4, 0.25);



//Define artificial ailerons, elevator, and rudder to take control inputs

CreateControlSurface(AIRCTRL_ELEVATOR, 0, 0, _V(0, 0, 0), AIRCTRL_AXIS_AUTO, 1);

CreateControlSurface(AIRCTRL_AILERON, 0, 0, _V(0, 0, 0), AIRCTRL_AXIS_AUTO, 1);

CreateControlSurface(AIRCTRL_RUDDER, 0, 0, _V(0, 0, 0), AIRCTRL_AXIS_AUTO, 2);

and then this:
void R4::clbkPostStep(double simt, double simdt, double mjd)
{
//Get flight control inputs

pitch = GetControlSurfaceLevel(AIRCTRL_ELEVATOR);

roll = GetControlSurfaceLevel(AIRCTRL_AILERON);

// tail_rotor_dir = -GetControlSurfaceLevel(AIRCTRL_RUDDER);

tail_rotor_spec.prop_eff = std::abs(tail_rotor_dir);

throttle_level = GetThrusterGroupLevel(THGROUP_MAIN);

main_rotor_spec.prop_eff = GetThrusterGroupLevel(THGROUP_HOVER);

double i3 = GetControlSurfaceLevel(AIRCTRL_RUDDER);

//Main rotor axial torque (realistic, but hard to fly with keyboard)

//main_rotor_torque = main_engine_torque/main_rotor_ratio

//vi:add_force({x=0, y=0, z=-main_rotor_torque}, {x= 0.5, y=main_rotor_axis.y, z=main_rotor_axis.z})
//vi:add_force({x=0, y=0, z= main_rotor_torque}, {x=-0.5, y=main_rotor_axis.y, z=main_rotor_axis.z})


sprintf(oapiDebugString(), "pitch %2.2f rudder %2.2f POWER %2.2f", pitch, i3, main_rotor_spec.prop_eff);

}

and when I press the keypad no change in the pitch, rudder,......
I really don't know the problem. It may be some C++ thing.
 
Maybe, I have no clue. I would it think something simple but maybe not
 
The strangest thing is, perhaps, that I sent @gattispilot a copy of my DLL and it didn't work for him either.
So the dll version you sent flew? So you could change the heading,.....

So if UACS worked in LUA that would be great.

I looked at the Delta Glider code and It looks the same. Except I can fire rcs from the keypad?
 
So how is Lua scripting looking to you all these days? :)
I think it's a great complement to Orbiter for those who don't want to bother with C++ and a compiler. I initially planned my projects in ScriptVessel, but then I discovered C++ and loved it.

What I also like about C++ is that I can program for Linux and Windows with little effort. It's true, I have errors, but they're usually not C++ errors; they're just errors caused by my clumsiness or ignorance.
 
Not sure about my c++. No idea how to do lua.
Do idea why the surface isnt working
 
I don't understand. I put a DG next to a copter just to see if my keypad was working. and it was.

@Matias Saibene your dll I can start the engine and power up and raise/lower collective. But no roll, pitch, yaw control. For you were you able to use pitch,.....

It looks like the code is similar as the dg as far as the surface stuff.

Maybe it is how my compiler is set up?
 
@Matias Saibene your dll I can start the engine and power up and raise/lower collective. But no roll, pitch, yaw control. For you were you able to use pitch,.....
But on my computer, my DLL works perfectly. I can control the helicopter just fine.

Could it be an incompatibility because I'm building on Windows 11?
 
No idea how to do lua.
From my niave perspective, lua looks easier to follow (Syntax) than C++, and due to working with the Orbiter API 90% (?) similar. Just without the compiling hassle, and I'm not seeing any major disadvantages compared to a .dll (the only 2: possible UACS support and backward compatibility).
Thunderchicken's code is pretty universal and only a few parameters needed to be adjusted (cockpit instr.-as always- was a bigger deal) to get a model up and running, maybe try that and convert later.
 
Last edited:
Oh. I guess what I don't understand is why one dll works on another pc but on mine it doesn't. Is there a setting in 2024 I may not have active? But then a Delta glider works?

I don't know how to do LUA. just barely C++:)
 
I guess what I don't understand is why one dll works on another pc but on mine it doesn't.
That must be a compiling issue?
@Matias Saibene are you maybe exporting in debug mode?
Are there special libraries for win11?
(please excuse naive questions from somebody that hasn't compiled for over 30yrs)
 
That must be a compiling issue?
@Matias Saibene are you maybe exporting in debug mode?
Are there special libraries for win11?
(please excuse naive questions from somebody that hasn't compiled for over 30yrs)
No problem, I'm compiling in Release mode with CMake:

Code:
 cmake .. -G "Visual Studio 17 2022" -A Win32; msbuild R4.sln /p:Configuration=Release /p:Platform=Win32 /m

CMake takes care of the Windows bureaucracy: generating a Visual Studio solution and compiling it. This way, I avoid having to use Visual Studio Community, which is extremely slow on my machine.
 
cmake .. -G "Visual Studio 17 2022" -A Win32; msbuild R4.sln /p:Configuration=Release /p:Platform=Win32 /m
So 32bit. VS 2022, is there any reason why that shouldn't run on older win systems?
And to be clear you've exported a DG .dll under the same conditions that works on @gattispilot pc?
I'm on win10, if you like I can check if the .dll works my end?

P.s. emoji's not from me!
 
Maybe I need to to look at cmake? It looked complicated to set up though?
 
Maybe I need to to look at cmake? It looked complicated to set up though?

It isn't that complicated since you don't need to know everything of CMake just for compiling Orbiter add-ons, but its a completely different process. The advantage is, you can make your sources completely independent of any compiler or system assumptions, maybe you would even support multiple different Orbiter versions with just one build script.
 
Back
Top