Hi,
thank you for the updated implementation. I re-ran my test case with chrono at commit 841781d6e0e4b09c68cd431e1f7381b402f17ad1.
The reaction torque vector does now rotate as expected with ChLinkMotorRotationSpeed. As shown in my example below there is now a constant angle difference of 90° between force and torque in the x-y plane.
However, with the ChLinkLockLock implementation I noticed that the angle of the torque vector seems to change only at half the speed of the body rotation. This leads to a constantly changing difference between force and torque direction in the x-y plane.
So perhaps there is also something wrong with the ChLinkLockLock's reaction torque direction (see example with output below).
Sorry for being naggy, your support is highly appreciated!
Best regards,
Simon
Code:
ChSystemNSC system{};
auto fixed_body{chrono_types::make_shared<ChBody>()};
fixed_body->SetBodyFixed(true);
auto rotating_body{chrono_types::make_shared<ChBody>()};
rotating_body->SetPos({1.0, 0.0, 0.0});
// Option 1: ChLinkMotorRotationSpeed
auto rotation_link{chrono_types::make_shared<ChLinkMotorRotationSpeed>()};
rotation_link->Initialize(rotating_body, fixed_body, ChFrame{});
rotation_link->SetSpeedFunction(chrono_types::make_shared<ChFunction_Const>(1.0));
// Option 2: ChLinkLockLock
// auto rotation_link{chrono_types::make_shared<ChLinkLockLock>()};
// rotation_link->Initialize(rotating_body, fixed_body, {});
// rotation_link->Set_angleset(chrono::AngleSet::ANGLE_AXIS);
// rotation_link->SetMotion_axis({0.0, 0.0, 1.0});
// rotation_link->SetMotion_ang(chrono_types::make_shared<ChFunction_Ramp>(0.0, 1.0));
system.Add(fixed_body);
system.Add(rotating_body);
system.Add(rotation_link);
system.Set_G_acc({0.0, 0.0, 10.0});
for (double time{}; time < 1.0; time += 0.01)
{
system.DoFrameDynamics(time);
const auto body_position{rotating_body->GetPos()};
const double body_angle{std::atan2(body_position[1], body_position[0])};
const auto reaction_force{rotation_link->Get_react_force()};
const double force_angle{std::atan2(reaction_force[1], reaction_force[0])};
const auto reaction_torque{rotation_link->Get_react_torque()};
const double torque_angle{std::atan2(reaction_torque[1], reaction_torque[0])};
std::cout << std::fixed << std::setprecision(3) << "Time: " << system.GetChTime()
<< " *** Body Angle: " << body_angle << " *** Force Angle: " << force_angle
<< " *** Torque Angle: " << torque_angle
<< " *** Angle Difference: " << force_angle - torque_angle << "\n";
}
Output using ChLinkMotorRotationSpeed:
...
Time: 0.950 *** Body Angle: 0.950 *** Force Angle: 0.940 *** Torque Angle: -0.631 *** Angle Difference: 1.571
Time: 0.960 *** Body Angle: 0.960 *** Force Angle: 0.950 *** Torque Angle: -0.621 *** Angle Difference: 1.571
Time: 0.970 *** Body Angle: 0.970 *** Force Angle: 0.960 *** Torque Angle: -0.611 *** Angle Difference: 1.571
Time: 0.980 *** Body Angle: 0.980 *** Force Angle: 0.970 *** Torque Angle: -0.601 *** Angle Difference: 1.571
Time: 0.990 *** Body Angle: 0.990 *** Force Angle: 0.980 *** Torque Angle: -0.591 *** Angle Difference: 1.571
Output using ChLinkLockLock:
...
Time: 0.950 *** Body Angle: 0.950 *** Force Angle: 0.940 *** Torque Angle: -1.096 *** Angle Difference: 2.036
Time: 0.960 *** Body Angle: 0.960 *** Force Angle: 0.950 *** Torque Angle: -1.091 *** Angle Difference: 2.041
Time: 0.970 *** Body Angle: 0.970 *** Force Angle: 0.960 *** Torque Angle: -1.086 *** Angle Difference: 2.046
Time: 0.980 *** Body Angle: 0.980 *** Force Angle: 0.970 *** Torque Angle: -1.081 *** Angle Difference: 2.051
Time: 0.990 *** Body Angle: 0.990 *** Force Angle: 0.980 *** Torque Angle: -1.076 *** Angle Difference: 2.056