-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ViNT v1 Release: Checkpoints, Training, LoCoBot Deployment
- Loading branch information
1 parent
a7c7b50
commit 942a6a3
Showing
57 changed files
with
5,073 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# camera parameters for src/gnm_locobot.launch | ||
video_device: "/dev/video0" # change this to your video device path | ||
image_width: 160 #640 | ||
image_height: 120 #480 | ||
pixel_format: yuyv | ||
camera_frame_id: "usb_cam" | ||
io_method: "mmap" | ||
framerate: 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# camera parameters for src/gnm_locobot.launch | ||
video_device: "/dev/video2" # change this to your video device path | ||
image_width: 160 | ||
image_height: 120 | ||
pixel_format: yuyv | ||
camera_frame_id: "usb_cam" | ||
io_method: "mmap" | ||
framerate: 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# # Velocity command sources | ||
# vel_sources: | ||
# # Teleoperation commands | ||
# teleop: | ||
# topic: /cmd_vel_mux/input/teleop | ||
# timeout: 0.6 | ||
# priority: 100 | ||
|
||
# # Move base commands | ||
# move_base: | ||
# topic: /cmd_vel_mux/input/navi | ||
# timeout: 0.6 | ||
# priority: 90 | ||
|
||
# # Mux parameters | ||
# yaml_cfg_file: "" | ||
# allow_unsafe_topics: false | ||
# cmd_vel_timeout: 0.25 | ||
# publish_topic: /mobile_base/commands/velocity | ||
|
||
|
||
subscribers: | ||
- name: "gnm vels" | ||
topic: "/cmd_vel_mux/input/navi" | ||
timeout: 0.1 | ||
priority: 0 | ||
short_desc: "The default cmd_vel, controllers unaware that we are multiplexing cmd_vel should come here" | ||
- name: "teleop" | ||
topic: "/cmd_vel_mux/input/teleop" | ||
timeout: 0.5 | ||
priority: 2 | ||
short_desc: "Navigation stack controller" | ||
- name: "gnm recovery" | ||
topic: "/cmd_vel_mux/input/recovery" | ||
timeout: 0.1 | ||
priority: 1 | ||
publisher: "/mobile_base/commands/velocity" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# joystick parameters for src/gnm_locobot.launch | ||
dev: "/dev/input/js0" # change this to your joystick device path | ||
|
||
# joystick parameters for src/joy_teleop.py | ||
deadman_switch: 5 # button index | ||
lin_vel_button: 4 | ||
ang_vel_button: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
vint: | ||
config_path: "../../train/config/vint.yaml" | ||
ckpt_path: "../model_weights/vint5c_29.pth" | ||
|
||
# gnmv9: | ||
# config_path: "../../train/config/gnmv9.yaml" | ||
# ckpt_path: "../model_weights/gnmv9_29.pth" | ||
|
||
late_fusion: | ||
config_path: "../../train/config/late_fusion.yaml" | ||
ckpt_path: "../model_weights/vint_late_fusion.pth" | ||
|
||
gnm: | ||
config_path: "../../train/config/gnm.yaml" | ||
ckpt_path: "../model_weights/gnm_large.pth" | ||
|
||
|
||
# add your own model configs here after saving the *.pth file to ../model_weight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# linear and angular speed limits for the robot | ||
max_v: 0.2 #0.4 # m/s | ||
max_w: 0.4 #0.8 # rad/s | ||
# observation rate fo the robot | ||
frame_rate: 4 # Hz | ||
graph_rate: 0.3333 # Hz | ||
|
||
# topic names (modify for different robots/nodes) | ||
vel_teleop_topic: /cmd_vel_mux/input/teleop | ||
vel_navi_topic: /cmd_vel_mux/input/navi | ||
vel_recovery_topic: /cmd_vel_mux/input/recovery | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: vint_deployment | ||
channels: | ||
- pytorch | ||
- conda-forge | ||
dependencies: | ||
- python=3.8.5 | ||
- cudatoolkit=11. | ||
- torchvision | ||
- numpy | ||
- matplotlib | ||
- pyyaml | ||
- rospkg | ||
- pip: | ||
- torch | ||
- torchvision | ||
- efficientnet_pytorch | ||
- warmup_scheduler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import argparse | ||
import os | ||
from utils import msg_to_pil | ||
import time | ||
|
||
# ROS | ||
import rospy | ||
from sensor_msgs.msg import Image | ||
from sensor_msgs.msg import Joy | ||
|
||
IMAGE_TOPIC = "/usb_cam/image_raw" | ||
TOPOMAP_IMAGES_DIR = "../topomaps/images" | ||
obs_img = None | ||
|
||
|
||
def remove_files_in_dir(dir_path: str): | ||
for f in os.listdir(dir_path): | ||
file_path = os.path.join(dir_path, f) | ||
try: | ||
if os.path.isfile(file_path) or os.path.islink(file_path): | ||
os.unlink(file_path) | ||
elif os.path.isdir(file_path): | ||
shutil.rmtree(file_path) | ||
except Exception as e: | ||
print("Failed to delete %s. Reason: %s" % (file_path, e)) | ||
|
||
|
||
def callback_obs(msg: Image): | ||
global obs_img | ||
obs_img = msg_to_pil(msg) | ||
|
||
|
||
def callback_joy(msg: Joy): | ||
if msg.buttons[0]: | ||
rospy.signal_shutdown("shutdown") | ||
|
||
|
||
def main(args: argparse.Namespace): | ||
global obs_img | ||
rospy.init_node("CREATE_TOPOMAP", anonymous=False) | ||
image_curr_msg = rospy.Subscriber( | ||
IMAGE_TOPIC, Image, callback_obs, queue_size=1) | ||
subgoals_pub = rospy.Publisher( | ||
"/subgoals", Image, queue_size=1) | ||
joy_sub = rospy.Subscriber("joy", Joy, callback_joy) | ||
|
||
topomap_name_dir = os.path.join(TOPOMAP_IMAGES_DIR, args.dir) | ||
if not os.path.isdir(topomap_name_dir): | ||
os.makedirs(topomap_name_dir) | ||
else: | ||
print(f"{topomap_name_dir} already exists. Removing previous images...") | ||
remove_files_in_dir(topomap_name_dir) | ||
|
||
|
||
assert args.dt > 0, "dt must be positive" | ||
rate = rospy.Rate(1/args.dt) | ||
print("Registered with master node. Waiting for images...") | ||
i = 0 | ||
start_time = float("inf") | ||
while not rospy.is_shutdown(): | ||
if obs_img is not None: | ||
obs_img.save(os.path.join(topomap_name_dir, f"{i}.png")) | ||
print("published image", i) | ||
i += 1 | ||
rate.sleep() | ||
start_time = time.time() | ||
obs_img = None | ||
if time.time() - start_time > 2 * args.dt: | ||
print(f"Topic {IMAGE_TOPIC} not publishing anymore. Shutting down...") | ||
rospy.signal_shutdown("shutdown") | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description=f"Code to generate topomaps from the {IMAGE_TOPIC} topic" | ||
) | ||
parser.add_argument( | ||
"--dir", | ||
"-d", | ||
default="topomap", | ||
type=str, | ||
help="path to topological map images in ../topomaps/images directory (default: topomap)", | ||
) | ||
parser.add_argument( | ||
"--dt", | ||
"-t", | ||
default=1., | ||
type=float, | ||
help=f"time between images sampled from the {IMAGE_TOPIC} topic (default: 3.0)", | ||
) | ||
args = parser.parse_args() | ||
|
||
main(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# Create a new tmux session | ||
session_name="gnm_locobot_$(date +%s)" | ||
tmux new-session -d -s $session_name | ||
|
||
# Split the window into three panes | ||
tmux selectp -t 0 # select the first (0) pane | ||
tmux splitw -v -p 50 # split it into two halves | ||
tmux selectp -t 0 # go back to the first pane | ||
tmux splitw -h -p 50 # split it into two halves | ||
|
||
# Run roscore in the first pane | ||
tmux select-pane -t 0 | ||
tmux send-keys "roscore" Enter | ||
|
||
# Run the create_topoplan.py script with command line args in the second pane | ||
tmux select-pane -t 1 | ||
tmux send-keys "conda activate gnm_deployment" Enter | ||
tmux send-keys "python create_topomap.py --dt 1 --dir $1" Enter | ||
|
||
# Change the directory to ../topomaps/bags and run the rosbag play command in the third pane | ||
tmux select-pane -t 2 | ||
tmux send-keys "mkdir -p ../topomaps/bags" Enter | ||
tmux send-keys "cd ../topomaps/bags" Enter | ||
tmux send-keys "rosbag play -r 1.5 $2" # feel free to change the playback rate to change the edge length in the graph | ||
|
||
# Attach to the tmux session | ||
tmux -2 attach-session -t $session_name |
Oops, something went wrong.