.. _auto_movesx:
movesx (Auto Mode)
----------------------
This function moves the robot along a spline curve that connects the current position to the target position (the last waypoint) through the waypoints in the task space. The input velocity/acceleration means the **maximum** velocity/acceleration in the path. If ``eVelOpt`` is ``SPLINE_VELOCITY_OPTION_CONST``, the robot moves at the input velocity at constant speed. If constant speed is not possible for the given waypoints and velocity, the robot moves at variable speed (``SPLINE_VELOCITY_OPTION_DEFAULT``).
.. figure:: /tutorials/images/mode/movesx_overview.png
:alt: movesx
:width: 80%
:align: center
.. raw:: html
**Definition** |br|
``DRFLEx.h`` within class `CDRFLEx`, public section
.. code-block:: cpp
bool movesx(float fTargetPos[MAX_SPLINE_POINT][NUM_TASK],
unsigned char nPosCount,
float fTargetVel[2],
float fTargetAcc[2],
float fTargetTime = 0.f,
MOVE_MODE eMoveMode = MOVE_MODE_ABSOLUTE,
MOVE_REFERENCE eMoveReference = MOVE_REFERENCE_BASE,
SPLINE_VELOCITY_OPTION eVelOpt = SPLINE_VELOCITY_OPTION_DEFAULT)
{
return _movesx(_rbtCtrl, fTargetPos, nPosCount, fTargetVel, fTargetAcc,
fTargetTime, eMoveMode, eMoveReference, eVelOpt);
};
**Parameter** |br|
.. list-table::
:widths: 22 18 15 45
:header-rows: 1
* - **Parameter Name**
- **Data Type**
- **Default Value**
- **Description**
* - fTargetPos
- float \[MAX_SPLINE_POINT\]\[6\]
- -
- Maximum 100 waypoint information [mm, deg]
* - nPosCount
- unsigned char
- -
- Number of valid waypoints. nPosCount must be 1 to 100.
* - fTargetVel
- float\[2\]
- -
- Linear Velocity, Angular Velocity [mm/s, deg/s]
* - fTargetAcc
- float\[2\]
- -
- Linear Acceleration, Angular Acceleration [mm/s\ :sup:`2`, deg/s\ :sup:`2`]
* - fTargetTime
- float
- 0.f
- Reach Time \[sec\]
* - eMoveMode
- :ref:`MOVE_MODE `
- ``MOVE_MODE_ABSOLUTE``
- Refer to the Definition of Enumeration Type
* - eMoveReference
- :ref:`MOVE_REFERENCE `
- ``MOVE_REFERENCE_BASE``
- Refer to the Definition of Enumeration Type
* - eVelOpt
- :ref:`SPLINE_VELOCITY_OPTION `
- ``SPLINE_VELOCITY_OPTION_DEFAULT``
- Refer to the Definition of Enumeration Type
.. Note::
- If a value is passed to **fTargetVel** (e.g., ``fTargetVel ={30, 0}``), the input corresponds to the linear velocity of the motion, while the angular velocity is determined proportionally to the linear velocity.
- If a value is passed to **fTargetAcc** (e.g., ``fTargetAcc ={60, 0}``), the input corresponds to the linear acceleration of the motion, while the angular acceleration is determined proportionally to the linear acceleration.
- If **fTargetTime** is specified, values are processed based on **fTargetTime**, ignoring **fTargetVel** and **fTargetAcc**.
- When **eMoveMode** is ``MOVE_MODE_RELATIVE``, each pos in the position list is defined as a relative coordinate with respect to the preceding pos. (If position list=\[q1, q2, …,q(n-1), q(n)\], **q1** is relative to the starting point, while **q(n)** is relative to **q(n-1)**.)
- This function does not support online blending of previous and subsequent motions.
.. Caution::
If the ``SPLINE_VELOCITY_OPTION_CONST`` option (constant-velocity option) is selected for **eVelOpt** but the distance and velocity between the input waypoints do not allow it, the constant-velocity motion **cannot be used**, and the motion automatically switches to the variable-velocity motion (``eVelOpt = SPLINE_VELOCITY_OPTION_DEFAULT``).
**Return**
.. list-table::
:widths: 15 85
:header-rows: 1
* - **Value**
- **Description**
* - 0
- Error
* - 1
- Success
.. Note::
Returns false without a message when the robot is in STATE_EMERGENCY_STOP, STATE_SAFE_OFF, STATE_SAFE_OFF2, STATE_SAFE_STOP or STATE_SAFE_STOP2.
**Example**
.. code-block:: cpp
// CASE 1 : Moves absolute coordinate standard (mode = MOVE_MODE_ABSOLUTE)
float xpos[4][6];
unsigned char xposNum = 4;
float tvel[2] = { 50, 100 };
float tacc[2] = { 50, 100 };
xpos[0][0]=559; xpos[0][1]=434.5; xpos[0][2]=651.5;
xpos[0][3]=0; xpos[0][4]=180; xpos[0][5]=0;
xpos[1][0]=559; xpos[1][1]=434.5; xpos[1][2]=251.5;
xpos[1][3]=0; xpos[1][4]=180; xpos[1][5]=0;
xpos[2][0]=559; xpos[2][1]=234.5; xpos[2][2]=251.5;
xpos[2][3]=0; xpos[2][4]=180; xpos[2][5]=0;
xpos[3][0]=559; xpos[3][1]=234.5; xpos[3][2]=451.5;
xpos[3][3]=0; xpos[3][4]=180; xpos[3][5]=0;
drfl.movesx(xpos, xposNum, tvel, tacc, 0, MOVE_MODE_ABSOLUTE);
// Moves the spline curve that connects the waypoints defined in xpos
// with a maximum linear/angular velocity of 50 and maximum acceleration of 100.
// CASE 2 : Moves relative coordinate standard (mode = MOVE_MODE_RELATIVE)
float xpos2[4][6];
xpos2[0][0]=0; xpos2[0][1]=+400; xpos2[0][2]=0;
xpos2[0][3]=0; xpos2[0][4]=0; xpos2[0][5]=0; // from start position -> x0
xpos2[1][0]=0; xpos2[1][1]=0; xpos2[1][2]=+400;
xpos2[1][3]=0; xpos2[1][4]=0; xpos2[1][5]=0; // from x0 -> x1
xpos2[2][0]=0; xpos2[2][1]=+200; xpos2[2][2]=0;
xpos2[2][3]=0; xpos2[2][4]=0; xpos2[2][5]=0; // from x1 -> x2
xpos2[3][0]=0; xpos2[3][1]=0; xpos2[3][2]=+200;
xpos2[3][3]=0; xpos2[3][4]=0; xpos2[3][5]=0; // from x2 -> x3
drfl.movesx(xpos2, xposNum, tvel, tacc, 0, MOVE_MODE_RELATIVE);
// Moves the spline curve that connects the relative waypoints in xpos2
// with max velocity 50 (mm/sec, deg/sec) and max acceleration 100 (mm/sec2, deg/sec2).