Skip to content
Snippets Groups Projects
Commit 028398a6 authored by Alcolado Nuthall's avatar Alcolado Nuthall
Browse files

tidy: clean unneeded files

parent 12a93911
No related branches found
No related tags found
No related merge requests found
......@@ -7,8 +7,9 @@ Panels:
- /Global Options1
- /Status1
- /Image1
- /PointCloud21
Splitter Ratio: 0.5
Tree Height: 94
Tree Height: 196
- Class: rviz_common/Selection
Name: Selection
- Class: rviz_common/Tool Properties
......@@ -76,6 +77,40 @@ Visualization Manager:
Reliability Policy: Reliable
Value: /camera/rgb
Value: true
- Alpha: 1
Autocompute Intensity Bounds: true
Autocompute Value Bounds:
Max Value: 10
Min Value: -10
Value: true
Axis: Z
Channel Name: intensity
Class: rviz_default_plugins/PointCloud2
Color: 255; 255; 255
Color Transformer: ""
Decay Time: 0
Enabled: true
Invert Rainbow: false
Max Color: 255; 255; 255
Max Intensity: 4096
Min Color: 0; 0; 0
Min Intensity: 0
Name: PointCloud2
Position Transformer: ""
Selectable: true
Size (Pixels): 3
Size (m): 0.009999999776482582
Style: Flat Squares
Topic:
Depth: 5
Durability Policy: Volatile
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: /pcd
Use Fixed Frame: true
Use rainbow: true
Value: true
Enabled: true
Global Options:
Background Color: 48; 48; 48
......@@ -145,12 +180,12 @@ Visualization Manager:
Window Geometry:
Displays:
collapsed: false
Height: 846
Height: 1145
Hide Left Dock: false
Hide Right Dock: false
Image:
collapsed: false
QMainWindow State: 000000ff00000000fd000000040000000000000156000002b4fc020000000afb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003b000000e7000000c700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000a0049006d0061006700650100000128000000dd0000002800fffffffb0000000a0049006d006100670065010000020b000000e40000002800ffffff000000010000010f000002b4fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003b000002b4000000a000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004b00000003efc0100000002fb0000000800540069006d00650100000000000004b00000025300fffffffb0000000800540069006d006501000000000000045000000000000000000000023f000002b400000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
QMainWindow State: 000000ff00000000fd000000040000000000000156000003dffc020000000afb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003b0000014d000000c700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000a0049006d006100670065010000018e0000013e0000002800fffffffb0000000a0049006d00610067006501000002d2000001480000002800ffffff000000010000010f000003dffc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003b000003df000000a000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e100000197000000030000073d0000003efc0100000002fb0000000800540069006d006501000000000000073d0000025300fffffffb0000000800540069006d00650100000000000004500000000000000000000004cc000003df00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection:
collapsed: false
Time:
......@@ -159,6 +194,6 @@ Window Geometry:
collapsed: false
Views:
collapsed: false
Width: 1200
Width: 1853
X: 67
Y: 60
Y: 27
......@@ -8,22 +8,22 @@
"aspect": 1.33333333333,
"camera_to_world": [
[
-0.7794105921481128,
0.2580277804141302,
-0.5709122466560741,
-0.15150902339942507
-0.5864376195618306,
0.29104753718687776,
-0.7558983062953022,
-0.2832813335422174
],
[
-0.6246540202209707,
-0.2498903335022854,
0.7398392908219299,
0.170480890757302
-0.8096524572344355,
-0.18351676230420205,
0.5574804897461648,
-0.16196170949416663
],
[
0.04823363835652139,
0.9332612098210632,
0.3559452631714859,
-0.10236216822295188
0.023533313767811814,
0.9389424524702438,
0.3432684868907569,
-0.09978051483234415
],
[
0.0,
......
......@@ -8,22 +8,22 @@
"aspect": 1.33333333333,
"camera_to_world": [
[
-0.7794105921481128,
0.2580277804141302,
-0.5709122466560741,
-0.15150902339942507
-0.5864376195618306,
0.29104753718687776,
-0.7558983062953022,
-0.2832813335422174
],
[
-0.6246540202209707,
-0.2498903335022854,
0.7398392908219299,
0.170480890757302
-0.8096524572344355,
-0.18351676230420205,
0.5574804897461648,
-0.16196170949416663
],
[
0.04823363835652139,
0.9332612098210632,
0.3559452631714859,
-0.10236216822295188
0.023533313767811814,
0.9389424524702438,
0.3432684868907569,
-0.09978051483234415
],
[
0.0,
......
......@@ -4,7 +4,6 @@ import mediapy as media
import numpy as np
import torch
# Typing
from pathlib import Path
from typing import Any, Dict, List, Literal, Optional, Union
......@@ -79,14 +78,7 @@ def _render_trajectory_video(
render_image = np.concatenate(render_image, axis=1)
if output_format == "images":
return render_image
"""
if image_format == "png":
media.write_image(output_image_dir / f"{camera_idx:05d}.png", render_image, fmt="png")
if image_format == "jpeg":
media.write_image(
output_image_dir / f"{camera_idx:05d}.jpg", render_image, fmt="jpeg", quality=jpeg_quality
)"""
class RenderCameraPath():
image_format: Literal["jpeg", "png"] = "jpeg"
jpeg_quality: int = 100
......@@ -112,7 +104,7 @@ class RenderCameraPath():
with open(camera_path_filename, "r", encoding="utf-8") as f:
camera_path = json.load(f)
seconds = camera_path["seconds"]
crop_data = None # we're not cropping the image
crop_data = None
camera_path = get_path_from_json(camera_path)
self.rendered_output_names = render_output_names
......
......@@ -19,7 +19,7 @@ class PCDPublisher(Node):
self.pcd_publisher = self.create_publisher(sensor_msgs.PointCloud2, 'pcd', 10)
# subscribe to pose coming in from topic
self.subscription = self.create_subscription(Pose, 'pose', self.listener_callback, 1)
self.subscription = self.create_subscription(Pose, 'pose', self.listener_callback, 10)
self.subscription
self.render = RenderLiDAR()
......
......@@ -17,34 +17,6 @@ from nerfstudio.model_components.ray_samplers import PDFSampler, UniformSampler
from nerfstudio.utils.tensor_dataclass import TensorDataclass
from nerfstudio.cameras.rays import RayBundle, RaySamples, Frustums
def generat_direction():
min, max = -30.67, 10.67 # view range degrees
no_channels = 32
delta_range = (max - min) / no_channels # delta degrees
elevations = [math.radians(i) for i in np.arange(min, max, delta_range)]
azimuths = [math.radians(i) for i in np.arange(0, 360, 1)]
rays = []
for elevation in elevations:
for azimuth in azimuths:
rays.append(torch.tensor([
math.cos(elevation) * math.sin(azimuth),
math.cos(elevation) * math.cos(azimuth),
math.sin(elevation)
], device='cuda:0'))
return torch.stack(rays)
def generate_pointcloud(ray_bundle, outputs):
rgbs = outputs['rgb']
points = ray_bundle.origins + ray_bundle.directions * outputs['depth']
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points.double().cpu().numpy())
pcd.colors = o3d.utility.Vector3dVector(rgbs.detach().double().cpu().numpy())
return pcd
class RenderLiDAR():
eval_num_rays_per_chunk: Optional[int] = None
......@@ -55,12 +27,40 @@ class RenderLiDAR():
eval_num_rays_per_chunk=self.eval_num_rays_per_chunk,
test_mode="inference",
)
def generate_pointcloud(self,ray_bundle, outputs):
rgbs = outputs['rgb']
points = ray_bundle.origins + ray_bundle.directions * outputs['depth']
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points.double().cpu().numpy())
pcd.colors = o3d.utility.Vector3dVector(rgbs.detach().double().cpu().numpy())
return pcd
def generate_direction(self):
min, max = -30.67, 10.67 # view range degrees
no_channels = 32
delta_range = (max - min) / no_channels # delta degrees
elevations = [math.radians(i) for i in np.arange(min, max, delta_range)]
azimuths = [math.radians(i) for i in np.arange(0, 360, 1)]
rays = []
for elevation in elevations:
for azimuth in azimuths:
rays.append(torch.tensor([
math.cos(elevation) * math.sin(azimuth),
math.cos(elevation) * math.cos(azimuth),
math.sin(elevation)
], device='cuda:0'))
return torch.stack(rays)
def run(self, origin):
cuda0 = torch.device('cuda:0')
directions = generat_direction()
#TODO: change origin depending on pose coming in
directions = self.generate_direction()
origin = torch.tensor(origin, device=cuda0)
x,y = directions.shape
......@@ -74,7 +74,7 @@ class RenderLiDAR():
ray_bundle = RayBundle(origins, directions, pixel_area, camera_indices=camera_indices, nears=None, fars=None)
outputs = self.pipeline.model(ray_bundle)
pcd = generate_pointcloud(ray_bundle, outputs)
pcd = self.generate_pointcloud(ray_bundle, outputs)
torch.cuda.empty_cache()
tpcd = o3d.t.geometry.PointCloud.from_legacy(pcd)
......
......@@ -18,7 +18,7 @@ import mediapy as media
# run nerf to get image
# publish image to topic
class MinimalPublisher(Node):
class DepthGenerator(Node):
def __init__(self):
super().__init__('minimal_publisher')
# subscribe to pose coming in from topic
......@@ -92,7 +92,7 @@ class MinimalPublisher(Node):
def main(args=None):
rclpy.init(args=args)
minimal_publisher = MinimalPublisher()
minimal_publisher = DepthGenerator()
rclpy.spin(minimal_publisher)
......
......@@ -18,7 +18,7 @@ import mediapy as media
# run nerf to get image
# publish image to topic
class MinimalPublisher(Node):
class RGBGenerator(Node):
def __init__(self):
super().__init__('minimal_publisher')
# subscribe to pose coming in from topic
......@@ -92,7 +92,7 @@ class MinimalPublisher(Node):
def main(args=None):
rclpy.init(args=args)
minimal_publisher = MinimalPublisher()
minimal_publisher = RGBGenerator()
rclpy.spin(minimal_publisher)
......
import rclpy
from rclpy.node import Node
from cv_bridge import CvBridge
from sensor_msgs.msg import Image
import cv2
import numpy as np
# simple example of publishing an image of a single frame saved in a file
class MinimalPublisher(Node):
def __init__(self):
super().__init__('minimal_publisher')
self.publisher_ = self.create_publisher(Image, 'simple_camera', 10)
timer_period = 0.5 # seconds
self.timer = self.create_timer(timer_period, self.timer_callback)
self.i = 0
self.cv_image1 = cv2.imread('/workspace/ros2_iron/src/nerf_sim/test_materials/00000.jpg')
self.bridge = CvBridge()
self.get_logger().info('Test')
def timer_callback(self):
msg = Image()
msg = self.bridge.cv2_to_imgmsg(np.array(self.cv_image1))
self.publisher_.publish(msg)
self.get_logger().info('Publishing: Image' % msg.data)
self.i += 1
def main(args=None):
rclpy.init(args=args)
minimal_publisher = MinimalPublisher()
rclpy.spin(minimal_publisher)
# Destroy the node explicitly
# (optional - otherwise it will be done automatically
# when the garbage collector destroys the node object)
minimal_publisher.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
\ No newline at end of file
import rclpy
from rclpy.node import Node
from cv_bridge import CvBridge
from sensor_msgs.msg import Image
import cv2
import numpy as np
import mediapy as media
# simple example of subscribing to an image on a topic
# can also be used for rviz visualization for real use
class MinimalSubscriber(Node):
def __init__(self):
super().__init__('minimal_subscriber')
self.subscription = self.create_subscription(Image, 'topic', self.listener_callback, 10)
self.subscription
self.bridge = CvBridge()
def listener_callback(self, data):
image = self.bridge.imgmsg_to_cv2(data)
print(image.shape)
media.write_image(f"new-test.jpg", image, fmt="jpeg")
#cv2.imwrite('test.jpg', image)
self.get_logger().info('Subscribing: Image')
def main(args=None):
rclpy.init(args=args)
minimal_publisher = MinimalSubscriber()
rclpy.spin(minimal_publisher)
# Destroy the node explicitly
# (optional - otherwise it will be done automatically
# when the garbage collector destroys the node object)
minimal_publisher.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
\ No newline at end of file
......@@ -26,8 +26,6 @@ setup(
entry_points={
'console_scripts': [
'pose_generator = nerf_sim.pose_generator:main',
'image_generator = nerf_sim.simple_image_generator:main',
'image_listener = nerf_sim.simple_image_listener:main',
'sim_rgb_generator = nerf_sim.sim_rgb_generator:main',
'sim_depth_generator = nerf_sim.sim_depth_generator:main',
'pcd_generator = nerf_sim.pcd_publisher_node:main',
......
test_materials/00000.jpg

106 KiB

Source diff could not be displayed: it is too large. Options to address this: view the blob.
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment