V-REP的Lua`tonumber`在Linux上返回nil(V-REP's Lua `tonumber` returns nil on Linux)
我们开发了一个简单的V-REP仿真,它在OS X上运行得很好,但在Linux(Ubuntu 15.04)上却没有。 Lua被用作主要的脚本语言。
我们附加了以下代码(在注释中返回值),不幸的是在Linux上返回
nil
(但在OS X上将e[3]
转换为数字而没有问题):e[3] -- -0.677782532263 type(e[3]) -- string type(tonumber(e[3])) -- nil
真正有趣的是,前面的代码在Lua 5.2.3控制台(OS X和Linux)中都能正常工作。 但是,在Linux上运行时,V-REP无法正确地将字符串转换为数字。
我们尝试了32b和64b V-REP版本 (今天下载),结果完全相同 -
nil
。 你能指出一些我们遗漏的东西吗? Lua和V-REP都不是我们每天使用的工具。编辑1:我使用Ubuntu 15.04。 V-REP使用Lua 5.1,My Lua版本:
$ apt-cache policy lua5.1 lua5.1: Installed: 5.1.5-7.1 Candidate: 5.1.5-7.1 Version table: *** 5.1.5-7.1 0 500 http://cz.archive.ubuntu.com/ubuntu/ vivid/main amd64 Packages 100 /var/lib/dpkg/status
在控制台中,我尝试了以下内容:
$ lua Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio > e={[3]="-0.677782532263"}; print(e[3], type(e[3]), tonumber(e[3]), type(tonumber(e[3]))) -0.677782532263 string -0.677782532263 number
包
We developed a simple V-REP simulation that works pretty well on OS X but not on Linux (Ubuntu 15.04). Lua is employed as the main scripting language.
We attach the following code (with the return values in comments) that unfortunately returns
nil
on Linux (but convertse[3]
to number without problem on OS X):e[3] -- -0.677782532263 type(e[3]) -- string type(tonumber(e[3])) -- nil
What is really interesting is the fact that the previous code works as one would expect in Lua 5.2.3 console (both OS X and Linux). However, V-REP can't convert the string to number properly when running on Linux.
We tried both 32b and 64b V-REP versions (today downloaded) with exactly same results -
nil
s. Could you please point out some things we're missing? Neither Lua nor V-REP are utils we use every day.Edit 1: I Use Ubuntu 15.04. V-REP uses Lua 5.1, My Lua version:
$ apt-cache policy lua5.1 lua5.1: Installed: 5.1.5-7.1 Candidate: 5.1.5-7.1 Version table: *** 5.1.5-7.1 0 500 http://cz.archive.ubuntu.com/ubuntu/ vivid/main amd64 Packages 100 /var/lib/dpkg/status
In console, I tried the following:
$ lua Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio > e={[3]="-0.677782532263"}; print(e[3], type(e[3]), tonumber(e[3]), type(tonumber(e[3]))) -0.677782532263 string -0.677782532263 number
Packages
原文: