Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Visualization using Foxglove #201

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ef49d55
added ROSCameraPublisher.py and visualizer operator can publish camer…
storm-light Jun 15, 2021
a4f092b
minimal name changes
storm-light Jun 15, 2021
a7ecf65
fixed variable typo
storm-light Jun 15, 2021
44ff205
visualizer operator can now publish ROS PointCloud2 messages (display…
storm-light Jun 17, 2021
83c3b98
fixed mirror image for lidar
storm-light Jun 17, 2021
cd44d2c
visualizer operator can visualize segmentation frames and depth frame…
storm-light Jun 23, 2021
8155d82
visualizes planning world
storm-light Jun 24, 2021
bf5a24d
streams can be displayed simultaneously (in foxglove), still has pyga…
storm-light Jul 3, 2021
ccce977
removed all dependencies on pygame in visualizer_operator, though sti…
storm-light Jul 4, 2021
22a3900
removed run_visualizer_control_loop
storm-light Jul 6, 2021
a7b36ce
removed visualize() methods from camera_frame.py, depth_frame.py, poi…
storm-light Jul 6, 2021
87b3a53
renamed ROSCameraPublisher.py to ros_camera_publisher.py and ROSLIDAR…
storm-light Jul 6, 2021
03e9752
added updated dockerfile (WIP) to install foxglove and ROS
storm-light Jul 6, 2021
dd73dfc
[Bug] Ensure localization sends a pose even if it is innacurate.
ICGog Jul 7, 2021
c8fa7b2
Support arbitrary traffic manager ports (#202)
pschafhalter Jul 7, 2021
1518c0a
[Bug] Ensure that the obstacle and TL bbox loggers do not overwrite b…
ICGog Jul 9, 2021
efa9333
removed pygame depedencies from operator_creator.py
storm-light Jul 14, 2021
88dc197
minor comment syntax fix
storm-light Jul 19, 2021
7227e58
minor comment syntax fix
storm-light Jul 19, 2021
ba82d01
changed import statements to include full path
storm-light Jul 19, 2021
051f1a8
added docstrings to ROSCameraPublisher and ROSLIDARPublisher classes …
storm-light Jul 19, 2021
2ad7843
resolved import merge conflict
storm-light Jul 19, 2021
ba218ef
minor comment changes
storm-light Jul 19, 2021
fdba024
Added QDTrack object tracker (#183)
mageofboy Jul 19, 2021
a24ed70
yapf'd deez files
storm-light Jul 19, 2021
13b6356
added ROSCameraPublisher.py and visualizer operator can publish camer…
storm-light Jun 15, 2021
204d60c
minimal name changes
storm-light Jun 15, 2021
5f77390
fixed variable typo
storm-light Jun 15, 2021
0b50b99
visualizer operator can now publish ROS PointCloud2 messages (display…
storm-light Jun 17, 2021
10288a5
fixed mirror image for lidar
storm-light Jun 17, 2021
c3d0913
visualizer operator can visualize segmentation frames and depth frame…
storm-light Jun 23, 2021
630b943
visualizes planning world
storm-light Jun 24, 2021
b3b0aab
streams can be displayed simultaneously (in foxglove), still has pyga…
storm-light Jul 3, 2021
389092b
removed all dependencies on pygame in visualizer_operator, though sti…
storm-light Jul 4, 2021
85cdf73
removed run_visualizer_control_loop
storm-light Jul 6, 2021
7702c64
removed visualize() methods from camera_frame.py, depth_frame.py, poi…
storm-light Jul 6, 2021
0fd5ad4
renamed ROSCameraPublisher.py to ros_camera_publisher.py and ROSLIDAR…
storm-light Jul 6, 2021
56590a5
added updated dockerfile (WIP) to install foxglove and ROS
storm-light Jul 6, 2021
2206c71
removed pygame depedencies from operator_creator.py
storm-light Jul 14, 2021
8101483
added docstrings to ROSCameraPublisher and ROSLIDARPublisher classes …
storm-light Jul 19, 2021
4b5cab5
minor comment syntax fix
storm-light Jul 19, 2021
af7fac5
minor comment syntax fix
storm-light Jul 19, 2021
08f945e
changed import statements to include full path
storm-light Jul 19, 2021
9aebae6
minor comment changes
storm-light Jul 19, 2021
2074851
yapf'd deez files
storm-light Jul 19, 2021
9d50b79
Merge remote-tracking branch 'origin/pylot-ros' into pylot-ros
storm-light Jul 20, 2021
053cdab
removed extra import statements
storm-light Jul 20, 2021
72ecd9a
runs roscore from visualizer operator's init() and kills process in d…
storm-light Jul 22, 2021
45436d7
updated Dockerfile to correctly install foxglove and ros
storm-light Jul 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.log
*.csv
*.ipynb
*.dot
dependencies/
pylot/prediction/prediction/

Expand Down
8 changes: 4 additions & 4 deletions data_gatherer.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def main(argv):
traffic_light_depth_camera_stream,
traffic_light_segmented_camera_stream,
pose_stream)
pylot.operator_creator.add_bounding_box_logging(traffic_lights_stream)
pylot.operator_creator.add_bounding_box_logging(
traffic_lights_stream, 'tl-bboxes')

if FLAGS.log_left_right_cameras:
(left_camera_stream, right_camera_stream, _,
Expand All @@ -186,7 +187,8 @@ def main(argv):
depth_camera_stream, center_camera_stream, segmented_stream,
pose_stream, ground_obstacles_stream,
ground_speed_limit_signs_stream, ground_stop_signs_stream)
pylot.operator_creator.add_bounding_box_logging(obstacles_stream)
pylot.operator_creator.add_bounding_box_logging(
obstacles_stream, 'bboxes')

if FLAGS.log_multiple_object_tracker:
pylot.operator_creator.add_multiple_object_tracker_logging(
Expand Down Expand Up @@ -300,8 +302,6 @@ def main(argv):
stream.send(erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))

try:
if pylot.flags.must_visualize():
pylot.utils.run_visualizer_control_loop(control_display_stream)
node_handle.wait()
except KeyboardInterrupt:
node_handle.shutdown()
Expand Down
32 changes: 32 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,35 @@ RUN echo "if [ -f ~/.bashrc ]; then . ~/.bashrc ; fi" >> ~/.bash_profile
# Set up ssh access to the container.
RUN cd ~/ && ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa <<<y 2>&1 >/dev/null
RUN sudo sed -i 's/#X11UseLocalhost yes/X11UseLocalhost no/g' /etc/ssh/sshd_config

# WIP (for visualization in Foxglove)

# Set up for Foxglove
RUN sudo apt-get -y install wget

# Install Foxglove Studio
RUN cd /tmp
RUN wget https://github.com/foxglove/studio/releases/download/v0.12.0/foxglove-studio-0.12.0-linux-amd64.deb
RUN sudo apt install -y ./foxglove-studio-*.deb
RUN rm ./foxglove-studio-*.deb

# Set up for ROS
RUN sudo apt -y update
RUN sudo apt install -y lsb-release
RUN sudo apt install -y curl

# Download ROS
# From, http://wiki.ros.org/melodic/Installation/Ubuntu:
# Setup your computer to accept software from packages.ros.org:
RUN sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
# Set up your keys
# RUN sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
RUN curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
# Make sure your Debian package index is up-to-date
RUN sudo apt -y update
# Desktop-Full Install
RUN sudo apt -y install ros-melodic-desktop-full
# Set up ROS environment variables
RUN echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
RUN source ~/.bashrc

14 changes: 14 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ mkdir -p tracking/center_track ; cd tracking/center_track
# COCO model
~/.local/bin/gdown https://drive.google.com/uc?id=1tJCEJmdtYIh8VuN8CClGNws3YO7QGd40

###### Download QDTrack models ######
cd $PYLOT_HOME/dependencies/models
mkdir -p tracking/qd_track ; cd tracking/qd_track
~/.local/bin/gdown https://drive.google.com/uc?id=1YNAQgd8rMqqEG-fRj3VWlO4G5kdwJbxz

##### Download AnyNet depth estimation models #####
echo "[x] Downloading the depth estimation models..."
cd $PYLOT_HOME/dependencies/models
Expand Down Expand Up @@ -140,6 +145,15 @@ sudo apt-get install llvm-9
export LLVM_CONFIG=/usr/bin/llvm-config-9
python3 setup.py build develop --user

###### Install QDTrack ######
cd $PYLOT_HOME/dependencies/
git clone https://github.com/mageofboy/qdtrack.git
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
python3 setup.py develop #need to add mmcv
cd $PYLOT_HOME/dependencies/qdtrack
python3 setup.py develop

##### Download the Lanenet code #####
echo "[x] Cloning the lanenet lane detection code..."
cd $PYLOT_HOME/dependencies/
Expand Down
4 changes: 1 addition & 3 deletions pylot.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def driver():
prediction_stream, waypoints_stream, control_stream)
streams_to_send_top_on += ingest_streams

node_handle = erdos.run_async()
node_handle = erdos.run_async('pylot.dot')

for stream in streams_to_send_top_on:
stream.send(erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
Expand Down Expand Up @@ -260,8 +260,6 @@ def main(args):
client.start_recorder(FLAGS.simulation_recording_file)
node_handle, control_display_stream = driver()
signal.signal(signal.SIGINT, shutdown)
if pylot.flags.must_visualize():
pylot.utils.run_visualizer_control_loop(control_display_stream)
node_handle.wait()
except KeyboardInterrupt:
shutdown_pylot(node_handle, client, world)
Expand Down
5 changes: 5 additions & 0 deletions pylot/component_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ def add_obstacle_tracking(center_camera_stream,
obstacles_wo_history_tracking_stream = \
pylot.operator_creator.add_center_track_tracking(
center_camera_stream, center_camera_setup)
elif FLAGS.tracker_type == 'qd_track':
logger.debug('Using QDTrack obstacle tracker...')
obstacles_wo_history_tracking_stream = \
pylot.operator_creator.add_qd_track_tracking(
center_camera_stream, center_camera_setup)
else:
logger.debug('Using obstacle tracker...')
obstacles_wo_history_tracking_stream = \
Expand Down
34 changes: 34 additions & 0 deletions pylot/debug/ros_camera_publisher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys
import rospy
import numpy as np
from sensor_msgs.msg import Image


class ROSCameraPublisher:
"""Class that stores a ROS publisher node that publishes ROS Image messages

Args:
topic: the name of the topic published to

storm-light marked this conversation as resolved.
Show resolved Hide resolved
Attributes:
image_pub: ROS publisher node
"""
def __init__(self, topic: str):
self.image_pub = rospy.Publisher(topic, Image, queue_size=10)

def publish(self, img_arr):
"""Publishes a sensor_msgs/Image message (constructed from input)

Args:
img_arr: A numpy array storing a frame (e.g. camera, depth, etc.)
"""
img_msg = Image(encoding='rgb8')
if type(img_arr[0][0][0]) != np.int8:
img_arr = img_arr.astype(np.int8)
img_msg.height, img_msg.width, channels = img_arr.shape
img_msg.data = img_arr.tobytes()
img_msg.step = img_msg.width * img_msg.height
img_msg.is_bigendian = (img_arr.dtype.byteorder == '>'
or img_arr.dtype.byteorder == '='
and sys.byteorder == 'big')
self.image_pub.publish(img_msg)
45 changes: 45 additions & 0 deletions pylot/debug/ros_lidar_publisher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import sys
import rospy
import numpy as np
from sensor_msgs.msg import PointCloud2, PointField


class ROSLIDARPublisher:
storm-light marked this conversation as resolved.
Show resolved Hide resolved
"""Class that stores a ROS publisher node that publishes ROS Point Cloud messages

Args:
topic: the name of the topic published to

Attributes:
point_cloud_pub: ROS publisher node
"""
def __init__(self, topic: str):
self.point_cloud_pub = rospy.Publisher(topic,
PointCloud2,
queue_size=10)

def publish(self, points):
"""Publishes a sensor_msgs/PointCloud2 message (constructed from input)

Args:
points: A numpy array storing a point cloud (see pylot.pylot.perception.point_cloud)
"""

points = points.astype(np.float32)
points_byte_array = points.tobytes()
row_step = len(points_byte_array)
point_step = len(points[0].tobytes())
fields = [
PointField('x', 0, PointField.FLOAT32, 1),
PointField('y', 4, PointField.FLOAT32, 1),
PointField('z', 8, PointField.FLOAT32, 1)
]
point_cloud_msg = PointCloud2(height=1,
width=len(points),
is_dense=True,
is_bigendian=False,
fields=fields,
point_step=point_step,
row_step=row_step,
data=points_byte_array)
self.point_cloud_pub.publish(point_cloud_msg)
Loading