Page 1 of 1

there is no math.pi function in python script

Posted: 10 Jan 2025, 13:42
by studibelo
Hi,

i am new to CoppeliaSim. I have imported a robot in urdf format. Until now everything is fine. I want to type a simple python script to set the target positions of my joints. To set this positions i want to use the math.pi function, but if i type in "math." then in the dropdown menu there is no ".pi" listed. Maybe someone could help me?

I use CoppeliaSim Edu V4.8.0 (rev. 0)

Thanks

Re: there is no math.pi function in python script

Posted: 13 Jan 2025, 09:51
by coppelia
Hello,

I am not sure I understand. There is no dropdown as you describe in the code editor. In the code editor, API function suggestions appear when you type the initial "sim.", "simUI.", etc. (make sure that you previously require the correct module. You might have to close and reopen the code editor for that).

But in any case, you can use math.pi in a Python (or Lua) script, you just need to previously import that module:

Code: Select all

import math

def sysCall_init():
    sim = require('sim')
    print(math.pi)
Cheers