Refactor anticollision script so that we can add more scripts to the anticollision module.
This commit is contained in:
committed by
Ferdi Franceschini
parent
901c6603fb
commit
64870e7bc8
@@ -3,8 +3,6 @@
|
|||||||
# TODO Handle sequencing when simultaneously moving multiple axes
|
# TODO Handle sequencing when simultaneously moving multiple axes
|
||||||
# TODO Handle functional dependencies (just write your own tcl script)
|
# TODO Handle functional dependencies (just write your own tcl script)
|
||||||
# or get the generic acscript to call a user proc
|
# or get the generic acscript to call a user proc
|
||||||
# FIXME The anticollider module does not report the error messages from the
|
|
||||||
# anticollision script, we currently get around this by using broadcast.
|
|
||||||
|
|
||||||
AntiCollisionInstall
|
AntiCollisionInstall
|
||||||
namespace eval anticollider {
|
namespace eval anticollider {
|
||||||
@@ -88,16 +86,14 @@ proc ::anticollider::enable {args} {
|
|||||||
#
|
#
|
||||||
# The ::anticollider::veto_region is a hash indexed by the names of the motors
|
# The ::anticollider::veto_region is a hash indexed by the names of the motors
|
||||||
# which have been registered with the anticollision module.
|
# which have been registered with the anticollision module.
|
||||||
proc ::anticollider::acscript {args} {
|
proc ::anticollider::veto_region_acscript {args} {
|
||||||
variable veto_region
|
variable veto_region
|
||||||
|
|
||||||
if {[::anticollider::enable $args] == "false"} {
|
set catch_status [ catch {
|
||||||
foreach {regmot target} $args {
|
foreach {regmot target} $args {
|
||||||
anticollision add 0 $regmot $target
|
if { ! [info exists veto_region($regmot)] } {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
|
||||||
foreach {regmot target} $args {
|
|
||||||
foreach row $veto_region($regmot) {
|
foreach row $veto_region($regmot) {
|
||||||
if { [lindex $row 1] == "@and"} {
|
if { [lindex $row 1] == "@and"} {
|
||||||
set forbid [lindex $row 0]
|
set forbid [lindex $row 0]
|
||||||
@@ -116,7 +112,6 @@ proc ::anticollider::acscript {args} {
|
|||||||
} else {
|
} else {
|
||||||
foreach {min max} $forbid {}
|
foreach {min max} $forbid {}
|
||||||
if {$min <= $target && $target <= $max} {
|
if {$min <= $target && $target <= $max} {
|
||||||
broadcast "ERROR:The range ($forbid) is forbidden for $regmot when [lindex $row 2]"
|
|
||||||
error "ERROR:The range ($forbid) is forbidden for $regmot when [lindex $row 2]"
|
error "ERROR:The range ($forbid) is forbidden for $regmot when [lindex $row 2]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,17 +121,14 @@ proc ::anticollider::acscript {args} {
|
|||||||
if {$obstrange == "@all"} {
|
if {$obstrange == "@all"} {
|
||||||
foreach {min max} [join $forbidden_range] {
|
foreach {min max} [join $forbidden_range] {
|
||||||
if {$min <= $target && $target <= $max} {
|
if {$min <= $target && $target <= $max} {
|
||||||
broadcast "ERROR: $regmot target ($target) is in the forbidden region ($forbidden_range)"
|
|
||||||
error "ERROR: $regmot target ($target) is in the forbidden region ($forbidden_range)"
|
error "ERROR: $regmot target ($target) is in the forbidden region ($forbidden_range)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
broadcast "ERROR: veto table must use @all with @any"
|
|
||||||
error "ERROR: veto table must use @all with @any"
|
error "ERROR: veto table must use @all with @any"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if {$obstrange == "@all"} {
|
if {$obstrange == "@all"} {
|
||||||
broadcast "ERROR: veto table must use @any with @all"
|
|
||||||
error "ERROR: veto table must use @any with @all"
|
error "ERROR: veto table must use @any with @all"
|
||||||
} else {
|
} else {
|
||||||
foreach {lower upper} [join $obstrange] {
|
foreach {lower upper} [join $obstrange] {
|
||||||
@@ -144,7 +136,6 @@ proc ::anticollider::acscript {args} {
|
|||||||
if {$lower <= $pos && $pos <= $upper} {
|
if {$lower <= $pos && $pos <= $upper} {
|
||||||
foreach {min max} [join $forbidden_range] {
|
foreach {min max} [join $forbidden_range] {
|
||||||
if {$min <= $target && $target <= $max} {
|
if {$min <= $target && $target <= $max} {
|
||||||
broadcast "ERROR:The range $min to $max is forbidden for $regmot when $obstmot is in this region ($obstrange)"
|
|
||||||
error "ERROR:The range $min to $max is forbidden for $regmot when $obstmot is in this region ($obstrange)"
|
error "ERROR:The range $min to $max is forbidden for $regmot when $obstmot is in this region ($obstrange)"
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -158,6 +149,8 @@ proc ::anticollider::acscript {args} {
|
|||||||
}
|
}
|
||||||
anticollision add 0 $regmot $target
|
anticollision add 0 $regmot $target
|
||||||
}
|
}
|
||||||
|
} message ]
|
||||||
|
handle_exception $catch_status $message
|
||||||
}
|
}
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -178,5 +171,18 @@ proc ::anticollider::init {} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc ::anticollider::acscript {args} {
|
||||||
|
set catch_status [ catch {
|
||||||
|
if {[::anticollider::enable $args] == "false"} {
|
||||||
|
foreach {regmot target} $args {
|
||||||
|
anticollision add 0 $regmot $target
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
::anticollider::veto_region_acscript {*}$args
|
||||||
|
} message ]
|
||||||
|
handle_exception $catch_status $message
|
||||||
|
}
|
||||||
|
|
||||||
publish ::anticollider::acscript user
|
publish ::anticollider::acscript user
|
||||||
anticollision script ::anticollider::acscript
|
anticollision script ::anticollider::acscript
|
||||||
|
|||||||
Reference in New Issue
Block a user