1
0
Fork 0

Merge commit 'refs/merge-requests/1552' of git@gitorious.org:fg/flightgear into next

Conflicts:

	src/MultiPlayer/multiplaymgr.cxx
This commit is contained in:
Csaba Halasz 2010-09-09 00:48:17 +02:00
commit fdbfd6fd0b
9 changed files with 138 additions and 72 deletions

View file

@ -479,6 +479,10 @@ bool FGAIBallistic::getSlaved() const {
return _slave_to_ac;
}
bool FGAIBallistic::getFormate() const {
return _formate_to_ac;
}
double FGAIBallistic::getMass() const {
return _mass;
}

View file

@ -105,6 +105,7 @@ public:
bool getHtAGL(double start);
bool getSlaved() const;
bool getFormate() const;
bool getSlavedLoad() const;
virtual const char* getTypeString(void) const { return "ballistic"; }

View file

@ -142,7 +142,7 @@ bool FGAIEscort::init(bool search_in_AI_path) {
no_roll = false;
props->setStringValue("controls/parent-name", _parent.c_str());
setParent();
setParentNode();
pos = _tgtpos;
speed = _parent_speed;
hdg = _parent_hdg;
@ -233,7 +233,7 @@ bool FGAIEscort::getGroundElev(SGGeod inpos) {
}
void FGAIEscort::setParent() {
void FGAIEscort::setParentNode() {
const SGPropertyNode_ptr ai = fgGetNode("/ai/models", true);
@ -263,29 +263,75 @@ void FGAIEscort::setParent() {
if (_selected_ac != 0){
const string name = _selected_ac->getStringValue("name");
double lat = _selected_ac->getDoubleValue("position/latitude-deg");
double lon = _selected_ac->getDoubleValue("position/longitude-deg");
double elevation = _selected_ac->getDoubleValue("position/altitude-ft");
_MPControl = _selected_ac->getBoolValue("controls/mp-control");
setParent();
_selectedpos.setLatitudeDeg(lat);
_selectedpos.setLongitudeDeg(lon);
_selectedpos.setElevationFt(elevation);
//double lat = _selected_ac->getDoubleValue("position/latitude-deg");
//double lon = _selected_ac->getDoubleValue("position/longitude-deg");
//double elevation = _selected_ac->getDoubleValue("position/altitude-ft");
//_MPControl = _selected_ac->getBoolValue("controls/mp-control");
_parent_speed = _selected_ac->getDoubleValue("velocities/speed-kts");
_parent_hdg = _selected_ac->getDoubleValue("orientation/true-heading-deg");
//_selectedpos.setLatitudeDeg(lat);
//_selectedpos.setLongitudeDeg(lon);
//_selectedpos.setElevationFt(elevation);
if(!_stn_deg_true){
_stn_truebrg = calcTrueBearingDeg(_stn_brg, _parent_hdg);
_stn_relbrg = _stn_brg;
//cout << _name <<" set rel"<<endl;
} else {
_stn_truebrg = _stn_brg;
_stn_relbrg = calcRelBearingDeg(_stn_brg, _parent_hdg);
//cout << _name << " set true"<<endl;
}
//_parent_speed = _selected_ac->getDoubleValue("velocities/speed-kts");
//_parent_hdg = _selected_ac->getDoubleValue("orientation/true-heading-deg");
double course2;
//if(!_stn_deg_true){
// _stn_truebrg = calcTrueBearingDeg(_stn_brg, _parent_hdg);
// _stn_relbrg = _stn_brg;
// //cout << _name <<" set rel"<<endl;
//} else {
// _stn_truebrg = _stn_brg;
// _stn_relbrg = calcRelBearingDeg(_stn_brg, _parent_hdg);
// //cout << _name << " set true"<<endl;
//}
//double course2;
//SGGeodesy::direct( _selectedpos, _stn_truebrg, _stn_range * SG_NM_TO_METER,
// _tgtpos, course2);
//_tgtpos.setElevationFt(_stn_height);
//calcRangeBearing(pos.getLatitudeDeg(), pos.getLongitudeDeg(),
// _tgtpos.getLatitudeDeg(), _tgtpos.getLongitudeDeg(), _tgtrange, _tgtbrg);
//_relbrg = calcRelBearingDeg(_tgtbrg, hdg);
} else {
SG_LOG(SG_GENERAL, SG_ALERT, "AIEscort: " << _name
<< " parent not found: dying ");
setDie(true);
}
}
void FGAIEscort::setParent()
{
double lat = _selected_ac->getDoubleValue("position/latitude-deg");
double lon = _selected_ac->getDoubleValue("position/longitude-deg");
double elevation = _selected_ac->getDoubleValue("position/altitude-ft");
_MPControl = _selected_ac->getBoolValue("controls/mp-control");
_selectedpos.setLatitudeDeg(lat);
_selectedpos.setLongitudeDeg(lon);
_selectedpos.setElevationFt(elevation);
_parent_speed = _selected_ac->getDoubleValue("velocities/speed-kts");
_parent_hdg = _selected_ac->getDoubleValue("orientation/true-heading-deg");
if(!_stn_deg_true){
_stn_truebrg = calcTrueBearingDeg(_stn_brg, _parent_hdg);
_stn_relbrg = _stn_brg;
//cout << _name <<" set rel"<<endl;
} else {
_stn_truebrg = _stn_brg;
_stn_relbrg = calcRelBearingDeg(_stn_brg, _parent_hdg);
//cout << _name << " set true"<<endl;
}
double course2;
SGGeodesy::direct( _selectedpos, _stn_truebrg, _stn_range * SG_NM_TO_METER,
_tgtpos, course2);
@ -297,12 +343,6 @@ void FGAIEscort::setParent() {
_relbrg = calcRelBearingDeg(_tgtbrg, hdg);
} else {
SG_LOG(SG_GENERAL, SG_ALERT, "AIEscort: " << _name
<< " parent not found: dying ");
setDie(true);
}
}
void FGAIEscort::calcRangeBearing(double lat, double lon, double lat2, double lon2,

View file

@ -51,7 +51,7 @@ private:
virtual void update (double dt);
void setParentName(const std::string& p);
void setParent();
void setParentNode();
void setStnRange(double r);
void setStnBrg(double y);
void setStationSpeed();
@ -61,6 +61,7 @@ private:
void setStnHtFt(double h);
void setStnPatrol(bool p);
void setStnDegTrue(bool t);
void setParent();
void setMaxSpeed(double m);
void setUpdateInterval(double i);

View file

@ -61,9 +61,9 @@ void FGAIGroundVehicle::readFromScenario(SGPropertyNode* scFileNode) {
FGAIShip::readFromScenario(scFileNode);
setNoRoll(scFileNode->getBoolValue("no-roll", true));
setName(scFileNode->getStringValue("name", "groundvehicle"));
setSMPath(scFileNode->getStringValue("submodel-path", ""));
setParentName(scFileNode->getStringValue("parent", ""));
setNoRoll(scFileNode->getBoolValue("no-roll", true));
setContactX1offset(scFileNode->getDoubleValue("contact-x1-offset", 0.0));
setContactX2offset(scFileNode->getDoubleValue("contact-x2-offset", 0.0));
setXOffset(scFileNode->getDoubleValue("hitch-x-offset", 35.0));
@ -74,7 +74,6 @@ void FGAIGroundVehicle::readFromScenario(SGPropertyNode* scFileNode) {
setYawoffset(scFileNode->getDoubleValue("yaw-offset", 0.0));
setPitchCoeff(scFileNode->getDoubleValue("pitch-coefficient", 0.1));
setElevCoeff(scFileNode->getDoubleValue("elevation-coefficient", 0.25));
setParentName(scFileNode->getStringValue("parent", ""));
setTowAngleGain(scFileNode->getDoubleValue("tow-angle-gain", 1.0));
setTowAngleLimit(scFileNode->getDoubleValue("tow-angle-limit-deg", 2.0));
setInitialTunnel(scFileNode->getBoolValue("tunnel", false));
@ -125,7 +124,7 @@ void FGAIGroundVehicle::unbind() {
FGAIShip::unbind();
props->untie("controls/constants/elevation-coeff");
props->untie("controls/constants/pitch-coeff");
props->untie("controls/constants/pitch-coeff");
props->untie("position/ht-AGL-ft");
props->untie("hitch/rel-bearing-deg");
props->untie("hitch/tow-angle-deg");
@ -149,6 +148,9 @@ bool FGAIGroundVehicle::init(bool search_in_AI_path) {
invisible = false;
_limit = 200;
no_roll = true;
props->setStringValue("controls/parent-name", _parent.c_str());
setParentNode();
return true;
}
@ -342,12 +344,15 @@ bool FGAIGroundVehicle::getPitch() {
}
getGroundElev(pos);
//getGroundElev(pos);
return true;
}
void FGAIGroundVehicle::setParent() {
void FGAIGroundVehicle::setParentNode() {
if(_parent == "")
return;
const SGPropertyNode_ptr ai = fgGetNode("/ai/models", true);
@ -377,40 +382,16 @@ void FGAIGroundVehicle::setParent() {
if (_selected_ac != 0){
const string name = _selected_ac->getStringValue("name");
double lat = _selected_ac->getDoubleValue("position/latitude-deg");
double lon = _selected_ac->getDoubleValue("position/longitude-deg");
double elevation = _selected_ac->getDoubleValue("position/altitude-ft");
double hitch_x_offset_m = _selected_ac->getDoubleValue("hitch/x-offset-ft")
* SG_FEET_TO_METER;
double hitch_y_offset_m = _selected_ac->getDoubleValue("hitch/y-offset-ft")
* SG_FEET_TO_METER;
double hitch_z_offset_m = _selected_ac->getDoubleValue("hitch/z-offset-ft")
* SG_FEET_TO_METER;
_selectedpos.setLatitudeDeg(lat);
_selectedpos.setLongitudeDeg(lon);
_selectedpos.setElevationFt(elevation);
_parent_x_offset = _selected_ac->getDoubleValue("hitch/x-offset-ft");
_parent_y_offset = _selected_ac->getDoubleValue("hitch/y-offset-ft");
_parent_z_offset = _selected_ac->getDoubleValue("hitch/z-offset-ft");
_parent_speed = _selected_ac->getDoubleValue("velocities/true-airspeed-kt");
SGVec3d rear_hitch(-hitch_x_offset_m, hitch_y_offset_m, 0);
SGVec3d RearHitch = getCartHitchPosAt(rear_hitch);
SGGeod rearpos = SGGeod::fromCart(RearHitch);
double user_lat = rearpos.getLatitudeDeg();
double user_lon = rearpos.getLongitudeDeg();
double range, bearing;
calcRangeBearing(pos.getLatitudeDeg(), pos.getLongitudeDeg(),
user_lat, user_lon, range, bearing);
_range_ft = range * 6076.11549;
_relbrg = calcRelBearingDeg(bearing, hdg);
_hitch_x_offset_m = _selected_ac->getDoubleValue("hitch/x-offset-ft")
* SG_FEET_TO_METER;
_hitch_y_offset_m = _selected_ac->getDoubleValue("hitch/y-offset-ft")
* SG_FEET_TO_METER;
_hitch_z_offset_m = _selected_ac->getDoubleValue("hitch/z-offset-ft")
* SG_FEET_TO_METER;
setParent();
} else {
SG_LOG(SG_GENERAL, SG_ALERT, "AIGroundVeh1cle: " << _name
<< " parent not found: dying ");
@ -419,6 +400,34 @@ void FGAIGroundVehicle::setParent() {
}
void FGAIGroundVehicle::setParent(){
double lat = _selected_ac->getDoubleValue("position/latitude-deg");
double lon = _selected_ac->getDoubleValue("position/longitude-deg");
double elevation = _selected_ac->getDoubleValue("position/altitude-ft");
_selectedpos.setLatitudeDeg(lat);
_selectedpos.setLongitudeDeg(lon);
_selectedpos.setElevationFt(elevation);
_parent_speed = _selected_ac->getDoubleValue("velocities/true-airspeed-kt");
SGVec3d rear_hitch(-_hitch_x_offset_m, _hitch_y_offset_m, 0);
SGVec3d RearHitch = getCartHitchPosAt(rear_hitch);
SGGeod rearpos = SGGeod::fromCart(RearHitch);
double user_lat = rearpos.getLatitudeDeg();
double user_lon = rearpos.getLongitudeDeg();
double range, bearing;
calcRangeBearing(pos.getLatitudeDeg(), pos.getLongitudeDeg(),
user_lat, user_lon, range, bearing);
_range_ft = range * 6076.11549;
_relbrg = calcRelBearingDeg(bearing, hdg);
}
void FGAIGroundVehicle::calcRangeBearing(double lat, double lon, double lat2, double lon2,
double &range, double &bearing) const
{

View file

@ -65,6 +65,7 @@ private:
void setParentName(const string& p);
void setTrainSpeed(double s, double dt, double coeff);
void setParent();
void setParentNode();
void AdvanceFP();
void setTowSpeed();
void RunGroundVehicle(double dt);
@ -93,6 +94,7 @@ private:
double _range_ft;
double _relbrg;
double _parent_speed, _parent_x_offset, _parent_y_offset, _parent_z_offset;
double _hitch_x_offset_m, _hitch_y_offset_m, _hitch_z_offset_m;
double _dt_count, _next_run, _break_count;
const SGMaterial* _material;

View file

@ -99,6 +99,7 @@ void FGAIShip::readFromScenario(SGPropertyNode* scFileNode) {
setRudderConstant(scFileNode->getDoubleValue("rudder-constant", 0.5));
setFixedTurnRadius(scFileNode->getDoubleValue("fixed-turn-radius-ft", 500));
setSpeedConstant(scFileNode->getDoubleValue("speed-constant", 0.5));
setSMPath(scFileNode->getStringValue("submodel-path", ""));
if (!flightplan.empty()) {
SG_LOG(SG_GENERAL, SG_ALERT, "getting flightplan: " << _name );
@ -250,12 +251,12 @@ void FGAIShip::update(double dt) {
// Update the velocity information stored in those nodes.
// Transform that one to the horizontal local coordinate system.
SGQuatd ec2hl = SGQuatd::fromLonLat(pos);
// The orientation of the carrier wrt the horizontal local frame
// The orientation of the ship wrt the horizontal local frame
SGQuatd hl2body = SGQuatd::fromYawPitchRollDeg(hdg, pitch, roll);
// and postrotate the orientation of the AIModel wrt the horizontal
// local frame
SGQuatd ec2body = ec2hl*hl2body;
// The cartesian position of the carrier in the wgs84 world
// The cartesian position of the ship in the wgs84 world
SGVec3d cartPos = SGVec3d::fromGeod(pos);
// The simulation time this transform is meant for
@ -680,7 +681,7 @@ void FGAIShip::ProcessFlightPlan(double dt) {
if (_next_name == "TUNNEL"){
_tunnel = !_tunnel;
SG_LOG(SG_GENERAL, SG_ALERT, "AIShip: " << _name << " " << sp_turn_radius_nm );
SG_LOG(SG_GENERAL, SG_DEBUG, "AIShip: " << _name << " " << sp_turn_radius_nm );
fp->IncrementWaypoint(false);
next = fp->getNextWaypoint();
@ -697,7 +698,7 @@ void FGAIShip::ProcessFlightPlan(double dt) {
}else if(_next_name == "END" || fp->getNextWaypoint() == 0) {
if (_repeat) {
SG_LOG(SG_GENERAL, SG_ALERT, "AIShip: "<< _name << " Flightplan repeating ");
SG_LOG(SG_GENERAL, SG_INFO, "AIShip: "<< _name << " Flightplan repeating ");
fp->restart();
prev = curr;
curr = fp->getCurrentWaypoint();
@ -711,7 +712,7 @@ void FGAIShip::ProcessFlightPlan(double dt) {
_lead_angle = 0;
AccelTo(prev->speed);
} else if (_restart){
SG_LOG(SG_GENERAL, SG_ALERT, "AIShip: " << _name << " Flightplan restarting ");
SG_LOG(SG_GENERAL, SG_INFO, "AIShip: " << _name << " Flightplan restarting ");
_missed_count = 0;
initFlightPlan();
} else {
@ -755,7 +756,7 @@ void FGAIShip::ProcessFlightPlan(double dt) {
_until_time = next->time;
setUntilTime(next->time);
if (until_time_sec > time_sec) {
SG_LOG(SG_GENERAL, SG_ALERT, "AIShip: " << _name << " "
SG_LOG(SG_GENERAL, SG_INFO, "AIShip: " << _name << " "
<< curr->name << " waiting until: "
<< _until_time << " " << until_time_sec << " now " << time_sec );
setSpeed(0);
@ -763,7 +764,7 @@ void FGAIShip::ProcessFlightPlan(double dt) {
_waiting = true;
return;
} else {
SG_LOG(SG_GENERAL, SG_DEBUG, "AIShip: "
SG_LOG(SG_GENERAL, SG_INFO, "AIShip: "
<< _name << " wait until done: getting new waypoints ");
setUntilTime("");
fp->IncrementWaypoint(false);

View file

@ -75,6 +75,11 @@ void FGAIWingman::bind() {
&FGAIBase::_getLongitude,
&FGAIBase::_setLongitude));
props->tie("controls/formate-to-ac",
SGRawValueMethods<FGAIBallistic,bool>
(*this, &FGAIBallistic::getFormate, &FGAIBallistic::setFormate));
props->tie("orientation/pitch-deg", SGRawValuePointer<double>(&pitch));
props->tie("orientation/roll-deg", SGRawValuePointer<double>(&roll));
props->tie("orientation/true-heading-deg", SGRawValuePointer<double>(&hdg));
@ -122,6 +127,8 @@ void FGAIWingman::unbind() {
props->untie("orientation/roll-deg");
props->untie("orientation/true-heading-deg");
props->untie("controls/formate-to-ac");
props->untie("submodels/serviceable");
props->untie("velocities/true-airspeed-kt");

View file

@ -159,6 +159,7 @@ FGMultiplayMgr::sIdPropertyList[] = {
{1101, "sim/model/livery/file", simgear::props::STRING},
{1200, "environment/wildfire/data", simgear::props::STRING},
{1201, "environment/contrail", simgear::props::INT},
{1300, "tanker", simgear::props::INT},