Coppel.Damien Posted January 6, 2020 Share Posted January 6, 2020 (edited) Hi, I'm trying with Unigine to simulate the behavior of a helicopter gyrostabilized camera (something similar to this setup ) The real physical system I'm trying to simulate can keep looking at a specific point without being affected by the aircraft pitch or yaw, but it cannot compensate the roll of the aircraft, when the aircraft rotates on the roll axis, the system rotates the same way. I've tried to recreate that behavior with a component I called gimbal : void Gimbal::update() { quat helico_rotation = helicopter_node->getWorldRotation(); gimbal_node->setRotation(conjugate(helico_rotation)); } I have the following node hierarchy : helicopter_node is the parent of gimbal_node, both are basic nodes. gimbal_node symbolizes the system I'm trying to simulate that is attached to an aircraft symbolized by helicopter_node. First I tried to imitate the gyrostabilization by rotating the system by the cojugate quaternion of the aircraft, but this compensate the rotation of the aircraft on all axis and I need to keep the roll axis. I want gimbal_node to have the same rotation as the aircraft on the roll axis. void Gimbal::update() { quat helico_rotation = helicopter_node->getWorldRotation(); vec3 angles = decomposeRotationXYZ(helico_rotation.getMat3()); gimbal_node->setRotation(conjugate(helico_rotation) * quat(0.0f, angles.y, 0.0f)); } I then tried to get the angle of the aircraft on the roll axis and add it in a quaternion to the gimbal node but it doesn't work as I intented : when I start to rotate the aircraft on the roll axis, the gimbal system rotates the same way on the roll axis but at some point it starts to rotate in the opposite direction of the aircraft rotation. The outcome was predictable as mixing quaternion and euler angles is a terrible idea. It seems that I'm missing something here with the usage of quaternions, does anyone have an idea on how to achieve what I'm looking for ? Edited January 6, 2020 by Coppel.Damien Link to comment
morbid Posted January 8, 2020 Share Posted January 8, 2020 Hello Damien, Our team is back from the holidays. We'll think of possible solutions for gyrostablization, I will answer you after consulting a colleague. Thanks. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
alexander Posted January 8, 2020 Share Posted January 8, 2020 Hi Damien, Try to use setWorldDirection method. It doesn't give you full control (I mean setting min/max angles etc.), but it is a good start to solve your problem. void Gimbal::update() { // AXIS_Z - up (yaw) axis of the helicopter node // AXIS_Y - forward (roll) axis of the camera node vec3 dir = vec3(normalize(target->getWorldPosition() - gimbal_node->getWorldPosition())); gimbal_node->setWorldDirection(dir, helicopter_node->getWorldDirection(Math::AXIS_Z), Math::AXIS_Y); } I recommend to use vectors instead of quaternions. Then you can use decomposeRotationZXY (yaw, pitch, roll) and composeRotationZXY to clamp angles. Best regards, Alexander Link to comment
Recommended Posts