rzirzi
November 3, 2025, 7:53pm
1
I have been using it for many year with ROS 6.x, but had to upgrade ROS to 7.x ant it stopped working. Please help me convert this script to ROS 7.x :
:global VoltLast
:local EmailAddress "myemail@mydomain.com "
:local MinimalGoodVoltage 270
:local MTName [/system identity get name]
:local Date [/system clock get date]
:local Time [/system clock get time]
:local VoltAct [/system health get voltage]
:local VoltDiff [ ($VoltAct - $VoltLast) ]
:tonum VoltDiff
:if ( $VoltDiff < 0 ) do={ :set VoltDiff [ ( 0 - $VoltDiff ) ] }
:if (( $VoltDiff >= 1 ) && ($VoltAct < $MinimalGoodVoltage)) do={/tool e-mail send to=$EmailAddress subject=("NISKIE NAPIECIE AKU $MTName " . [:pick $VoltAct 0 2] . "." . [:pick $VoltAct 2 3] . "V") body=([$Date] . " - " . [$Time] . " " . "Napiecie akumulatora baza $MTName " . [:pick $VoltAct 0 2] . "." . [:pick $VoltAct 2 3] . "V")}
:if ( $VoltDiff >= 1 ) do={ :set VoltLast $VoltAct }
Thank You!
infabo
November 3, 2025, 8:29pm
2
Log should tell you the line where script is failing.
rzirzi
November 3, 2025, 8:32pm
3
at ROS 7.xx it’s completelly different…. I suppose, so can anyone convert it to ROS 7.xx?
infabo
November 3, 2025, 8:36pm
4
I am not very experienced at ROS scripting but the syntax and commands look okay. So again: what tells you the /log/print after executing your script?
xrlls
November 3, 2025, 9:22pm
5
This is your problem.
Instead you can try something like this:
:local VoltAct ([/system/health/get ([find name~"voltage"]->0)]->"value")
Your next problem will then be that this returns a string with a decimalseparator, but at least it is a step…
rzirzi
November 3, 2025, 9:56pm
6
Can you convert all script to ROS7.xx verion ?
Amm0
November 4, 2025, 1:07am
7
/system/health is tricky in scripting, and did change in V7.
You, at minimum, need to change:
:local VoltAct [/system health get voltage]
to
:local VoltAct [/system/health get [find where name=voltage] value]
I believe the rest of the script should work same – although the comparison of voltage are going to via "time" type & other "less optimal" scripting code, the logic should still work. If the text is wrong, you may need to adjust the [:pick] statements.
If the script was copied from someplace here, I tried to find the thread you got the script from and see if anyone posted an update.
xrlls
November 4, 2025, 8:23am
8
Something like this:
:global VoltLast
:local EmailAddress "myemail@mydomain.com"
:local MinimalGoodVoltage 270
:local MTName [/system identity get name]
:local Date [/system clock get date]
:local Time [/system clock get time]
#:local VoltAct [/system health get voltage]
:local VoltAct ([/system/health/get ([find name~"voltage"]->0)]->"value"); #Get first entry named something containing "voltage"
:local Index [:find $VoltAct "."]; #Find index to decimal separator
:set VoltAct [tonum ([:pick $VoltAct -1 $Index].[:pick $VoltAct ($Index+1) [:len $VoltAct]])]; #remove decimal separator
:local VoltDiff [ ($VoltAct - $VoltLast) ]
:tonum VoltDiff
:if ( $VoltDiff < 0 ) do={ :set VoltDiff [ ( 0 - $VoltDiff ) ] }
:if (( $VoltDiff >= 1 ) && ($VoltAct < $MinimalGoodVoltage)) do={/tool e-mail send to=$EmailAddress subject=("NISKIE NAPIECIE AKU $MTName " . [:pick $VoltAct 0 2] . "." . [:pick $VoltAct 2 3] . "V") body=([$Date] . " - " . [$Time] . " " . "Napiecie akumulatora baza $MTName " . [:pick $VoltAct 0 2] . "." . [:pick $VoltAct 2 3] . "V")}
:if ( $VoltDiff >= 1 ) do={ :set VoltLast $VoltAct }