diff --git a/README.md b/README.md index b791e54..6d1ca03 100644 --- a/README.md +++ b/README.md @@ -136,3 +136,20 @@ Now you should be able to use `pyrealsense2`. ``` shell /usr/bin/Intel.Realsense.CustomRW -sn 017322071705 -w -f update_calibration.xml ``` + +# Usage + +Under the main folder, run: +``` shell +python scripts/deoxys_camera_node.py --camera-ref rs_0 --use-rgb +--use-depth --eval --use-rec --visualization +``` +If you want to specify ip (e.g. localhost), you should add an argument +`--host IP_ADDR` + +Currently we use redis server. Follow the instruction of their +[official +documentation](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-on-linux/). After +installation, edit the file `/etc/redis/redis.conf` with sudo access, +comment out the original line of `bind 127.0.0.1 ::1` and add a new +line that binds to your own IP. diff --git a/camera_calibration/hand_eye_calibration.py b/camera_calibration/hand_eye_calibration.py index 7211d52..e9e29f8 100644 --- a/camera_calibration/hand_eye_calibration.py +++ b/camera_calibration/hand_eye_calibration.py @@ -60,7 +60,8 @@ def main(): # load a list of joints to move - joints_json_file_name = f"{args.config_folder}/{args.config_filename}" + # joints_json_file_name = f"{args.config_folder}/{args.config_filename}" + joints_json_file_name = args.config_filename joint_info = json.load(open(joints_json_file_name, "r")) joint_list = joint_info["joints"] @@ -118,7 +119,7 @@ def main(): color_img = imgs["color"] depth_img = imgs["depth"] - cv2.imshow("", color_img) + cv2.imshow("", color_img[..., ::-1]) cv2.imwrite(f"{calibration_img_folder}/{idx}_color.png", color_img) cv2.imwrite(f"{calibration_img_folder}/{idx}_depth.png", depth_img) cv2.waitKey(1) diff --git a/camera_calibration/record_robot_joints.py b/camera_calibration/record_robot_joints.py index 4b188d4..b35cd8e 100644 --- a/camera_calibration/record_robot_joints.py +++ b/camera_calibration/record_robot_joints.py @@ -81,6 +81,7 @@ def main(): with open(joint_info_json_filename, "w") as f: json.dump({"joints": save_joints}, f, indent=4) + print(f"Saving to {file_name}.json") robot_interface.close() diff --git a/deoxys_vision/utils/calibration_utils.py b/deoxys_vision/utils/calibration_utils.py index 315cb9c..a07bfb1 100644 --- a/deoxys_vision/utils/calibration_utils.py +++ b/deoxys_vision/utils/calibration_utils.py @@ -51,18 +51,18 @@ def write_calibrated_extrinsics(data, return default_extrinsic_json_file -def load_default_extrinsics(camera_id, - camera_type, - calibration_method="tsai", - fmt="homogeneous"): - default_extrinsic_json_file = os.path.join(get_calibration_path("results"), - f"camera_{camera_type}_{camera_id}_{calibration_method}_extrinsics.json") +# def load_default_extrinsics(camera_id, +# camera_type, +# calibration_method="tsai", +# fmt="homogeneous"): +# default_extrinsic_json_file = os.path.join(get_calibration_path("results"), +# f"camera_{camera_type}_{camera_id}_{calibration_method}_extrinsics.json") - assert(os.path.exists(default_extrinsic_json_file)), f"{default_extrinsic_json_file} needs to exist" +# assert(os.path.exists(default_extrinsic_json_file)), f"{default_extrinsic_json_file} needs to exist" - with open(default_extrinsic_json_file, "r") as f: - data = json.load(f) - return get_extrinsics_data(data, fmt) +# with open(default_extrinsic_json_file, "r") as f: +# data = json.load(f) +# return get_extrinsics_data(data, fmt) def get_extrinsics_data(data, fmt): if fmt == "matrix": diff --git a/scripts/deoxys_camera_node.py b/scripts/deoxys_camera_node.py index cc608f4..45dbe9f 100644 --- a/scripts/deoxys_camera_node.py +++ b/scripts/deoxys_camera_node.py @@ -116,6 +116,7 @@ def main(): img_counter = 0 freq = 30.0 + MAX_IMG_NUM = 653360 while True: start_time = time.time_ns() @@ -208,9 +209,9 @@ def main(): camera2redis_pub_interface.set_img_info(img_info) camera2redis_pub_interface.set_img_buffer(imgs=imgs) - print(img_counter) if counter < COUNT_THRESH: img_counter += 1 + img_counter = img_counter % MAX_IMG_NUM # if not args.eval: # if counter < COUNT_THRESH: @@ -241,7 +242,7 @@ def main(): time_interval = (end_time - start_time) / (10 ** 9) if time_interval < 1.0 / freq: time.sleep(1.0 / freq - time_interval) - print(f"The camera node only took {time_interval} to transmit image") + # print(f"The camera node only took {time_interval} to transmit image") if camera2redis_pub_interface.finished: break