Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Addons > Addon Development
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Notices

Addon Development Developers post news, updates, & discussions here about your projects in development.

Reply
 
Thread Tools
  #1  
Old
gattispilot's Avatar
gattispilot gattispilot is online now
Addon Developer
Default Swiveling attachment
by gattispilot 04-10-2012, 01:12 PM

I have been asked about making a swiveling attachment. The attachment vessel has a child that attaches to a parent vessel and then a parent that then would attach to a child on the second vessel. In this case it is a rover that Donamy is working on.


little thrust and wheels turned ( I think the cart/rear part should be at an angle also)


no thrust



More Forward Thrust applied and wheels turned
What I have is the X vector is measured and then based on that the angle of the direction part of the attachment is set.

Code:
VECTOR3 speedvec; // first we define our vector which will recieve the data
oapiGetFocusShipAirspeedVector(&speedvec);//then we retrieve its x,y,z
//CART[ROT] =_V(0, cos((speedvec.x)*PI), -sin((speedvec.x)*PI));
//ANGLE=speedvec.x/10;//CHANGES HOW MUCH OF AN ANGLE CHANGE
ANGLE=speedvec.x*10;
if ((ANGLE)>.2) ANGLE=.2;//SETS LIMIT OF ANGLE CHANGE
if ((ANGLE)<-.2) ANGLE=-.2;// SETS LIMIT OF ANGLE CHANGE
CART[DIR] =_V( -sin((ANGLE)*PI),0, -cos((ANGLE)*PI));
//if ((ANGLE)>.2) ANGLE=.2;//SETS LIMIT OF ANGLE CHANGE
//if ((ANGLE)<-.2) ANGLE=-.2;// SETS LIMIT OF ANGLE CHANGE
SetAttachmentParams(FG2,_V(0,0,0),CART[DIR],_V(0,1,0));//SETS NEW ATTACHMENT
double sin1=sin((ANGLE)*PI);
double cos1=cos((ANGLE)*PI);
//if ((speedvec.z>0)&&(speedvec.x==0))SetAttachmentParams(FG2,_V(0,0,1),_V(0,0,1),_V(0,1,0));
   sprintf(oapiDebugString(),"ANGLE %2.2f speedvec.x %2.2f sin1 %2.2f cos %2.2f,", ANGLE,speedvec.x,sin1,cos1 );
Any ideas?
Reply With Quote
Views 1114 Comments 10
Thanked by:
Total Comments 10

Comments

Old 04-10-2012, 02:49 PM   #2
Loru
Moderator
 
Loru's Avatar

Default

I suggest contacting tl8 as he is working on his aircraft tug and may provide some ideas.
Loru is offline   Reply With Quote
Thanked by:
Old 04-10-2012, 06:39 PM   #3
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Thanks I messaged him.
gattispilot is online now   Reply With Quote
Old 04-18-2012, 05:05 PM   #4
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

I have moved this a vessel. I can get the attachment to move by looking at the rudder and adjusting that value. But I need to have it move later than the vessel turns. Any ideas? So when the vessel turn the trailer continues along and then turns accordingly.
gattispilot is online now   Reply With Quote
Old 04-19-2012, 04:08 AM   #5
Tommy
Orbinaut
Default

Setting the attachment based on rudder position won't work. As you noted, the timing doesn't match. Also, this won't work if the vehicle is backing up.

There seem to be two main options. One is to create the IK algorithms (with appropriate constraints) yourself and incorporate them into vessel code.

