there is no math.pi function in python script

Report crashes, strange behaviour, or apparent bugs
Post Reply
studibelo
Posts: 1
Joined: 10 Jan 2025, 13:03

there is no math.pi function in python script

Post 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

coppelia
Site Admin
Posts: 10626
Joined: 14 Dec 2012, 00:25

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

Post 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

Post Reply