Skip to content

Commit

Permalink
Update instructions on redis and running camera node
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuyifengzju committed Apr 18, 2024
1 parent 6853fc0 commit 612fdf9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
5 changes: 3 additions & 2 deletions camera_calibration/hand_eye_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions camera_calibration/record_robot_joints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
20 changes: 10 additions & 10 deletions deoxys_vision/utils/calibration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
5 changes: 3 additions & 2 deletions scripts/deoxys_camera_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def main():

img_counter = 0
freq = 30.0
MAX_IMG_NUM = 653360
while True:
start_time = time.time_ns()

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 612fdf9

Please sign in to comment.