op_ima_traj_set()
Abstract
Sets the trajectory for an object.
Syntax
op_ima_traj_set (objid, traj_filename, wait_time)
| Argument | Type | Description |
|---|---|---|
objid |
Objid |
object ID of the site of interest; must be a mobile node or mobile subnet |
traj_filename |
const char * |
name of the trajectory to set |
wait_time |
double |
time to wait from the current simulation time before starting to follow the trajectory, in seconds |
Return Type
Compcode
OPC_COMPCODE_SUCCESS if the new trajectory is set; OPC_COMPCODE_FAILURE otherwise.
Example
double duration = op_ima_traj_remaining_duration_get (subnet_objid);
if (duration == 0)
{
op_ima_traj_set (subnet_objid, "NE_zig_zag", 0.0);
op_ima_traj_speed_set (subnet_objid, op_dist_uniform (100.0) + 10.0, VOSC_FALSE);
}
Details
None.
Purpose
Provides a way to assign a trajectory to a mobile site (node or subnet) during a simulation. You can call this KP at any time to assign a new trajectory or replace the current one on the site. Thus, you can use this KP to have a site follow a series of trajectories in sequence or to change the trajectory being followed in response to changing conditions in the simulation.
Errors
- Recoverable Error: Object ID (
<objid>) is out-of-range. - Recoverable Error: Object ID (
<objid>) refers to a restricted object. - Recoverable Error: Object (
<objid>) has incorrect type (<type>); mobile sites are expected.
Reference
- Use the KP op_ima_traj_info_get() to get the current speed and ascent rate of a site and the time until one of these changes
- Use the KP op_ima_traj_remaining_duration_get() to get the time remaining until a site reaches the end of its trajectory
- Use the KP op_ima_traj_speed_set() to override the speed set by the trajectory