Skip to content
This repository has been archived by the owner on Oct 28, 2023. It is now read-only.

Commit

Permalink
MFT 1日目終了時のコード
Browse files Browse the repository at this point in the history
  • Loading branch information
n4o847 committed Oct 14, 2023
1 parent d639b5b commit 13a0666
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
1 change: 1 addition & 0 deletions ptcs/ptcs_bridge/master_controller_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ def wrapped_callback(_characteristic: BleakGATTCharacteristic, data: bytearray):
assert characteristic is not None

await self._client.start_notify(characteristic, wrapped_callback)
logger.info("%s start notify speed", self)
3 changes: 3 additions & 0 deletions ptcs/ptcs_bridge/train_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def wrapped_callback(_characteristic: BleakGATTCharacteristic, data: bytearray):

characteristic = self._get_characteristic_position_id()
await self._client.start_notify(characteristic, wrapped_callback)
logger.info("%s start notify position id", self)

async def start_notify_rotation(self, callback: NotifyRotationCallback) -> None:
def wrapped_callback(_characteristic: BleakGATTCharacteristic, data: bytearray):
Expand All @@ -94,6 +95,7 @@ def wrapped_callback(_characteristic: BleakGATTCharacteristic, data: bytearray):

characteristic = self._get_characteristic_rotation()
await self._client.start_notify(characteristic, wrapped_callback)
logger.info("%s start notify rotation", self)

async def start_notify_voltage(self, callback: NotifyVoltageCallback) -> None:
def wrapped_callback(_characteristic: BleakGATTCharacteristic, data: bytearray):
Expand All @@ -104,3 +106,4 @@ def wrapped_callback(_characteristic: BleakGATTCharacteristic, data: bytearray):

characteristic = self._get_characteristic_voltage()
await self._client.start_notify(characteristic, wrapped_callback)
logger.info("%s start notify voltage", self)
1 change: 1 addition & 0 deletions ptcs/ptcs_bridge/wire_pole_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ def wrapped_callback(_characteristic: BleakGATTCharacteristic, data: bytearray):
assert characteristic is not None

await self._client.start_notify(characteristic, wrapped_callback)
logger.info("%s start notify collapse", self)
18 changes: 9 additions & 9 deletions ptcs/ptcs_control/mft2023.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def create_control(logger: logging.Logger | None = None) -> Control:
max_input=250,
max_speed=40.0,
length=14.0,
delta_per_motor_rotation=0.4553,
delta_per_motor_rotation=0.4553 * 0.9 * 0.9,
head_position=DirectedPosition(
section=s3,
target_junction=j1,
Expand Down Expand Up @@ -154,11 +154,11 @@ def create_control(logger: logging.Logger | None = None) -> Control:
)
t3 = Train(
id="t3",
min_input=200,
max_input=250,
min_input=190,
max_input=220,
max_speed=40.0,
length=14.0,
delta_per_motor_rotation=0.314,
delta_per_motor_rotation=0.4208,
head_position=DirectedPosition(
section=s3,
target_junction=j1,
Expand All @@ -177,19 +177,19 @@ def create_control(logger: logging.Logger | None = None) -> Control:
min_input=180,
max_input=230,
max_speed=40.0,
length=70.0,
delta_per_motor_rotation=0.6378,
length=40.0,
delta_per_motor_rotation=0.4241,
head_position=DirectedPosition(
section=s1,
target_junction=j0,
mileage=WATARI_RAIL_B + STRAIGHT_RAIL * 4,
),
)

control.add_train(t0)
control.add_train(t1)
# control.add_train(t0)
# control.add_train(t1)
control.add_train(t2)
# control.add_train(t3)
control.add_train(t3)
control.add_train(t4)

stop_0 = Stop(
Expand Down
18 changes: 9 additions & 9 deletions ptcs/ptcs_server/mft2023.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@

def create_bridge() -> Bridge2:
bridge = Bridge2()
# bridge.add_train(TrainSimulator("t0"))
bridge.add_train(TrainClient("t0", ADDRESS_T0))
# bridge.add_train(TrainSimulator("t1"))
bridge.add_train(TrainClient("t1", ADDRESS_T1))
bridge.add_train(TrainSimulator("t0"))
# bridge.add_train(TrainClient("t0", ADDRESS_T0))
bridge.add_train(TrainSimulator("t1"))
# bridge.add_train(TrainClient("t1", ADDRESS_T1))
# bridge.add_train(TrainSimulator("t2"))
bridge.add_train(TrainClient("t2", ADDRESS_T2))
bridge.add_train(TrainSimulator("t3"))
# bridge.add_train(TrainClient("t3", ADDRESS_T3))
# bridge.add_train(TrainSimulator("t4"))
bridge.add_train(TrainClient("t4", ADDRESS_T4))
# bridge.add_train(TrainSimulator("t3"))
bridge.add_train(TrainClient("t3", ADDRESS_T3))
bridge.add_train(TrainSimulator("t4"))
# bridge.add_train(TrainClient("t4", ADDRESS_T4))
bridge.add_obstacle(WirePoleClient("obstacle_0", ADDRESS_WIRE_POLE))
bridge.add_controller(MasterControllerClient("t0", ADDRESS_MASTER_CONTROLLER))
bridge.add_controller(MasterControllerClient("t3", ADDRESS_MASTER_CONTROLLER))
return bridge

0 comments on commit 13a0666

Please sign in to comment.