FlexSim's kinematics functionality allows you to have a single object perform several travel operations through one common interface. Each travel operation can have its own acceleration, deceleration, startspeed, endspeed, and maximum speed properties. Travel operations can overlap with each other, or be performed in sequence.
Below is a time-based plot of two kinematics performed in sequence:
And a time-based plot of two kinematics that overlap each other:
Kinematics can also be used just to make it easier to handle the math for any logic that involves speeds, rates, accelerations, decelerations, etc.
As an example, an overhead crane usually has several motors that drive it. One motor drives the bridge along a railing, while another motor drives a trolley along the bridge, while another lifts the hook or grabber by a cable. Each of these motors may have their own acceleration, deceleration, and maximum speed properties. Using kinematics, you can define all of these motions through a single kinematics interface, where different motors can work simultaneously, giving the motion of the crane's end effector a very dynamic behavior. Before kinematics were introduced, the simplest way to simulate this behavior was to have three different objects hierarchically ordered in the model tree, each object simulating one motion or kinematic. While this works very well in some cases, in other instances it can become tedious and unfriendly. Kinematic functionality attempts to fix this problem by allowing one object to do several motions or kinematics simultaneously.
The following is a summary of the kinematics commands:
This parameter set assumes you have an object that you want to move, like a transporter. The first parameter, again, is a blank node kinematic data, either a label, attribute, or variable. The second parameter is the object that will do the moving. The command will save off the object's initial location and rotation. The optional parameter managerotation is either 1 or 0. If 1, the rotation of the object will be set according to the velocity of the object at any given time. By default, the object's positive x direction will always point in the direction of the object's current velocity. This would be used, for example, if you have a truck that you always want to point forward as it travels. If managerotation is passed as 0, then the object won't rotate unless given commands to rotate, which will be explained later. If you do not specify this parameter, then by default, managerotate is set to 0. The optional localcoords parameter specifies the orientation of subsequent travel command locations. For example, if my truck is rotated 45 degrees, and I want it to travel 5 units in the x direction, this can be interpreted in two different ways. Do I want it to travel 5 units in x according to the truck's coordinate system, or 5 units in x according to the model's coordinate system (or the coordinate system of the truck's container)? In the former case, the object would actually travel 3.5 units in the x direction and 3.5 units in the y direction according to the model's coordinate space. In the latter case, however, the object would travel the usual 5 in the x direction according to the model's coordinate space. The localcoords parameter specifies which coordinate system you want to use. If 1 is passed, the object's coordinate system will be used (the former case). Note that only the object's initial coordinate system will be used to calculate locations, not subsequent coordinate systems if the object rotates later on in the kinematics. If 0 is passed, the object's container's coordinate system will be used (the latter case). If you do not specify this parameter, the default is 0.
This parameter set allows you to explicitly pass initial locations and rotations, instead of referencing an object. Although you would probably more often use the other parameter set where you pass the object in, this parameter set gives you ultimate flexibility. Use this if you want to explicitly pass in the initial locations and rotations of the object, or if your location and rotation values don't necessarily represent real locations and rotations in your model. For example, you are simulating a robot arm, and there are several joints of the arm that move/rotation with different acceleration/deceleration/max speed values. The visualization of movements of the arm are not simulated with explicit Flexsim locations/rotations, but are done using your own draw commands and labels or variables. In this case, you don't want kinematics to be applied to straight rotations and locations, but rather to information that you are keeping on the object yourself. In such situations, a given set of kinematics does not need to be viewed as applied directly to x,y,z locations and x,y,z, rotations, but can rather be viewed as six separate kinematic motions, each along one axis. These six axes can represent whatever you want them to. For example, your robot has four joints, each with one rotation value. To have the four joints of the robot move using kinematics, you can have each joint simulate one axis in the kinematics. The x part of the kinematics applies to the rotation of joint 1, the y part applies to the rotation of joint 2, the z part applies to the rotation of joint 3, and the rx part applies to the rotation of joint 4. The other two parts of the kinematics, ry and rz, you don't worry about. You can initialize the kinematics with the start rotations of each of your 4 joints, and then add kinematics that apply to each joint individually. Then, when you want to get the joints' current rotation values out later to draw the robot arm in motion, you can use the getkinematics command instead of the updatekinematics command to get the values explicitly, and not have them be applied to an object's location or rotation. These commands will be explained later.
This command would only be used if managerotation is passed into initkinematics as 1. This allows you to set an initial rotation from which the rotation is managed. By default, the object's positive x direction will always point in the direction of the object's current velocity. In the case of a truck, you may want the truck, instead of always being rotated so that it is traveling forward, to travel backward. Here you could specify a rotation offset of (0,0,180).
This command adds a kinematic to the set of kinematics. The x, y, and z parameters make up an offset location or rotation. For example, the location (5,5,0) tells the kinematic to travel 5 in the x and 5 in the y. Note that these are offsets from the object's current position, and not absolute locations. The targetspeed parameter specifies the target speed for the travel operation. The other parameters are optional. Acc specifies the acceleration. Dec specifies the deceleration. Startspeed specifies the speed that the kinematic should start at. If this speed is higher that the target speed, then the object will start at the start speed and decelerate down to the target speed. Endspeed specifies the ending speed for the operation. If endspeed is greater than targetspeed, then at the end of the operation, the object will accelerate from the target speed to the end speed. The starttime is the start time of the kinematic, in simulation time, not as an offset from the current time. The type parameter specifies what type of kinematic it is. This value will usually either be KINEMATIC_TRAVEL, or KINEMATIC_ROTATE. If it is KINEMATIC_TRAVEL, the operation will be applied to the x, y, and z location values. If it is KINEMATIC_ROTATE, the operation will be applied to the rx, ry, and rz rotation values, and speeds are defined in degrees per unit of time, accelerations/decelerations in degrees per unit of time squared. The command returns the time that this kinematic operation will finish.
Below is a time-based plot of a kinematic that travels 3 in the x and 2 in the y, with accelerations and decelerations.
In addition to KINEMATIC_TRAVEL and KINEMATIC_ROTATE, there are three "turn" kinematic types, which cause the moving object to turn a certain angle with a given turn radius. These are KINEMATIC_TURN_XY, KINEMATIC_TURN_YZ, and KINEMATIC_TURN_ZX. For these kinematic types, the x, y, and z parameters that you pass into addkinematic() take on a different meaning, as follows:
All other parameters are the same for this kinematic type, i.e. max speed, acceleration, deceleration, etc. Speeds are in length units per time unit, NOT in degrees per time unit.
As an example, if you would like to make a motion that turns from travelling positive along the x axis to travelling at 60 degrees off the x axis, with a turn radius of 5 (i.e. turn about the z axis), call:
addkinematic(kinematics, 0, 60, 5, 1, 1, 1, 0, 0, time(), KINEMATIC_TURN_XY);
This command should be called in the middle of the kinematic operation, usually on predraw or draw. It calculates and then sets the current location and rotation of the object, according to all kinematics that have been added and the current update time. The updatetime parameter is optional. If it is not passed, the current simulation time is used.
This command is used if you want to get explicit information on the kinematics. You can get information on the entire set of kinematics, or on each individual kinematic. Use this if your kinematics do not apply directly to object locations and rotations, or if you need this information in your logic. The type parameter specifies the type of information you want, and will be explained shortly. The kinematicindex parameter is optional, and specifies which individual kinematic you want to get information for. For example, if you add a kinematic to travel 5 units in the x direction as the second addkinematic command, you would pass a 2 as the kinematicindex parameter into the getkinematics command. If not passed, or if you pass a 0 value here, the default gets information for all kinematics together. The updatetime/traveldist parameter is optional. The meaning of this parameter depends on the type parameter you specify. Sometimes this parameter will not be used. Some of the time it represents the requested update time that you want to get information for. If not passed, the current time is used. In the case of a KINEMATIC_ARRIVALTIME query, this parameter instead represents travel distance. The use of this parameter will be explained with each query type.
|Information||Value of type Parameter||Single Kinematic||All Kinematics|
|These return x, y, or z component of the current location of the specified kinematic at the given update time. For example, if you added a kinematic to travel 10 units in the x, starting at time 5, and you want to know the x location for this given kinematic at time 7, you can call getkinematics(datanode, KINEMATIC_X, index, 7) to get the x location for time 7.||These return the x, y, or z location of the object at the given update time.|
|End Distance||KINEMATIC_ENDDIST||This returns the distance from the final destination location of all kinematics from the object's initial location. Here the updatetime parameter is not used.|
|Total Distance||KINEMATIC_TOTALDIST||This returns the total distance for the kinematic operation.||This returns the sum of the distances of all the added kinematics. This has a
subtle difference from KINEMATIC_ENDDIST.
For example, if your first kinematic travels 10 in the x direction, and your second kinematic travels -10 in the x direction, then the enddist value will be 0, whereas the totaldist value will be 20. Here the updatetime parameter is not used.
|Total Component Distances||KINEMATIC_TOTALX
|These return the x, y, or z component of the total distance for the kinematic operation. These are the same values you passed into the addkinematic command. Here the updatetime parameter is not used.||These return the sum of x, y, or z component of all added kinematics. Here the updatetime parameter is not used.|
|Cumulative Distance||KINEMATIC_CUMULATIVEDIST||This returns the cumulative travel distance of all added kinematics. Unlike enddist or totaldist, it calculates the distance of the possibly curved path that the object will follow during the entire kinematic operation. Here the updatetime parameter is not used. Note: for cumulative distance, if you are using turn kinematics, the turn kinematics may not overlap other travel or turn kinematics. If they overlap with others, then the cumulative distance calculation will be incorrect.|
|These return the x, y, or z component of the current velocity for the specified kinematic at the given update time.||These return the x, y, or z velocity of the object for the given time.|
|Start Speed||KINEMATIC_STARTSPEED||This returns the start speed for the kinematic. This is the startspeed you specify in the addkinematic command. Here the updatetime parameter is not used.|
|Peak Speed||KINEMATIC_PEAKSPEED||This returns the peak speed or "reached speed" for the kinematic. This is usually the same as the target speed specified in the addkinematic command, but may not be if the kinematic cannot get to the target speed given the distance it has to travel. Here the updatetime parameter is not used.|
|End Speed||KINEMATIC_ENDSPEED||This returns the end speed for the kinematic. This is usually the endspeed that you specify in the addkinematic command, but may not be if the kinematic cannot decelerate/accelerate to your specified endspeed given the distance it has to travel. Here the updatetime parameter is not used.|
|Total Velocity||KINEMATIC_VELOCITY||This returns the total velocity of the kinematic for the given time.||This returns a scalar value of the total velocity for the given time.|
|Acceleration (Starting)||KINEMATIC_ACC1||This returns the acceleration value used to get from the start speed to the target speed. If the start speed is less than the target speed, then this value will be the acceleration value. Otherwise it will be the negative deceleration value. Here the updatetime parameter is not used.|
|Acceleration (Stopping)||KINEMATIC_ACC2||This returns the acceleration value used to get from the target speed to the end speed. If the end speed is less than the target speed, then this will return the negative deceleration value. Otherwise it will return the acceleration value. Here the updatetime parameter is not used.|
|These return the x, y, or z rotation of a rotational kinematic at the given update time.||These return the x, y, or z rotation of the object at the given update time. This will only work if rotations are managed manually.|
|End Rotational Distance||KINEMATIC_ENDRDIST||This returns the distance from the final destination rotational position of all kinematics from the object's initial rotational position. This will only work if rotations are managed manually. Here the updatetime parameter is not used.|
|Total Rotational Distance||KINEMATIC_TOTALRDIST||This returns the total rotational distance for the kinematic operation if it is a rotational kinematic.||This returns the sum of the rotational distances of all the added kinematics. This will only work if you are managing rotations yourself. Here the updatetime parameter is not used.|
|Total Component Rotations||KINEMATIC_TOTALRX
|These return the x, y, or z component of the total rotational distance for the kinematic operation if it is a rotational kinematic. These are the same values you passed into the addkinematic command. Here the updatetime parameter is not used.||These return the sum of rx, ry, or rz component of all added kinematics. This will only work if you are managing rotations yourself. Here the updatetime parameter is not used.|
|Cumulatvie Rotational Distance||KINEMATIC_CUMULATIVERDIST||This returns the cumulative rotational travel distance of all added kinematics. This will only work if you are managing rotations yourself. Here the updatetime parameter is not used.|
|These return the x, y, or z component of the current rotational velocity for the specified kinematic at the given time if it is a rotational kinematic.||These return the rotational x, y, or z velocity of the object for the given time.|
|Total Rotational Velocity||KINEMATIC_RVELOCITY||This returns the total rotational velocity of the kinematic for the given time if it is a rotational kinematic.||This returns a scalar value of the total rotation velocity for the given time. This only works if rotations are managed manually.|
|Start Times||KINEMATIC_STARTTIME||This returns the time that the specified kinematic will start its operation. This is the same starttime that you specified when you added the kinematic. Here the updatetime parameter is not used.||This returns the lowest start time of all the kinematics. Here the updatetime parameter is not used.|
|Acceleration Time (Starting)||KINEMATIC_ACC1TIME||This returns the total time the kinematic will spend accelerating/decelerating from the start speed to the target speed. Here the updatetime parameter is not used.|
|Arrival Time||KINEMATIC_ARRIVALTIME||In this query, the updatetime/traveldist parameter is used as a requested travel distance for the given kinematic. This returns the time of arrival for a certain sub-distance of a given kinematic. For example, if I've added a kinematic that tells the object to travel 5 units in the x direction, but I want to know how long it will take him to travel just 3 of those 5 units, I can use this query, and pass 3 in as the traveldist parameter.|
|Peak Time||KINEMATIC_PEAKTIME||This returns the total time the kinematic will spend traveling at the peak speed. Here the updatetime parameter is not used.|
|Acceleration Time (Stopping)||KINEMATIC_ACC2TIME||This returns the total time the kinematic will spend accelerating/decelerating from the target speed to the end speed. Here the updatetime parameter is not used.|
|End Times||KINEMATIC_ENDTIME||This returns the time that the specified kinematic will finish its operation. This is the same endtime that is returned from the addkinematic command. Here the updatetime parameter is not used.||This returns the highest end time of all the kinematics. Here the updatetime parameter is not used.|
|Number of Kinematics||KINEMATIC_NR||This returns the number of kinematics that have been added. Here the updatetime parameter is not used.|
|Turn Kinematic Data||KINEMATIC_STARTANGLE
|These return the start angle, turn angle, and turn radius of a turn kinematic.|
|Kinematic Type||KINEMATIC_TYPE||This returns KINEMATIC_TRAVEL if the specified kinematic is a travel operation, and KINEMATIC_ROTATE if the kinematic is a rotate operation.|
This command prints kinematic information to the output console. The index parameter is optional. If it is not passed, then information will be printed for all kinematics that have been added. If it is passed, then the index variable is an index of the added kinematic you want to print information for.
This command tells the kinematic to not update locations when the updatekinematics command is called. Execute this on reset to free the object to move it around in the ortho view.