turtlebot3-burger_150.png
turtlebot3-waffle-pi_150.png
turtlebot3-arm_150.png
walking-y2_150.png
turbot3-multi_150.png
turbot3-dl-ros1_150.png
turbot3-ai.png
turbot3-dl-ros2_150.png
turbot3-slam_150.png
turbot3-arm_150.png
turtlebot4-lite_150.png
turtlebot4-pro_150.png
turbot4-dl_150.png
turbot4-ai_150.png
aidriving-racebot_150.png
aidriving-autodrive_150.png
turtlebot-arm_150.png
openmanipulator-x_150.png
Home » Farmbot开发入门教程 » farmbot开发入门教程-Lua 配置

farmbot开发入门教程-Lua 配置

纠错,疑问,交流: 请进入讨论区请点击进入页面,扫码加入微信群或Q群进行交流

获取最新文章: 扫一扫加入“创客智造”公众号

说明:

  • FarmBot OS 中的配置 Lua 函数列表

env(键,值)/env(键)

  • 将键/值对存储并检索到 FarmBot 的 SD 卡。
- key并且value必须是字符串。
 - 值的长度不得超过 1,000 个字符。
 - ENV 最终将与您的 Web 应用程序帐户同步。


-- Store a value:
env("key", "value")

-- Example:
env("MY_API_TOKEN", "abc123")



-- Retrieve a value:
env("key")
-- Returns nil if no value is found.

-- Example:
api_token = env("MY_API_TOKEN")
if api_token then
  toast("Token is " .. api_token, "success")
else
  toast("Token not found", "error")
end

读取状态(…路径?)

  • 读取设备状态树。设备状态树包含许多与设备操作相关的属性。它与FarmBotJS中看到的状态树相同。
-- Read the entire state tree:
read_status()

-- Example:
status = read_status()
wifi = status.informational_settings.wifi_level_percent
toast("WiFi strength is " .. wifi .. "%")

-- Read a single property:
read_status("path", "to", "property")

-- Example:
raw_encoder_position_x = read_status("location_data", "raw_encoders", "x")
toast(raw_encoder_position_x)


status = read_status()
if status.location_data.position.x > 100 then
  toast("X is greater than 100")
else
  toast("X is less than or equal to 100")
end

fbos_version()

  • 返回FarmBot OS 版本的字符串表示形式。
fbos_version()


获取设备(属性?)

  • 获取设备属性。这与API 上找到的设备资源相同。
-- Get all properties:
get_device()

-- Example:
device = get_device()
toast("FarmBot name is " .. device.name)

-- Get a single property:
get_device("property_name")

-- Example:
id = get_device("id")
toast("Device ID is " .. id)

获取_fbos_config(属性?)

  • 获取FarmBot OS 配置属性。这与API 上找到的 FarmBot OS 配置资源相同。
-- Get all properties:
get_fbos_config()

-- Example:
fbos_config = get_fbos_config()
toast("FarmBot's firmware hardware is " .. fbos_config.firmware_hardware)

-- Get a single property:
get_fbos_config("property_name")

-- Example:
firmware_hardware = get_fbos_config("firmware_hardware")
toast("FarmBot firmware hardware is " .. firmware_hardware)

获取固件配置(属性?)

  • 获取固件配置属性。这与API 上的固件配置资源相同。
-- Get all properties:
get_firmware_config()

-- Example:
firmware_config = get_firmware_config()
toast("Encoder enabled Z is " .. firmware_config.encoder_enabled_z)

-- Get a single property:
get_firmware_config("property_name")

-- Example:
encoder_enabled_z = get_firmware_config("encoder_enabled_z")
toast("Encoder enabled Z is " .. encoder_enabled_z)

更新设备(参数)

  • 更新设备属性。这是在 API 上找到的相同设备资源。
update_device({key = "value"})

-- Example:
update_device({name = "Test Farmbot"})

更新_fbos_config()

  • 更新FarmBot OS 配置属性。这与API 上找到的 FarmBot OS 配置资源相同。
update_fbos_config({key = "value"})

-- Example:
update_fbos_config({disable_factory_reset = true})

更新固件配置(参数)

  • 更新固件配置属性。这与API 上的固件配置资源相同。
update_firmware_config({key = "value"})

-- Example:
update_firmware_config({encoder_enabled_z = 1.0})

纠错,疑问,交流: 请进入讨论区请点击进入页面,扫码加入微信群或Q群进行交流

获取最新文章: 扫一扫加入“创客智造”公众号


标签: none