Also please try to use PI's codec API as your college Andreas does.
ObjectSecurity Ltd. http://www.objectsecurity.com
Hallo Karel,
thank you very much for your support. The anyobject Any variable contains
all data coming from a complex structure (struct) defined in two specific
IDL files: commonBasicTypes.idl and AircraftInterface.idl. Here are the
--- commonBasicTypes.idl ---
#ifndef __COMMONBASICTYPES_IDL__
#define __COMMONBASICTYPES_IDL__
struct SGeoPos
{
double lat_wgs84; // degrees
double lon_wgs84; // degrees
double alt_wgs84_m;
};
typedef sequence <SGeoPos> LGeoPos;
struct S2dPos // e.g. referring to a pos in an OpenGL display
{
double x; // normally -1.0 to +1.0
double y; // normally -1.0 to +1.0
};
typedef sequence <S2dPos> L2dPos;
struct STime
{
long hour;
long min;
long sec;
double ms; // milliseconds
};
/**
Operation modes of a flight management system
*/
enum EFMSMode
{
FMS_MODE_OFFLINE, //!< FMS is offline (caused by operator or
"end-of-track")
FMS_MODE_TEMPORARY_OFFLINE, //!< The FMS is offline for batch processing
FMS_MODE_LNAV, //!< horizontal navigation only
FMS_MODE_VNAV, //!< horizontal and vertical navigation, no speed control
FMS_MODE_VNAV_SPEED //!< HNAV + VNAV + speed control
};
// Different approach modes for waypoints.
enum EWPMode
{
WAYPOINT_MODE_TRACK, //!< The default: Use the waypoint as "fly-by"
navigation hint.
WAYPOINT_MODE_OVERFLY, //!< Fly over the waypoint. No pre-turning is
allowed.
WAYPOINT_MODE_HOVER, //!< Hover at the waypoint. The FMS is not allowed
to advance to the next waypoint. This is only supported for rotorcrafts.
WAYPOINT_MODE_CIRCLE //!< Circle around the waypoint. The FMS is not
allowed to advance to the next waypoint.
};
enum EWaypointType
{
WAYPOINTTYPE_UNKNOWN,
WAYPOINTTYPE_GROUND,
WAYPOINTTYPE_AIR,
WAYPOINTTYPE_TRAJECTORY //more to come
};
enum EDesiredTurnMode
{
TURNMODE_TURNFLYBY,
TURNMODE_TURNFLYOVER,
TURNMODE_TURNFLYOVERINTERCEPT
};
struct STurnModeConstraint
{
boolean constraintDefined;
EDesiredTurnMode eTurnMode;
};
struct SPositionConstraint
{
boolean constraintDefined;
double allowedLateralDeviation_m;
};
enum EAltitudeType
{
ALTTYPE_WGS84,
ALTTYPE_AGL,
ALTTYPE_MSL,
ALTTYPE_FL
};
struct SAltitudeConstraint
{
boolean constraintDefined;
boolean preferdAltSet;
double preferedAlt_m;
EAltitudeType ePreferdAltType;
boolean maxAltSet;
double maxAlt_m;
EAltitudeType eMaxAltType;
boolean minAltSet;
double minAlt_m;
EAltitudeType eMinAltType;
};
struct STimeConstraint
{
boolean constraintDefined;
STime sTargetTime;
long timeEarly_s;
long timeLate_s;
};
struct SWaypoint
{
boolean initialized; // A waypoint is valid if this flag is true.
long id; // Unique ID for identification
string name; // The name of this waypoint.
SGeoPos sPos; // The WGS84 coordinates of the waypoint
boolean hasHeading; // If set to true, the waypoint has an ingress
heading. e.g. for VOR navigation or corridor entrance.
double heading_rad; // If hasHeading is true, then this is the ingress
heading for the waypoint.
double ingress_speed_m_s; // Ingress speed in meter per second for this
waypoint.
double circle_radius_m; // Circle radius in meter (only valid, if mode =
WAYPOINT_MODE_CIRCLE)
boolean circle_clockwise; // true for clockwise, false for
counter-clockwise (only valid, if mode = WAYPOINT_MODE_CIRCLE)
EWPMode mode;
EWaypointType eWaypointType;
STurnModeConstraint sTurnModeConstraint; // TODO: shift constraints to
routenplaner_cmd_qe
SPositionConstraint sPositionConstraint;
SAltitudeConstraint sAltitudeConstraint;
STimeConstraint sTimeConstraint;
};
typedef sequence<SWaypoint> LWaypoint;
typedef sequence<long> LWpId;
struct SRoute
{
boolean initialized; // A Route is valid if this flag is true.
long id; // Unique ID for identification
string name;
//long nextRoutepointId; // only for MiRA integration. moved to
SFMSOutput->sCurrentRoute.routepointIndex
//LWaypoint lWaypoint; // only for MiRA integration. moved to
SRouteData->lWaypoint
LWpId lWpId; // For the new FMS a route consists of waypoint ids.
Waypoints are stored separately. The order of the waypoints corresponds
to the sequence order
};
typedef sequence<SRoute> LRoute;
typedef sequence<long> LRouteIds;
#endif
---- AircraftInterface.idl ---
#ifndef AIRCRAFTINTERFACE_IDL
#define AIRCRAFTINTERFACE_IDL
#include "commonBasicTypes.idl"
enum EAircraftType
{
AIRCRAFTTYPE_PLANE,
AIRCRAFTTYPE_HELI
};
struct SIdentification
{
short id; //id specified by the scenario simulation (and send to x-plane
via the d-sim control plugin)
string name;
string identifier; //military or civil aircraft identifier
EAircraftType eAircraftType;
//EAircraftModel eAircraftModel;
boolean isManned;
};
struct SAircraftAttitude
{
double phi_rad; // roll
double theta_rad; // pitch
double psi_rad_magN; // yaw
double psi_rad_trueN; // yaw
};
struct SAircraftRates
{
//in flugzeugkoordinaten
double p_rad_s; // phi_dot
double q_rad_s; // theta_dot
double r_rad_s; // psi_dot
};
struct SAircraftAccelerations
{
//in flugzeugkoordinaten
double x_m_s_s;
double y_m_s_s;
double z_m_s_s;
};
struct SAircraftVelocities
{
double north_m_s;
double east_m_s;
double vertical_m_s;
double ias_m_s;
double cas_m_s;
double tas_m_s;
double gs_m_s;
};
struct SFlightMechanics
{
SGeoPos sPos;
SAircraftAttitude sAtt;
SAircraftRates sRat;
SAircraftAccelerations sAcc;
SAircraftVelocities sVel;
double magneticVariation_rad;
};
struct SRotorState
{
double rpm_rad_s;
double torque_nm;
double maxTorque_nm; //used for % calculation of the torque;
};
enum EEngineOperatingState
{
ENGINESTATE_ON,
ENGINESTATE_OFF,
ENGINESTATE_STARTUP
};
struct SEngineState
{
double rpm_rad_s;
double torque_nm;
double maxTorque_nm; // used for % calculation of the
torque
double curFuelConsumption_kg_s;
EEngineOperatingState eOpState;
};
enum EGearState
{
GEAR_UP,
GEAR_DOWN,
GEAR_TRANSIT
};
struct SGearState
{
EGearState nose;
EGearState right;
EGearState left;
};
struct SSystemData
{
SRotorState sRotor;
long noOfEngines;
sequence<SEngineState,2> sEngine;
SGearState sGear;
double flaps; //-1 .. +1
double spoiler; //-1 .. +1
double break; //-1 .. +1
};
struct SCurrentInput
{
double roll; //-1 .. +1
double pitch; //-1 .. +1
double yaw; //-1 .. +1
double collective; //-1 .. +1
double throttle1; //-1 .. +1 0= no power +1 100% power
double throttle2; //-1 .. +1 0= no power +1 100% power
double trimRoll; //-1 .. +1
double trimPitch; //-1 .. +1
double trimYaw; //-1 .. +1
double trimCollective; //-1 .. +1
double flaps; //-1 .. +1 -> 0 = neutral (in) +1= down -1 = up ????????
double brakes; //-1 .. +1
double spoiler;
boolean gearUp;
};
struct SSateliteState
{
boolean l1Locked;
boolean l2Locked;
};
struct SGPSHealth
{
double pdop_m; // positional dilution of precision
double hdop_m; // horizontal dilution of precision
long noSat; // number of satellites
sequence<SSateliteState,20> sSateliteState;
long itow_ms; // international time of week
};
struct SSystemHealth
{
SGPSHealth sGPS;
boolean destroyed; // true => the aircraft is lost
};
struct SBaroData
{
double pressure_hPa;
double qnh_hPa;
double alt_m;
};
struct SSensorics
{
boolean hasGroundContact;
double airTemp_celsius;
SBaroData sBaroData;
double radarAlt_m;
double sonarAlt_m;
double laserAlt_m;
};
struct SWindData
{
double speed_m_s;
double dir_rad_magN;
double dir_rad_trueN;
};
struct SWeatherData
{
SWindData sWind;
};
struct SAircraftInterface
{
SIdentification sId;
SFlightMechanics sFm;
SSystemData sSystem;
SSystemHealth sHealth;
SSensorics sSensorics;
SWeatherData sWeather;
SCurrentInput sCurrentInput;
double simTime;
};
#endif
Here is the also the source cpp file I wrote and used to simulate a
serialization process variables of type SAircraftInterface
--- codec_test.cpp ---
#include <QApplication>
#include "anyserial.h"
#include "ifDKAircraftInterface.h"
using namespace std;
int main( int argc, char *argv[])
{
SAircraftInterface_var aci_src, aci_dst;
CORBA::Any anyobject_src, anyobject_dst;
OctetSeq sequence;
QApplication app(argc, argv);
aci_src = new SAircraftInterface;
aci_dst = new SAircraftInterface;
//identification
aci_src->sId.name="MiRA 1";
aci_src->sId.isManned = true;
aci_src->sId.eAircraftType = AIRCRAFTTYPE_HELI;
//position
aci_src->sFm.sPos.lat_wgs84 = 10.0;
aci_src->sFm.sPos.lon_wgs84 = 20.0;
aci_src->sFm.sPos.alt_wgs84_m = 5.0;
// Convert anyobject_src to an octet sequence using MICO internal codec
anyobject_src <<= *aci_src;
anyobject_src >> sequence;
// Show octet sequence length
cout << "sequence.length: " << sequence.length() << endl;
// Try to convert octet sequence to anyobject_dst using MICO internal codec
try
{
anyobject_dst << sequence;
anyobject_dst >>= *aci_dst;
cout << "aci.name: " << aci_dst->sId.name << endl;
cout << "Sequence converted back to object of type Any." << endl;
}
catch (...)
{
cout << "Error trying to convert sequence back to object of type Any."
<< endl;
}
return ( 0 );
}
1. If you remove the line where QApplication is called the try section
works and the result is of 4016 octet for the sequence generated by the
codec;
2. If you leave the line where QAppliaction is called the try section
works well only when the two lines where aci_src and aci_dst variables are
allocated through the new operator have been placed before the
QApplication, otherwise an exception is catched and the sequence results
of 3748 octet, exactely 268 octet less than normal, as I already specified
in my previous e-mail.
void operator>> ( const Any& anyobject, OctetSeq& dataseq)
2. ifDKAircraftInterface.h has been generated with the Mico idl compiler
#ifndef __IFDKAircraftInterface_IDL__
#define __IFDKAircraftInterface_IDL__
#include "AircraftInterface.idl"
interface ifDKAircraftInterface
{
SAircraftInterface ReadData ( );
void WriteData ( in SAircraftInterface var );
long long GetVersion ( );
};
#endif // #ifndef __IFDKAircraftInterface_IDL__
Many Thanks in advance,
Pasquale Zarcone
Post by Karel GardasHello,
what exactly does your anyobject Any variable contain? The strange thing
is that you are only able to duplicate the issue when you use Qt...
Cheers,
Karel
Post by Andreas BenzlerHallo,
I´m using a client-server model based on Mico and I defined an idl
interface ifRec
{
long Register( in string name, in string ns );
void WriteData( in long id, in any data );
void SetEnv( in string Key, in string Value );
void Rec();
void Break();
void Resume();
void Replay( in double speed );
void Stop();
long Load( in string filename );
};
The WriteData function uses the parameter "data" of type Any, which
represents a structure (struct) containing other structures inside, and I
get a run-time error whenever a client calls this function. The client has
been compiled with Qt and uses the QApplication function. I discovered
that the run-time error it´s based on the problem that the object of type
Any is codified in the wrong way from Mico during the serialization
process only when the QApplication function is used in the client code and
also when the tree´s depth of the structures codified in the Any object is
too big, otherwise no run-time error comes up and the octet sequence that
represents the object, made by the Mico serialization process, has the
correct length. I also discovered that the difference between the octet
sequence with and without using QApplication is fixed and always 268 bytes
(more bytes without QApplication) and it does not depend on the complexity
of the structure that the Any object represents. I discovered this last
detail simulating a serialization process of the Any object using the
available Mico internal codec. I tried to compile the system with the two
Mico versions 2.3.11 and 2.3.13, both versions compiled specifying also the
--with-qt=<qt-path> directive for the configure script, but I have same
problems.
void operator>> ( const Any& anyobject, OctetSeq& dataseq)
{
// Codec
ORB_var orb;
Object_var obj;
IOP::CodecFactory_var cf;
IOP::Encoding enc2;
IOP::Codec_ptr codec_ptr;
// Generate codec based on CodecFactory
int argc = 1;
char* argv[1];
argv[0] = "anyserial";
orb = ORB_init( argc, argv, "mico-local-orb" );
obj = orb->resolve_initial_references("CodecFactory");
cf = IOP::CodecFactory::_narrow(obj);
enc2.format = IOP::ENCODING_CDR_ENCAPS;
enc2.major_version = 1;
enc2.minor_version = 2;
codec_ptr = cf->create_codec(enc2);
// Encode anyobject and generate a new octet sequence
OctetSeq_var newdataseq_ptr = codec_ptr->encode(anyobject);
int length = newdataseq_ptr->length();
// Copy generated octet sequence into dataseq
dataseq.length(length);
for (int i=0; i<length; i++)
dataseq[i] = (*newdataseq_ptr)[i];
}
Any and OctetSeq types are exactly CORBA::Any and CORBA::OctetSeq types
defined in MICO.
Could please anyone help to understand why Mico has this strange behavior
and eventually to find a solution?
Many Thanks in advance,
Pasquale Zarcone
Because the mail did not come trough with my colleges account I post
this message on his behalf
Andreas
_______________________________________________
Mico-devel mailing list
http://www.mico.org/mailman/listinfo/mico-devel
--
ObjectSecurity Ltd. http://www.objectsecurity.com
_______________________________________________
Mico-devel mailing list
http://www.mico.org/mailman/listinfo/mico-devel