HKUST-Aerial-Robotics / D2SLAM

$D^2$SLAM: Decentralized and Distributed Collaborative Visual-inertial SLAM System for Aerial Swarm
293 stars 34 forks source link

Failed to replace the workspace in Docker #22

Open myboyhood opened 1 year ago

myboyhood commented 1 year ago

Thanks for this great job! But I meet some problem of workspace with docker pc


Problem generation

When I config the workspace and run as instructions

rosrun sync_bag_player docker_swarm_test.py /home/zph/hard_disk/rosbag/d2slam/D2SLAMDataset/quadcam_7inch_n3_2023_1_14/d2vins.yaml -z -t

The d2vins.yaml is as follows:

dataset:
  swarm1: #drone 1
    id: 1
    config_path: "Configs/"
    bag: "eight_noyaw_1-sync.bag"
  # swarm2: #drone 2
  #   id: 2
  #   config_path: "Configs/"
  #   bag: "eight_noyaw_2-sync.bag"
  # swarm5: #drone 3
  #   id: 5
  #   config_path: "Configs/"
  #   bag: "eight_noyaw_5-sync.bag"
  # swarm6: #drone 4
  #   id: 6
  #   config_path: "Configs/"
  #   bag: "eight_noyaw_6-sync.bag"
  # swarm7: #drone 5
  #   id: 7
  #   config_path: "Configs/"
  #   bag: "eight_noyaw_7-sync.bag"

output_path: "outputs/d2vins-5-sync/"
# workspace: "/home/xuhao/d2slam_ws/"
# workspace: "/home/zyh/d2slam_ws"
workspace: "/home/zph/ros_ws/d2slam_ws" # should be your d2slam ws
# workspace: ""
image_name: "d2slam:pc"
exclude_topics: ["/uwb_node/incoming_broadcast_data"]
rate: 0.1
t_start: 0
duration: 1000
start_latency: 10

entry_point_script: |
  #!/bin/bash
  RVIZ=false
  SHOW=true
  if [ $DRONE_ID -eq 1 ] 
  then
    SHOW=true
    RVIZ=true
  fi
  echo "ready to roslaunch d2vins"
  roslaunch d2vins quadcam.launch show:=$SHOW self_id:=$DRONE_ID \
    config:=/root/SwarmConfig/quadcam/quadcam_multi.yaml \
    enable_loop:=false rviz:=$RVIZ send_whole_img_desc:=false send_img:=false enable_pgo:=false \
    main_id:=1

Screenshot from 2023-10-11 15-44-26

I find I can not souce the workspace correctly, Because it has remapped to my worksapce of my host. I have compiled D2SLAM successfully on my host.

Some trys

But when I change the line in docker_swarm_test.py as follow:

    # -v {workspace}:/root/swarm_ws/ \
    # -v {workspace_mount} \
    cmd = f"""docker run --name {container_name} --gpus all --rm -it \
    -v {output_path}:/root/output/ \
    -v {swarm_config_path}:/root/SwarmConfig/ \
    -v {config_path}:/root/config.yaml \
    -v {dataset_path}:/root/bags/ \
    -v {entry_point_path}:/root/entry_point.sh \
    -v {docker_entry_point}:/root/docker_entrypoint.sh \
    --env='DRONE_ID={_id}' \
    --env='DISPLAY' --volume='/tmp/.X11-unix:/tmp/.X11-unix:rw' \
    --privileged \
    {image_name} /root/docker_entrypoint.sh /root/bags/{bag_path} {token}"""

That will not replace the workspace of docker with the workspace of host. It can run with the original code. But I can not change the code in host and run it in the docker.


Hopes

I hope I can change the code in /home/zph/ros_ws/d2slam_ws and run it in docker Could you give some suggestions? Best !