The second is to use a separate physics engine that can perform the IK solutions for you. The only real return data you would need is the angle between the parent and child. I forget which engine I was looking at for this, but any engine that could support a truck-trailer combination would work. The engine could use a "flat" world (rather than Orbiter's round world) unless you were trying to support terrain meshes (such as the outdated Meshland project).

Either way, it's not easy. Hopefully someone will come up with a brilliant shortcut that works!
Tommy is offline   Reply With Quote
Thanked by:
Old 04-19-2012, 01:01 PM   #6
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Thanks. I started to look for some IK algorithms. I think it is beyond me.

Looking at the Inverse Kinetics IK it appears to be like the robotic arm?

I found this:http://www.darwin3d.com/gamedev/articles/col0998.pdf

I guess the two lengths would be the distance from the front wheels and the connection. The 2nd distance would be the distance from connector to rear wheels. But then using his formula. That would set the angle, right?

Last edited by gattispilot; 04-19-2012 at 02:25 PM.
gattispilot is online now   Reply With Quote
Old 04-19-2012, 02:14 PM   #7
Donamy
Beta Tester


Default

Something that seems so simple, has stumped all the rocket scientist here. How does Rigs and Rods do it ?
Donamy is offline   Reply With Quote
Old 04-19-2012, 11:54 PM   #8
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Is there a way to find out the angle a vessel is turning? I tried the oapiGetFocusBank(&bank)
gattispilot is online now   Reply With Quote
Old 04-20-2012, 12:07 AM   #9
tl8
Addon Developer
 
tl8's Avatar

Default

Quote:
Originally Posted by Donamy View Post
 Something that seems so simple, has stumped all the rocket scientist here. How does Rigs and Rods do it ?
They have their own physics engine that is designed for this sort of thing.

The problem here is that while we have the information, actually designing and programming such a system requires a sub physics engine.

---------- Post added at 10:07 AM ---------- Previous post was at 10:04 AM ----------

It is not unlike the SpaceX factory:

They have the tools and materials to make a car, but the design and production of the car from those tools and materials is quite hard.
tl8 is offline   Reply With Quote
Old 04-24-2012, 09:47 PM   #10
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Looking to find the yaw rate. I saw this post:


http://orbiter-forum.com/showthread.php?t=10845

Code:
GetAngularVel (avel);
double wrate=(avel.y);

sprintf(oapiDebugString(),"i3 %2.2f ANGLE1 %2.2f YAW2 %2.2f YAW3 %5.20f,", i3,ANGLE1,YAW2,wrate );
But when I turn I get 0.00000000000 for wrate. I want to base the amount of angle change on the turn rate.

Last edited by gattispilot; 04-24-2012 at 09:50 PM.
gattispilot is online now   Reply With Quote
Thanked by:
Old 04-26-2012, 01:05 PM   #11
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Here is a video of what we have. The turn angle is based off of the rudder/wheels.
http://s373.photobucket.com/albums/o...OVER13TEST.mp4

One thing that is odd is the dll version runs slower than the sc3. The values appear to be the same though.

Code:
SetSize (6);
	SetEmptyMass (610.0);
//	SetCW (0.3, 0.3, 0.6, 0.9);
	 SetCW(0.09,0.09,2,1.4);

	//SetWingAspect (0.1);
	//..SetWingEffectiveness (0.1);
	SetCrossSections (_V(10.69,10.71,6.81));
	//SetRotDrag (_V(0.1,0.1,0.1));
	SetPitchMomentScale (0.00005);
	SetBankMomentScale (0.00005);
	SetPMI (_V(0.50,0.50,0.50));
	SetTrimScale (0.05);
	SetCameraOffset (_V(0,1.176,1.352));
	
	SetTouchdownPoints  (_V(0,-1,1.502), _V(-1.09,-1,0), _V(1.09,-1,0));; 


th_main = CreateThruster (_V(0,0,0), _V(0,0,1), MAXMAINTH, TANK, ISP);
	CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);
		
	th_retro = CreateThruster (_V(0,0,0), _V(0,0,-1), MAXRETROTH, TANK, ISP);
	CreateThrusterGroup (&th_retro, 1, THGROUP_RETRO);
Code:
const double FUELMASS = 9709;
const double ISP = 2983;
const double MAXMAINTH = 15000;
const double MAXRETROTH = 15000;
const double MAXRCSTH = 15000;

the sc3 version:
EMPTY_MASS=610
FUEL_MASS=9709
MAIN_THRUST=15000
RETRO_THRUST=15000
HOVER_THRUST=0
ATTITUDE_THRUST=15000
ISP=2983 ;2913.76
;PMI=(1.09,1.10,0.82)
PMI=(0.50,0.50,0.50)
CROSS_SECTION=(10.69,10.71,6.81)
PITCH_MOMENT_SCALE=0.00005
BANK_MOMENT_SCALE=0.00005
LAND_PT1=(0,-0.802,1.502)
LAND_PT2=(-1.09,-0.802,0)
LAND_PT3=(1.09,-0.802,0)
VISIBLE=1
CAMERA=(0,1.176,1.352)
gattispilot is online now   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Addons > Addon Development


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 07:51 PM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 2007 - 2012, Orbiter-Forum.com. All rights reserved.