Hi, I am trying to model a simple inline slider crank mechanism using AnyScript. I am quite new at this.
According to my understanding, I need four segments (24 DOFs), three Revolute Joints and a prismatic joints.
Here is my joint mechanisms:
joint 1: A revolute joint between the origin and one end of the crank.
joint 2: A revolute joint between crank tip and connecting rod end.
joint 3: A revolute joint between connecting rod and the slider segment
joint 4: A prismatic joint between slider and the base segment.
The driver for joint 1 has a rotational velocity. Drivers for all other joints have velocity 0.
If I do this, the system does not work as intended.
If I try to fix the base by introducing another joint between the origin and the left end of the base, then the system shows over-constrained.
Please let me know where I am going wrong and the correct solution. I am attaching the bad code for convenience.
Main = {
AnyFolder MyModel = {
// Global Reference Frame
AnyFixedRefFrame GlobalRef = {
/*AnyRefNode leftjnt ={
AnyDrawNode drawnode ={
ScaleXYZ = {0.09,0.09,0.9};
RGB = {1,0,0};
};
};*/
/*
AnyRefNode groundjnt ={
sRel = {8.5,0,0};
AnyDrawNode drawnode ={
ScaleXYZ = {0.09,0.09,0.9};
RGB = {1,0,0};
};
};*/
AnyDrawRefFrame DrwGlobalRef = {
RGB={1,0,0};
ScaleXYZ={3,0,0};
};
}; //Global Ref Frame
//******************************//
//--------- Segment-1 ---------//
//****************************//
AnyFolder Segment = {
AnySeg Segment1 = {
r0 = {1.5,0,0};
Mass = 10;
Jii = {0.1,5,5};
AnyRefNode Left1 = {
sRel = {-1.5,0,0};
};
AnyRefNode Right1 = {
sRel = {1.5,0,0};
};
AnyDrawSeg drwSegment1 = {
Opacity = 0.4;
};
}; //Segment1
AnySeg Segment2 ={
Mass = 10;
Jii = {0.1,10,10};
r0 = {6, 0,0};
AnyRefNode Right2 = {
sRel = {2.5, 0.0, 0};
};
AnyRefNode Left2 = {
sRel = {-2.5, 0.0, 0};
};
AnyDrawSeg Seg2 = {
Opacity= 0.4;
};
}; // Segment2
AnySeg Segment3 ={
Mass = 10;
Jii = {0.2,12,12};
r0={8,0,0};
AnyDrawSeg Seg3 = {
Opacity= 0.4;
};
};
AnySeg Segment4 ={
Mass = 10;
Jii = {0.1,0.1,0.1};
r0={9,0,0};
AnyDrawSeg Seg4 = {
Opacity= 0.4;
};
};
}; //Segment Folder
//**************************//
//----------Joint----------//
//*************************//
AnyFolder Joint ={
AnyRevoluteJoint Leftjnt = {
Axis = z;
AnyFixedRefFrame& Ground =Main.MyModel.GlobalRef;
AnyRefNode &LeftNode = Main.MyModel.Segment.Segment1.Left1;
};
AnyRevoluteJoint jnt3 = {
Axis = z;
AnyFixedRefFrame& Ground =Main.MyModel.GlobalRef;
AnySeg &LeftNode = Main.MyModel.Segment.Segment3;
};
AnyRevoluteJoint Middlejnt = {
Axis = x;
//Axis2 = z;
AnyRefNode &MiddleNode1 = Main.MyModel.Segment.Segment1.Right1;
AnyRefNode &MiddleNode2 = Main.MyModel.Segment.Segment2.Left2;
};
AnyRevoluteJoint secondRev = {
Axis =z;
AnySeg &seg4=Main.MyModel.Segment.Segment4;
AnyRefNode &node=Main.MyModel.Segment.Segment2.Right2;
};
AnyPrismaticJoint sliderjnt = {
Axis = x;
AnyRefNode &MiddleNode1 = Main.MyModel.Segment.Segment2.Right2;
AnySeg &MiddleNode2 = Main.MyModel.Segment.Segment3;
};
//
};// Joint
//----------Drivers----------//
AnyFolder Drivers = {
AnyKinEqSimpleDriver SimpleDriver = {
AnyRevoluteJoint &Jnt =Main.MyModel.Joint.Leftjnt ;
DriverPos = {30*pi/180};
DriverVel = {360*pi/180};
Reaction.Type = {Off};
};
AnyKinEqSimpleDriver SimpleDriver2 = {
AnyRevoluteJoint &Jnt2 =Main.MyModel.Joint.Middlejnt ;
DriverPos = {0}; // Because 2 degree of Freedom
DriverVel = {0};
Reaction.Type = {Off};
};
/*
AnyKinEqSimpleDriver SimpleDriver3 = {
AnyRevoluteJoint &Jnt =Main.MyModel.Joint.jnt3 ;
DriverPos = {0};
DriverVel = {0};
Reaction.Type = {Off};
};*/
AnyKinEqSimpleDriver SimpleDriver4 = {
AnyRevoluteJoint &Jnt2 =Main.MyModel.Joint.secondRev ;
DriverPos = {0}; // Because 2 degree of Freedom
DriverVel = {0};
Reaction.Type = {Off};
};
AnyKinEqSimpleDriver SimpleDriver5 = {
AnyPrismaticJoint &Jnt2 =Main.MyModel.Joint.sliderjnt ;
DriverPos = {0}; // Because 2 degree of Freedom
DriverVel = {0};
Reaction.Type = {Off};
};
}; // Drivers Folder
//---------Kninematics---------//
};// My Model Folder
//----------ModelStudy----------//
AnyBodyStudy ModelStudy = {
AnyFolder& Model = Main.MyModel;
Gravity = {0.0, -9.81, 0.0};
AnyKinEqSimpleDriver& Driver = Main.MyModel.Drivers.SimpleDriver;
AnyKinEqSimpleDriver& Driver2 = Main.MyModel.Drivers.SimpleDriver2;
//AnyKinEqSimpleDriver& Driver3 = Main.MyModel.Drivers.SimpleDriver3;
AnyKinEqSimpleDriver& Driver4 = Main.MyModel.Drivers.SimpleDriver4;
AnyKinEqSimpleDriver& Driver5 = Main.MyModel.Drivers.SimpleDriver5;
InverseDynamics.Criterion.Type = MR_MinMaxStrict;
}; // ModelStudy
}; // Main