Forum Migration Notice
Update (2026-01-21): The user forums are now in read-only mode pending the data migration.

Update (2026-01-12): The user forums will be put into read-only mode on the 21st of January, 00:00 CET, to prepare for the data migration.

We're transitioning to a more modern community platform by beginning of next year. Learn about the upcoming changes and what to expect.

Random values

Is there a standard function in RAPID to generate random values for variables? Something equivalent to the 'rand' or 'randf' function in C?

Comments

  • No, but there's probably plenty of ways to make your own. For instance, if the robot is moving, you might try something like:

    FUNC num GetRandom()

      VAR jointtarget joints;

      VAR num nVal;

      joints := CJointT();

      RETURN nVal:=Round(Sqrt(Abs(joints.rax_3)))

    ENDFUNC

    Russell Drown
  • Nowadays you can use Rand()
    -----------------
    David
    Swedish freelance ABB robot programmer