msrinivasan32 Posted February 20, 2019 Share Posted February 20, 2019 Hello, I've started a project with the IG template and am having trouble receiving the correct CIGI packets. I have the default ig_config.xml provided with the template and have made no changes to it. However, when I use a CIGI host emulator to change the attitude or position of the entity with the same ID, the received packets are wrong. Here is a snippet of the code for my packet callback function. void AppWorldLogic::entity_control(IG::CIGI::ICigiEntityControl* control) { if (control->getEntityID() == 200) { Math::vec3 rotation = control->getRotation(); Math::dvec3 position = control->getPosition(); char euler[50]; char pos[50]; sprintf(euler, "\nEuler Angles: %d, %d, %d\n", rotation[0], rotation[1], rotation[2]); sprintf(pos, "Position: %d, %d, %d\n", pos[0], pos[1], pos[2]); Log::message(euler); Log::message(pos); } else { Log::message("\nIncorrect entity type.\n"); } } The getEntityID() function returns the correct value so the program enters the conditional, however, the printed angles and position are incorrect. For example, when I change the roll, pitch, or yaw of the entity in the host emulator, the printed angles are all 0, but the position values change to arbitrary numbers that have no connection to those I entered for the angles. Any suggestions for what I'm doing wrong? Thank you Link to comment
cash-metall Posted February 21, 2019 Share Posted February 21, 2019 vec3 - float, float, float dvec3(Vec3) - double, double,double %d - for print int type change %d to %f or %.2f for print floating point number also, you can print directly Log::message("\nEuler Angles: %f, %f, %f\n", rotation[0], rotation[1], rotation[2]); Link to comment
msrinivasan32 Posted February 21, 2019 Author Share Posted February 21, 2019 Thank you. That fixed my rotation angle issue. However, the position values still do not change at all when I change latitude, longitude, or altitude. Do you have any suggestions there on what might be causing the issue? Is the getPosition() function meant to return something else? If so, is there a packet that contains altitude and how could I access it? Link to comment
cash-metall Posted February 21, 2019 Share Posted February 21, 2019 In entity control packet getPosition returns lat-lon-alt for top-level entity, or x-y-z offset for child entity. Whitch CIGI host are you used? Does a clean ig_template work with your host? Why do you read the entity-control package manually? this package is supported by default. Link to comment
msrinivasan32 Posted February 21, 2019 Author Share Posted February 21, 2019 I am using the Host Emulator 3.3. When I create a blank project with the ig_template, the packets are received just fine. In the default ig_template, is the be-200 entity (id = 200) a top-level entity or a child entity? When I created that clean project and tried to receive the packets for it, I was still getting x-y-z values where z was always 0 even when I change the altitude. Am I doing something wrong here? This project is to create an avionics panel that displays altitude, heading, attitude, and airspeed of an entity. The world has a geodetic pivot and a barebones terrain but aside from that, there is just a gui object that will contain sprites for each instrument. That's why I'm manually reading those packets, but if you know of a better way to do the same thing, I'm very open to suggestions. Link to comment
cash-metall Posted February 22, 2019 Share Posted February 22, 2019 Thank you for the clarification. This is a good decision. Strange, I just checked the ig_template: Create IG Template through sdk, Change the name of the world in the ig_config.xml, Create geo-pivot in Editor. Used HEMU for test everything works! Here is my code that I checked. only I checked the EntityType, not the EntityID /////////////////////////////..............///////////////////////// void read_entity_control(IG::CIGI::ICigiEntityControl* control) { if (control->getEntityType() == 200) //type = 200 for be-200. id - it`s unique entity identificator { Math::vec3 rotation = control->getRotation(); Math::dvec3 position = control->getPosition(); Log::message("position: %f %f %f\n", position.x, position.y, position.z); Log::message("rotation: %f %f %f\n", rotation.x, rotation.y, rotation.z); } else { Log::message("\nIncorrect entity type.\n"); } }; void AppSystemLogic::init_cigi() { int index = Engine::get()->findPlugin("CIGIConnector"); // check CIGIConnector plugin load if (index < 0) return; // get CIGI interface cigi = (IG::CIGI::ConnectorInterface*)Engine::get()->getPluginData(index); cigi->setReceivePacketCallback(IG::CIGI::CIGI_OPCODE_ENTITY_CONTROL, MakeCallback(&read_entity_control)); // it doesn't need to initialize connector // it initializes automatically (look at ig_config.xml file for more info) } 1 Link to comment
msrinivasan32 Posted February 25, 2019 Author Share Posted February 25, 2019 I copied and pasted your code over mine, but changed back to using getEntityID() instead of getEntityType() and it worked. Not sure what was that different from what I originally had, but thank you for your help! Link to comment
cash-metall Posted February 25, 2019 Share Posted February 25, 2019 Are you sure you are not confusing the concepts EntityID and TypeID? In the next topic, a similar problem due to such an error. Link to comment
msrinivasan32 Posted February 25, 2019 Author Share Posted February 25, 2019 Yes I think I now understand the difference as it appears in HEMU and the ig_config.xml. Thanks again for your help! Link to comment
Walters.Robert Posted July 31, 2019 Share Posted July 31, 2019 I'm finding similar issues with the new IG template using the ig manager interface and the IEntity class. Using your workflow above: Create IG Template through sdk, Change the name of the world in the ig_config.xml, Create geo-pivot in Editor. Used HEMU for test I add the following code under the update class in AppWorldLogic.cpp to get a print out of the entity's euler angles: int entityType = ig_manager->findEntityType("be-200"); Log::message("The 'be-200' entity type ID is (%i)\n", entityType); vec3 be200Euler = ig_manager->getEntity(entityType)->getRotationEuler(); Log::message("The 'be-200' euler rotations are (%f) (%f) (%f)\n", be200Euler.x, be200Euler.y, be200Euler.z); but this returns all zeros. (enityType message was commented out for the screen shot, i had changed it to 122 in the ig xml to match with the defaults in HEMU). Though the entity has clearly been added and rotated: The end goal is to get the euler angles of a ship that is rolling on the ocean surface. I will then use the roll euler angle to drive an articulated part in the opposite direction in order to keep a horizon bar that is mounted on the ship level with the horizon like the one pictured here: I can't do this directly from a cigi packet from our HOST as it is pretty locked down and won't let me send packets other than time of day and entity location / rotations (no support for components or articulated parts). Link to comment
cash-metall Posted August 1, 2019 Share Posted August 1, 2019 8 hours ago, Walters.Robert said: int entityType = ig_manager->findEntityType("be-200"); Log::message("The 'be-200' entity type ID is (%i)\n", entityType); vec3 be200Euler = ig_manager->getEntity(entityType)->getRotationEuler(); Log::message("The 'be-200' euler rotations are (%f) (%f) (%f)\n", be200Euler.x, be200Euler.y, be200Euler.z); findEntityType return TypeID for "be-200" from ig_config.xml getEntity(int entity_id) accepts an EntityID, not TypeID! try to change code vec3 be200Euler = ig_manager->getEntity(0)->getRotationEuler(); Log::message("The 'be-200' euler rotations are (%f) (%f) (%f)\n", be200Euler.x, be200Euler.y, be200Euler.z); Link to comment
Walters.Robert Posted August 1, 2019 Share Posted August 1, 2019 Thanks. Works as advertised. I think the confusion for most people is that in the ig_config.xml the typeID is simply labeled 'ID' and not 'typeID' thus leading people to think that they can type in that number to return the entity. Link to comment
Recommended Posts