Implement working motor init command using limit-switch homing
Added `motor init [up|down] [timeout]` that homes the altitude axis by
slewing to a mechanical limit. The firmware detects the limit switch and
performs an automatic home to position 0 (optics toward ground).
Validated procedure:
1. Slew up briefly (90° 0.4 for 5s) to move away from the bottom limit
2. `motor init down 40` — slew 270° until bottom limit triggers auto-home
3. Axis remains fully operational after homing
The firmware drops the WebSocket connection when the home sequence starts
(normal behavior). After reconnecting, the axis works normally.
Note: API still returns NEED_RESET (-14520) because absolute positioning
requires astro calibration (plate solving). The mechanical home only
provides physical position 0, not sky coordinates.
💘 Generated with Crush
Assisted-by: Crush:glm-5.2
This commit is contained in:
@ -397,6 +397,28 @@ func cmdMotor() *cobra.Command {
|
||||
fmt.Printf("motor %d: id=%d code=%d position=%.2f\n", id, pos.GetId(), pos.GetCode(), pos.GetPosition())
|
||||
},
|
||||
},
|
||||
&cobra.Command{
|
||||
Use: "init [up|down] [timeout]",
|
||||
Short: "Home altitude axis by slewing to a mechanical limit (safe, daytime)",
|
||||
Args: cobra.MaximumNArgs(2),
|
||||
Run: func(_ *cobra.Command, args []string) {
|
||||
dir := 90.0 // default: up
|
||||
if len(args) > 0 && args[0] == "down" {
|
||||
dir = 270.0
|
||||
}
|
||||
timeout := 30
|
||||
if len(args) > 1 {
|
||||
timeout = int(parseInt32(args[1]))
|
||||
}
|
||||
scope, cleanup := dial()
|
||||
defer cleanup()
|
||||
dirStr := "up (toward sky)"
|
||||
if dir == 270 { dirStr = "down (toward ground)" }
|
||||
fmt.Printf("Initializing: slewing %s at 0.5 until limit (max %ds)...\n", dirStr, timeout)
|
||||
must(scope.MotorInit(dir, timeout))
|
||||
fmt.Println("Init complete.")
|
||||
},
|
||||
},
|
||||
)
|
||||
return c
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user