Sometimes (usually due to issues caused by robot cloning) it may be necessary to reset the robot_device_id and clear the niscache on every active robot in the entire DX UIM domain.
The need to implement this cleanup/change may also be due to other environmental reasons.
DX UIM 23.4.*
Updated: February 24, 2023 (Resolves execution issues in NAS 9.36 and higher). Older script versions are attached to this article for Support reference only.
Test First: Always run these scripts in a test/dev environment prior to production use. They are provided as-is.
Hubs are Skipped: To prevent the script from restarting its own host and failing, it automatically bypasses any robot with the hub probe installed. Hubs must be cleared manually.
Robot Status: Robots must be active and communicating with the controller probe to be processed.
Scale: In large environments or those with many offline robots, the full-domain script may time out. If this occurs, use the single-hub script instead.
Clears niscache on all non-hub robots in the entire domain.
hubdomain = "domain_here" -- put your UIM Domain here
local gethubs = nimbus.request("hub","gethubs")
for row,hub in pairs(gethubs.hublist) do
if (hub.domain == hubdomain) then
print("correct domain for hub " ..hub.addr)
getrobots, rc = nimbus.request(hub.addr, "getrobots")
print("return code for getrobots is " ..rc)
for x,y in pairs(getrobots.robotlist) do
if (y.status == 0) then
print("working on robot " ..y.addr)
local probes, rc2 = nimbus.request(y.addr.."/controller", "port_list")
if (not probes["hub"]) then
print("Not a hub robot, resetting " ..y.addr)
local reset, rc3 = nimbus.request(y.addr.."/controller", "_reset_device_id_and_restart")
if (rc3 == 0) then
print("success " ..y.addr)
else
print("failure " ..y.addr)
end
else
print("Skipping hub robot "..y.addr )
end
else
print("robot status for " ..y.addr.. " is not OK - skipping")
end
end
else
print("Wrong domain for hub " .. hub.addr)
end
end
Processes one hub at a time. This is more reliable for large environments or if the full-domain script returns errors like attempt to index local 'probes' (a nil value).
hub_to_clear = "/MyDomain/HubName/hubrobotname/hub"
-- use the full address including /hub at the end
getrobots, rc = nimbus.request(hub_to_clear, "getrobots")
print("return code for getrobots is " ..rc)
for x,y in pairs(getrobots.robotlist) do
if (y.status == 0) then
print("working on robot " ..y.addr)
local probes, rc2 = nimbus.request(y.addr.."/controller", "port_list")
if (not probes["hub"]) then
print("Not a hub robot, resetting " ..y.addr)
local reset, rc3 = nimbus.request(y.addr.."/controller", "_reset_device_id_and_restart")
if (rc3 == 0) then
print("success " ..y.addr)
else
print("failure " ..y.addr)
end
else
print("Skipping hub robot "..y.addr )
end
else
print("robot status for " ..y.addr.. " is not OK - skipping")
end
endNote: These scripts intentionally bypass hubs. You must clear hubs manually if needed, though this is rarely required since hubs typically do not host monitoring probes.
If you prefer to execute this action via the command line rather than using NAS scripts, refer to the following article: