Look along path while approaching beds

This commit is contained in:
Tanner
2026-11-07 23:21:41 +00:00
parent 9cbadbd551
commit 11add13779
4 changed files with 64 additions and 6 deletions
+14 -1
View File
@@ -2,7 +2,10 @@ import unittest
from munch import Munch
from mosfet.bot import look_direction_from_eye, update_pitch, update_yaw
from mosfet.bot import (
look_direction_from_eye, navigation_look_target, update_pitch,
update_yaw,
)
from mosfet.vector import Point3D, Vector3D
@@ -58,6 +61,16 @@ class TestFarmingPitch(unittest.TestCase):
self.assertGreaterEqual(state.yaw, -180.0)
self.assertLess(state.yaw, 180.0)
def test_path_navigation_looks_at_the_block_above_its_waypoint(self):
path = [(index, 64, 0) for index in range(6)]
target = navigation_look_target(path)
self.assertEqual(target.tuple(), (4, 65, 0))
self.assertEqual(navigation_look_target([(1, 64, 2)]).tuple(),
(1, 65, 2))
self.assertIsNone(navigation_look_target([]))
def test_pitch_tracks_look_target_instead_of_a_fixed_farming_angle(self):
state = Munch(pitch=0.0)
direction_to_crop = LookDirection(45.0)
+31
View File
@@ -243,6 +243,37 @@ class TestSleepWithBed(unittest.TestCase):
self.assertEqual(state.beds, [])
self.assertEqual(state.state, state.choose_bed)
def test_bed_approach_follows_path_before_aiming_at_bed(self):
bed = (4, 64, 2)
opening = (3, 64, 0)
state = SleepWithBedStates(Munch(
pos=(0, 64, 0), path=[opening], look_at=bed,
game=FakeGame(), world=FakeWorld()))
state.area = bed
state.opening = opening
state.opening_deadline = 9999999999
state.going_to_bed()
self.assertIsNone(state.g.look_at)
state.g.pos = opening
state.going_to_bed()
self.assertEqual(state.g.look_at, bed)
self.assertEqual(state.state, state.turn_to_bed)
def test_bed_placement_approach_follows_path(self):
opening = (3, 64, 0)
state = SleepWithBedStates(Munch(
pos=(0, 64, 0), path=[opening], look_at=(4, 64, 2),
game=FakeGame(), world=FakeWorld()))
state.area = (4, 64, 2)
state.opening = opening
state.opening_deadline = 9999999999
state.going_to_area()
self.assertIsNone(state.g.look_at)
def test_arrival_accepts_completed_path_with_small_position_error(self):
state = SleepWithBedStates(Munch(
pos=(0, 64, 0), path=[(1, 64, 0)], look_at=None,