From 6ecd174952513ed045ee255c2b9d264ceec9bf70 Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Thu, 3 Oct 2024 14:40:08 +0200 Subject: [PATCH 01/14] Update the dependencies for modular_robot_physical --- modular_robot_physical/pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modular_robot_physical/pyproject.toml b/modular_robot_physical/pyproject.toml index 6adc977a7..c07053088 100644 --- a/modular_robot_physical/pyproject.toml +++ b/modular_robot_physical/pyproject.toml @@ -32,8 +32,9 @@ pyrr = "^0.10.3" typed-argparse = "^0.3.1" pycapnp = { version = "^2.0.0b2" } pigpio = { version = "^1.78", optional = true } -revolve2-robohat = { version = "0.5.0", optional = true } +revolve2-robohat = { version = "0.6.1", optional = true } rpi-lgpio = { version = "0.5", optional = true } +opencv-python = "^4.10.0.84" # cpnp-stub-generator is disabled because it depends on pycapnp <2.0.0. # It is rarely used and by developers only, so we remove it for now and developers can install it manually. # If you manually install it make sure you also install the correct pycpanp version afterwards as it will be overridden. From a39b506030feb0ea5bea3db56e2c82d1ad5c6800 Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Thu, 3 Oct 2024 14:42:35 +0200 Subject: [PATCH 02/14] Add camera support for physical_interfaces v2 --- .../v2/_v2_physical_interface.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/modular_robot_physical/revolve2/modular_robot_physical/physical_interfaces/v2/_v2_physical_interface.py b/modular_robot_physical/revolve2/modular_robot_physical/physical_interfaces/v2/_v2_physical_interface.py index 5f73f5923..e34953315 100644 --- a/modular_robot_physical/revolve2/modular_robot_physical/physical_interfaces/v2/_v2_physical_interface.py +++ b/modular_robot_physical/revolve2/modular_robot_physical/physical_interfaces/v2/_v2_physical_interface.py @@ -1,13 +1,13 @@ import math from typing import Sequence -import cv2 import numpy as np from numpy.typing import NDArray from pyrr import Vector3 from robohatlib.hal.assemblyboard.PwmPlug import PwmPlug from robohatlib.hal.assemblyboard.servo.ServoData import ServoData from robohatlib.hal.assemblyboard.ServoAssemblyConfig import ServoAssemblyConfig +from robohatlib.hal.Camera import Camera from robohatlib.Robohat import Robohat from .._physical_interface import PhysicalInterface @@ -84,6 +84,7 @@ def __init__(self, debug: bool, dry: bool) -> None: self._robohat.init(servoboard_1_datas_list, servoboard_2_datas_list) self._robohat.do_buzzer_beep() self._robohat.set_servo_direct_mode(_mode=True) + self.cam: Camera = self._robohat.get_camera() def set_servo_targets(self, pins: list[int], targets: list[float]) -> None: """ @@ -181,17 +182,7 @@ def get_camera_view(self) -> NDArray[np.uint8]: """ Get the current view from the camera. - :returns: A dummy image until robohatlib has camera support. - """ - image = np.zeros((3, 100, 100), dtype=int) - cv2.putText( - image, - "Dummy Image", - (10, 10), - fontFace=cv2.FONT_HERSHEY_SIMPLEX, - fontScale=1, - color=(255, 0, 0), - thickness=1, - lineType=2, - ) + :returns: An image captured from robohatlib. + """ + image = self.cam.get_capture_array() return image From b29023e78726d092873786bff52b17d84030b410 Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Thu, 3 Oct 2024 15:04:44 +0200 Subject: [PATCH 03/14] Update the doc for clarity --- docs/source/physical_robot_core_setup/index.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/physical_robot_core_setup/index.rst b/docs/source/physical_robot_core_setup/index.rst index 533a0b640..012c40f91 100644 --- a/docs/source/physical_robot_core_setup/index.rst +++ b/docs/source/physical_robot_core_setup/index.rst @@ -39,6 +39,8 @@ On the RPi adjust the config in `/boot/config.txt` or on newer systems `/boot/fi ------------------ Setting up the RPi ------------------ +**Note**: For students in the CI Group, the RPi is already set up. All RPis are flashed with the same image, so the following steps are not necessary. Additionally, there should be an IP address on the head, allowing you to SSH into it. However, be aware that there will always be ongoing development changes in the revolve2-modular-robot_physical and revolve2-robohat packages, so make sure to pip install the latest version in your virtual environment. + This step is the same for all types of hardware. #. Flash the SD card with Raspberry Pi OS (previously Raspbian). Some Important notes: From aced70142afda2510e18a18db8cb63bc70b7f0c2 Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Mon, 7 Oct 2024 00:08:56 +0200 Subject: [PATCH 04/14] Refactor image channel conversion for cap'n proto serialization --- .../robot_daemon/_robo_server_impl.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modular_robot_physical/revolve2/modular_robot_physical/robot_daemon/_robo_server_impl.py b/modular_robot_physical/revolve2/modular_robot_physical/robot_daemon/_robo_server_impl.py index 39e8ab6b8..30824cb2c 100644 --- a/modular_robot_physical/revolve2/modular_robot_physical/robot_daemon/_robo_server_impl.py +++ b/modular_robot_physical/revolve2/modular_robot_physical/robot_daemon/_robo_server_impl.py @@ -293,8 +293,9 @@ def _camera_view_to_capnp(image: NDArray[np.uint8]) -> capnpImage: :param image: The NDArray image. :return: The capnp Image object. """ + # Convert each channel to a list of Int32 for Cap'n Proto return robot_daemon_protocol_capnp.Image( - r=image[0].flatten().tolist(), - g=image[1].flatten().tolist(), - b=image[2].flatten().tolist(), + r=image[:, :, 0].astype(np.int32).flatten().tolist(), + g=image[:, :, 1].astype(np.int32).flatten().tolist(), + b=image[:, :, 2].astype(np.int32).flatten().tolist(), ) From 68b0b5f2a166ca16b43260aa4402be4ff4f1882e Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Mon, 7 Oct 2024 14:12:52 +0200 Subject: [PATCH 05/14] Add display_camera_view() to remote and include camera support in an example --- .../5a_physical_robot_remote/main.py | 1 + .../modular_robot_physical/remote/_remote.py | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py b/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py index b7ae25644..27b298de1 100644 --- a/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py +++ b/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py @@ -107,6 +107,7 @@ def main() -> None: hostname="localhost", # "Set the robot IP here. debug=True, on_prepared=on_prepared, + camera_mode=False, ) """ Note that theoretically if you want the robot to be self controlled and not dependant on a external remote, you can run this script on the robot locally. diff --git a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py index 6bbf0feca..5f20fc2dd 100644 --- a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py +++ b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py @@ -3,10 +3,10 @@ from typing import Callable import capnp +import cv2 import numpy as np from numpy.typing import NDArray from pyrr import Vector3 - from revolve2.modular_robot.body.base import ActiveHinge from revolve2.modular_robot.body.sensors import CameraSensor, IMUSensor from revolve2.modular_robot.sensor_state import ModularRobotSensorState @@ -23,7 +23,6 @@ from ._modular_robot_sensor_state_impl_v1 import ModularRobotSensorStateImplV1 from ._modular_robot_sensor_state_impl_v2 import ModularRobotSensorStateImplV2 - def _active_hinge_targets_to_pin_controls( config: Config, active_hinges_and_targets: list[tuple[UUIDKey[ActiveHinge], float]] ) -> list[robot_daemon_protocol_capnp.PinControl]: @@ -50,6 +49,7 @@ async def _run_remote_impl( port: int, debug: bool, manual_mode: bool, + camera_mode: bool, ) -> None: active_hinge_sensor_to_pin = { UUIDKey(key.value.sensors.active_hinge_sensor): pin @@ -207,6 +207,11 @@ async def _run_remote_impl( pin_controls = _active_hinge_targets_to_pin_controls( config, control_interface._set_active_hinges ) + # Display camera image + if camera_mode: + capnp_image = sensor_readings.cameraView + _display_camera_view(capnp_image) + match hardware_type: case HardwareType.v1: await service.control( @@ -318,6 +323,23 @@ def _get_camera_sensor_state( } +def _display_camera_view( + camera_view: robot_daemon_protocol_capnp.Image +) -> None: + """ + Convert Cap'n Proto image back to an ND array for OpenCV and display it + """ + height = 480 + width = 640 + r_channel = np.array(camera_view.r, dtype=np.uint8).reshape((height, width)) + g_channel = np.array(camera_view.g, dtype=np.uint8).reshape((height, width)) + b_channel = np.array(camera_view.b, dtype=np.uint8).reshape((height, width)) + rgb_image = cv2.merge((r_channel, g_channel, b_channel)) + + cv2.imshow("Captured Image", rgb_image) + cv2.waitKey(1) + + def run_remote( config: Config, hostname: str, @@ -325,6 +347,7 @@ def run_remote( port: int = STANDARD_PORT, debug: bool = False, manual_mode: bool = False, + camera_mode: bool = False, ) -> None: """ Control a robot remotely, running the controller on your local machine. @@ -335,6 +358,7 @@ def run_remote( :param port: Port the robot daemon uses. :param debug: Enable debug messages. :param manual_mode: Enable manual controls for the robot, ignoring the brain. + :param camera_mode: Display the camera view of the robot. """ asyncio.run( capnp.run( @@ -345,6 +369,7 @@ def run_remote( port=port, debug=debug, manual_mode=manual_mode, + camera_mode=camera_mode, ) ) ) From 7ca79f6189ebe07b70c4d61ed6622b4a3153926f Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Mon, 7 Oct 2024 15:23:35 +0200 Subject: [PATCH 06/14] Move the display camera function to v2 section --- .../revolve2/modular_robot_physical/remote/_remote.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py index 5f20fc2dd..a4ea855af 100644 --- a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py +++ b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py @@ -207,10 +207,6 @@ async def _run_remote_impl( pin_controls = _active_hinge_targets_to_pin_controls( config, control_interface._set_active_hinges ) - # Display camera image - if camera_mode: - capnp_image = sensor_readings.cameraView - _display_camera_view(capnp_image) match hardware_type: case HardwareType.v1: @@ -247,6 +243,11 @@ async def _run_remote_impl( camera_sensor_states=camera_sensor_states, ) + # Display camera image + if camera_mode: + capnp_image = sensor_readings.cameraView + _display_camera_view(capnp_image) + if battery_print_timer > 5.0: print( f"Battery level is at {sensor_readings.battery * 100.0}%." From 6b023ad82093addc1ff1f43ceb47a76021f199e2 Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Tue, 8 Oct 2024 00:24:30 +0200 Subject: [PATCH 07/14] Refactor camera support to reduce code duplication --- .../modular_robot_physical/remote/_remote.py | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py index a4ea855af..886329061 100644 --- a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py +++ b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py @@ -49,7 +49,7 @@ async def _run_remote_impl( port: int, debug: bool, manual_mode: bool, - camera_mode: bool, + display_camera_view: bool, ) -> None: active_hinge_sensor_to_pin = { UUIDKey(key.value.sensors.active_hinge_sensor): pin @@ -244,9 +244,11 @@ async def _run_remote_impl( ) # Display camera image - if camera_mode: - capnp_image = sensor_readings.cameraView - _display_camera_view(capnp_image) + if display_camera_view: + _display_camera_view( + config.modular_robot.body.core.sensors.camera_sensor, + sensor_readings + ) if battery_print_timer > 5.0: print( @@ -271,11 +273,11 @@ def _capnp_to_camera_view( :param camera_size: The camera size to reconstruct the image. :return: The NDArray imag. """ - np_image = np.zeros(shape=(3, *camera_size), dtype=np.uint8) - np_image[0] = np.array(image.r).reshape(camera_size).astype(np.uint8) - np_image[1] = np.array(image.g).reshape(camera_size).astype(np.uint8) - np_image[2] = np.array(image.b).reshape(camera_size).astype(np.uint8) - return np_image + r_channel = np.array(image.r, dtype=np.uint8).reshape((camera_size[0], camera_size[1])) + g_channel = np.array(image.g, dtype=np.uint8).reshape((camera_size[0], camera_size[1])) + b_channel = np.array(image.b, dtype=np.uint8).reshape((camera_size[0], camera_size[1])) + rgb_image = cv2.merge((r_channel, g_channel, b_channel)).astype(np.uint8) + return rgb_image def _get_imu_sensor_state( @@ -325,20 +327,21 @@ def _get_camera_sensor_state( def _display_camera_view( - camera_view: robot_daemon_protocol_capnp.Image + camera_sensor: CameraSensor | None, + sensor_readings: robot_daemon_protocol_capnp.SensorReadings, ) -> None: """ - Convert Cap'n Proto image back to an ND array for OpenCV and display it - """ - height = 480 - width = 640 - r_channel = np.array(camera_view.r, dtype=np.uint8).reshape((height, width)) - g_channel = np.array(camera_view.g, dtype=np.uint8).reshape((height, width)) - b_channel = np.array(camera_view.b, dtype=np.uint8).reshape((height, width)) - rgb_image = cv2.merge((r_channel, g_channel, b_channel)) + Display a camera view from the camera readings. - cv2.imshow("Captured Image", rgb_image) - cv2.waitKey(1) + :param camera_sensor: The sensor in question. + :param sensor_readings: The sensor readings. + """ + if camera_sensor is None: + print("No camera sensor found.") + else: + rgb_image = _capnp_to_camera_view(sensor_readings.cameraView, camera_sensor.camera_size) + cv2.imshow("Captured Image", rgb_image) + cv2.waitKey(1) def run_remote( @@ -348,7 +351,7 @@ def run_remote( port: int = STANDARD_PORT, debug: bool = False, manual_mode: bool = False, - camera_mode: bool = False, + display_camera_view: bool = False, ) -> None: """ Control a robot remotely, running the controller on your local machine. @@ -359,7 +362,7 @@ def run_remote( :param port: Port the robot daemon uses. :param debug: Enable debug messages. :param manual_mode: Enable manual controls for the robot, ignoring the brain. - :param camera_mode: Display the camera view of the robot. + :param display_camera_view: Display the camera view of the robot. """ asyncio.run( capnp.run( @@ -370,7 +373,7 @@ def run_remote( port=port, debug=debug, manual_mode=manual_mode, - camera_mode=camera_mode, + display_camera_view=display_camera_view, ) ) ) From f9e3e68a7fbff4e6e25997e470baa4f1f5d8999b Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Tue, 8 Oct 2024 00:25:34 +0200 Subject: [PATCH 08/14] Add a camera to a modular body in an example --- .../5a_physical_robot_remote/main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py b/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py index 27b298de1..562c324ce 100644 --- a/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py +++ b/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py @@ -6,6 +6,10 @@ from revolve2.modular_robot.body.base import ActiveHinge from revolve2.modular_robot.body.v2 import ActiveHingeV2, BodyV2, BrickV2 from revolve2.modular_robot.brain.cpg import BrainCpgNetworkNeighborRandom +from revolve2.modular_robot.brain.dummy import BrainDummy +from revolve2.modular_robot.body.sensors import CameraSensor +from pyrr import Vector3 + from revolve2.modular_robot_physical import Config, UUIDKey from revolve2.modular_robot_physical.remote import run_remote @@ -40,6 +44,8 @@ def make_body() -> ( body.core_v2.right_face.bottom, body.core_v2.right_face.bottom.attachment, ) + """Add a camera sensor to the core.""" + body.core.add_sensor(CameraSensor(position=Vector3([0, 0, 0]), camera_size=(480, 640))) return body, active_hinges @@ -100,6 +106,7 @@ def main() -> None: Create a Remote for the physical modular robot. Make sure to target the correct hardware type and fill in the correct IP and credentials. The debug flag is turned on. If the remote complains it cannot keep up, turning off debugging might improve performance. + If you want to display the camera view, set display_camera_view to True. """ print("Initializing robot..") run_remote( @@ -107,7 +114,7 @@ def main() -> None: hostname="localhost", # "Set the robot IP here. debug=True, on_prepared=on_prepared, - camera_mode=False, + display_camera_view=False, ) """ Note that theoretically if you want the robot to be self controlled and not dependant on a external remote, you can run this script on the robot locally. From 068c1f46f273041170be05e91082eeca556dead9 Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Tue, 8 Oct 2024 00:36:34 +0200 Subject: [PATCH 09/14] Reformat the code --- .../modular_robot_physical/remote/_remote.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py index 886329061..4d2886612 100644 --- a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py +++ b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py @@ -273,9 +273,15 @@ def _capnp_to_camera_view( :param camera_size: The camera size to reconstruct the image. :return: The NDArray imag. """ - r_channel = np.array(image.r, dtype=np.uint8).reshape((camera_size[0], camera_size[1])) - g_channel = np.array(image.g, dtype=np.uint8).reshape((camera_size[0], camera_size[1])) - b_channel = np.array(image.b, dtype=np.uint8).reshape((camera_size[0], camera_size[1])) + r_channel = np.array(image.r, dtype=np.uint8).reshape( + (camera_size[0], camera_size[1]) + ) + g_channel = np.array(image.g, dtype=np.uint8).reshape( + (camera_size[0], camera_size[1]) + ) + b_channel = np.array(image.b, dtype=np.uint8).reshape( + (camera_size[0], camera_size[1]) + ) rgb_image = cv2.merge((r_channel, g_channel, b_channel)).astype(np.uint8) return rgb_image @@ -339,7 +345,9 @@ def _display_camera_view( if camera_sensor is None: print("No camera sensor found.") else: - rgb_image = _capnp_to_camera_view(sensor_readings.cameraView, camera_sensor.camera_size) + rgb_image = _capnp_to_camera_view( + sensor_readings.cameraView, camera_sensor.camera_size + ) cv2.imshow("Captured Image", rgb_image) cv2.waitKey(1) From dd2a355a81434cd479fab21e457f687dd84af925 Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Tue, 8 Oct 2024 00:42:27 +0200 Subject: [PATCH 10/14] Reformat --- .../5a_physical_robot_remote/main.py | 4 +++- .../revolve2/modular_robot_physical/remote/_remote.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py b/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py index 562c324ce..a98363708 100644 --- a/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py +++ b/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py @@ -45,7 +45,9 @@ def make_body() -> ( body.core_v2.right_face.bottom.attachment, ) """Add a camera sensor to the core.""" - body.core.add_sensor(CameraSensor(position=Vector3([0, 0, 0]), camera_size=(480, 640))) + body.core.add_sensor( + CameraSensor(position=Vector3([0, 0, 0]), camera_size=(480, 640)) + ) return body, active_hinges diff --git a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py index 4d2886612..2339505ff 100644 --- a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py +++ b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py @@ -247,7 +247,7 @@ async def _run_remote_impl( if display_camera_view: _display_camera_view( config.modular_robot.body.core.sensors.camera_sensor, - sensor_readings + sensor_readings, ) if battery_print_timer > 5.0: From f7cc00cc2ed693e3c283f97a30ec196d2ac06958 Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Tue, 8 Oct 2024 01:06:52 +0200 Subject: [PATCH 11/14] Reformat and fix image type --- .../physical_interfaces/v2/_v2_physical_interface.py | 2 +- .../revolve2/modular_robot_physical/remote/_remote.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modular_robot_physical/revolve2/modular_robot_physical/physical_interfaces/v2/_v2_physical_interface.py b/modular_robot_physical/revolve2/modular_robot_physical/physical_interfaces/v2/_v2_physical_interface.py index e34953315..7d34ddec7 100644 --- a/modular_robot_physical/revolve2/modular_robot_physical/physical_interfaces/v2/_v2_physical_interface.py +++ b/modular_robot_physical/revolve2/modular_robot_physical/physical_interfaces/v2/_v2_physical_interface.py @@ -184,5 +184,5 @@ def get_camera_view(self) -> NDArray[np.uint8]: :returns: An image captured from robohatlib. """ - image = self.cam.get_capture_array() + image = self.cam.get_capture_array().astype(np.uint8) return image diff --git a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py index 2339505ff..7ead00f2a 100644 --- a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py +++ b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py @@ -23,6 +23,7 @@ from ._modular_robot_sensor_state_impl_v1 import ModularRobotSensorStateImplV1 from ._modular_robot_sensor_state_impl_v2 import ModularRobotSensorStateImplV2 + def _active_hinge_targets_to_pin_controls( config: Config, active_hinges_and_targets: list[tuple[UUIDKey[ActiveHinge], float]] ) -> list[robot_daemon_protocol_capnp.PinControl]: From 9fa50c9380ed69eadc97dbed6b53f4669dc65e75 Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Tue, 8 Oct 2024 01:20:23 +0200 Subject: [PATCH 12/14] Reformat --- .../5a_physical_robot_remote/main.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py b/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py index a98363708..ed0d96fa0 100644 --- a/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py +++ b/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py @@ -1,15 +1,13 @@ """An example on how to remote control a physical modular robot.""" +from pyrr import Vector3 from revolve2.experimentation.rng import make_rng_time_seed from revolve2.modular_robot import ModularRobot from revolve2.modular_robot.body import RightAngles from revolve2.modular_robot.body.base import ActiveHinge +from revolve2.modular_robot.body.sensors import CameraSensor from revolve2.modular_robot.body.v2 import ActiveHingeV2, BodyV2, BrickV2 from revolve2.modular_robot.brain.cpg import BrainCpgNetworkNeighborRandom -from revolve2.modular_robot.brain.dummy import BrainDummy -from revolve2.modular_robot.body.sensors import CameraSensor -from pyrr import Vector3 - from revolve2.modular_robot_physical import Config, UUIDKey from revolve2.modular_robot_physical.remote import run_remote From a75714760782073c79d8b4f4e32387e27412959d Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Tue, 8 Oct 2024 01:27:40 +0200 Subject: [PATCH 13/14] Reformat --- .../5_physical_modular_robots/5a_physical_robot_remote/main.py | 1 + .../revolve2/modular_robot_physical/remote/_remote.py | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py b/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py index ed0d96fa0..b63898ef8 100644 --- a/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py +++ b/examples/5_physical_modular_robots/5a_physical_robot_remote/main.py @@ -1,6 +1,7 @@ """An example on how to remote control a physical modular robot.""" from pyrr import Vector3 + from revolve2.experimentation.rng import make_rng_time_seed from revolve2.modular_robot import ModularRobot from revolve2.modular_robot.body import RightAngles diff --git a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py index 7ead00f2a..085b16233 100644 --- a/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py +++ b/modular_robot_physical/revolve2/modular_robot_physical/remote/_remote.py @@ -7,6 +7,7 @@ import numpy as np from numpy.typing import NDArray from pyrr import Vector3 + from revolve2.modular_robot.body.base import ActiveHinge from revolve2.modular_robot.body.sensors import CameraSensor, IMUSensor from revolve2.modular_robot.sensor_state import ModularRobotSensorState From 1160bfedbfa2c4787f58e21f345503093c119cfc Mon Sep 17 00:00:00 2001 From: Ting-Chia Chiang Date: Tue, 8 Oct 2024 01:31:20 +0200 Subject: [PATCH 14/14] Update robohat version --- modular_robot_physical/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modular_robot_physical/pyproject.toml b/modular_robot_physical/pyproject.toml index c07053088..da3c1b8d5 100644 --- a/modular_robot_physical/pyproject.toml +++ b/modular_robot_physical/pyproject.toml @@ -32,7 +32,7 @@ pyrr = "^0.10.3" typed-argparse = "^0.3.1" pycapnp = { version = "^2.0.0b2" } pigpio = { version = "^1.78", optional = true } -revolve2-robohat = { version = "0.6.1", optional = true } +revolve2-robohat = { version = "0.6.2", optional = true } rpi-lgpio = { version = "0.5", optional = true } opencv-python = "^4.10.0.84" # cpnp-stub-generator is disabled because it depends on pycapnp <2.0.0.