Map range to +/-180 and limit step motion for A-axis
r3362 | dcl | 2012-01-30 14:21:31 +1100 (Mon, 30 Jan 2012) | 1 line
This commit is contained in:
@@ -198,7 +198,15 @@ namespace eval ::scobj::cybaman {
|
|||||||
sct geterror "Error - catch: $catch_message"
|
sct geterror "Error - catch: $catch_message"
|
||||||
return idle
|
return idle
|
||||||
}
|
}
|
||||||
set data [expr {round($data * 0.1) * 0.001}]
|
set channel [string toupper [string range [basename [sct]] end-1 end]]
|
||||||
|
if { "$channel" == "GA" } {
|
||||||
|
set data [expr {round($data * 0.1) * 0.001}]
|
||||||
|
if { $data > 180.0 } {
|
||||||
|
set data [expr $data - 360.0]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
set data [expr {round($data * 0.1) * 0.001}]
|
||||||
|
}
|
||||||
if {$data != [sct oldval]} {
|
if {$data != [sct oldval]} {
|
||||||
sct oldval $data
|
sct oldval $data
|
||||||
sct update $data
|
sct update $data
|
||||||
@@ -337,7 +345,29 @@ namespace eval ::scobj::cybaman {
|
|||||||
proc wrAngle {tc_root nextState cmd} {
|
proc wrAngle {tc_root nextState cmd} {
|
||||||
debug_log "wrAngle root=$tc_root sct=[sct] cmd=$cmd target=[sct target]"
|
debug_log "wrAngle root=$tc_root sct=[sct] cmd=$cmd target=[sct target]"
|
||||||
set par "[sct target]"
|
set par "[sct target]"
|
||||||
set data "[expr {round(10000 * [sct target])}]"
|
set channel [string toupper [string range [basename [sct]] end-1 end]]
|
||||||
|
if { "$channel" == "GA" } {
|
||||||
|
# and move by maximum 90 degree steps
|
||||||
|
set here [hval [pathname [sct]]/act_pos_GA]
|
||||||
|
if { $par > $here } {
|
||||||
|
if { ($par - $here) > 90.0 } {
|
||||||
|
set par [expr $here + 90.0]
|
||||||
|
}
|
||||||
|
} elseif { $par < $here } {
|
||||||
|
if { ($par - $here) < -90.0 } {
|
||||||
|
set par [expr $here - 90.0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sct print "Setting GA to $par (was [sct target])"
|
||||||
|
# change [-180,180] to [0,360]
|
||||||
|
if { $par < 0 } {
|
||||||
|
set data "[expr {round(10000 * ( 360.0 + $par ))}]"
|
||||||
|
} else {
|
||||||
|
set data "[expr {round(10000 * $par)}]"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
set data "[expr {round(10000 * $par)}]"
|
||||||
|
}
|
||||||
set target [chkTarget "$par"]
|
set target [chkTarget "$par"]
|
||||||
if {"$target" == ""} {
|
if {"$target" == ""} {
|
||||||
return -code error "Invalid value: \"$par\""
|
return -code error "Invalid value: \"$par\""
|
||||||
@@ -691,7 +721,7 @@ debug_log "chkWrite new data for $tc_root [sct] result=$data"
|
|||||||
set catch_status [catch {
|
set catch_status [catch {
|
||||||
set new_state "[lindex $current_state 1]"
|
set new_state "[lindex $current_state 1]"
|
||||||
set current_state "[lindex $current_state 0]"
|
set current_state "[lindex $current_state 0]"
|
||||||
if { "[sct]" == "$tc_root/device_state" } {
|
if { "[basename [sct]]" == "device_state" } {
|
||||||
if {"$new_state" != "[sct oldval]" } {
|
if {"$new_state" != "[sct oldval]" } {
|
||||||
set old_state "[sct oldval]"
|
set old_state "[sct oldval]"
|
||||||
sct oldval "$new_state"
|
sct oldval "$new_state"
|
||||||
@@ -736,6 +766,11 @@ debug_log "chkWrite new data for $tc_root [sct] result=$data"
|
|||||||
if { "$current_state" == 6 } {
|
if { "$current_state" == 6 } {
|
||||||
# still moving
|
# still moving
|
||||||
} elseif { "$current_state" == 1 } {
|
} elseif { "$current_state" == 1 } {
|
||||||
|
# has become idle
|
||||||
|
if { [hgetpropval $tc_root/display/set_pos_GA target] != [hval $tc_root/display/set_pos_GA] } {
|
||||||
|
sct print "we should take another bite"
|
||||||
|
# hset $tc_root/Display/set_pos_GA [hgetpropval /display/set_pos_GA target]
|
||||||
|
#}
|
||||||
if { [hval $tc_root/display/act_pos_GA] == [hval $tc_root/display/set_pos_GA] &&
|
if { [hval $tc_root/display/act_pos_GA] == [hval $tc_root/display/set_pos_GA] &&
|
||||||
[hval $tc_root/display/act_pos_GB] == [hval $tc_root/display/set_pos_GB] &&
|
[hval $tc_root/display/act_pos_GB] == [hval $tc_root/display/set_pos_GB] &&
|
||||||
[hval $tc_root/display/act_pos_GC] == [hval $tc_root/display/set_pos_GC] } {
|
[hval $tc_root/display/act_pos_GC] == [hval $tc_root/display/set_pos_GC] } {
|
||||||
@@ -972,7 +1007,7 @@ debug_log "Creating node $nodeName"
|
|||||||
hsetprop $scobj_hpath/$setNodeName checklimits ${ns}::$chkLimits $scobj_hpath
|
hsetprop $scobj_hpath/$setNodeName checklimits ${ns}::$chkLimits $scobj_hpath
|
||||||
hsetprop $scobj_hpath/$setNodeName checkstatus ${ns}::$chkStatus $scobj_hpath
|
hsetprop $scobj_hpath/$setNodeName checkstatus ${ns}::$chkStatus $scobj_hpath
|
||||||
hsetprop $scobj_hpath/$setNodeName halt ${ns}::$doHalt $scobj_hpath
|
hsetprop $scobj_hpath/$setNodeName halt ${ns}::$doHalt $scobj_hpath
|
||||||
::scobj::hinitprops $name $axis [basename $setNodeName]
|
::scobj::hinitprops $name/$axis [basename $setNodeName]
|
||||||
if {[SplitReply [environment_simulation]]=="false"} {
|
if {[SplitReply [environment_simulation]]=="false"} {
|
||||||
ansto_makesctdrive $axis $scobj_hpath/$setNodeName $scobj_hpath/$getNodeName $sct_controller
|
ansto_makesctdrive $axis $scobj_hpath/$setNodeName $scobj_hpath/$getNodeName $sct_controller
|
||||||
}
|
}
|
||||||
@@ -1001,7 +1036,7 @@ debug_log "Creating node $nodeName"
|
|||||||
Display opmode 0 0 0 int user {opmode} {rdValue} {} {} {}\
|
Display opmode 0 0 0 int user {opmode} {rdValue} {} {} {}\
|
||||||
Display prognumber 1 0 0 int user {mainProgNumber} {rdValue} {} {} {}\
|
Display prognumber 1 0 0 int user {mainProgNumber} {rdValue} {} {} {}\
|
||||||
Display reset 1 1 0 int user {visin_ctrlR} {rdValue} {visin_ctrlR} {wrValue} {}\
|
Display reset 1 1 0 int user {visin_ctrlR} {rdValue} {visin_ctrlR} {wrValue} {}\
|
||||||
Display set_pos_GA 1 1 0 float user {p101} {rdAngle} {p101} {wrAngle} {0:360}\
|
Display set_pos_GA 1 1 0 float user {p101} {rdAngle} {p101} {wrAngle} {-180:180}\
|
||||||
Display set_pos_GB 1 1 0 float user {p102} {rdAngle} {p102} {wrAngle} {-180:180}\
|
Display set_pos_GB 1 1 0 float user {p102} {rdAngle} {p102} {wrAngle} {-180:180}\
|
||||||
Display set_pos_GC 1 1 0 float user {p103} {rdAngle} {p103} {wrAngle} {-180:180}\
|
Display set_pos_GC 1 1 0 float user {p103} {rdAngle} {p103} {wrAngle} {-180:180}\
|
||||||
Display feed_rate 1 1 0 int user {p104} {rdValue} {p104} {wrValue} {0:99999}\
|
Display feed_rate 1 1 0 int user {p104} {rdValue} {p104} {wrValue} {0:99999}\
|
||||||
|
|||||||
Reference in New Issue
Block a user