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

Hardware H265 streaming #651

Merged
merged 90 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
bf56489
read messages from base station
rbridges12 Jul 12, 2023
1a68846
sending RTCMs over ros
rbridges12 Jul 13, 2023
8da0845
launch file with both GPSs, RTCMs successfully transmitted
rbridges12 Jul 13, 2023
a251f1c
port change
rbridges12 Jul 14, 2023
deb3724
output screen
rbridges12 Jul 30, 2023
315c03c
Merge branch 'master' into rtk
nehakankanala Oct 22, 2023
68f9730
added gps driver for rover gps and merged master into rtk
nehakankanala Oct 22, 2023
de9c114
edited rtk launch and esw.yaml
nehakankanala Oct 26, 2023
21f27c9
used pyubx reader instead of serial getline()
nehakankanala Oct 26, 2023
118ada5
added preliminary dual gnss file
pearlastrid Oct 27, 2023
e7be851
add notes
dllliu Oct 27, 2023
6087729
graph vectors for heading calculations
dllliu Oct 29, 2023
9602c61
calc heading and bearing
dllliu Oct 31, 2023
9ca084b
driver testing; not fully working :alien:
rahdal Oct 31, 2023
285d1b6
plots for heading calculations
dllliu Oct 31, 2023
4b84aed
added get_heading_vector function
pearlastrid Nov 2, 2023
325792d
add tests for vector heading method
dllliu Nov 3, 2023
42533ba
working as intended furing testing
rahdal Nov 9, 2023
280ef72
add tests to determine optimal amt of sig figs for gps coordinates
dllliu Nov 10, 2023
0803e8b
added more message parsing
rahdal Nov 12, 2023
ec73cc1
started adding gps to gazebo
pearlastrid Nov 14, 2023
89b8f75
finished adding new gps and links
pearlastrid Nov 14, 2023
b927d78
edited links
pearlastrid Nov 14, 2023
a271f7f
added links
pearlastrid Nov 15, 2023
a2b3a7b
try to debug plugins and make test subscriber file
dllliu Nov 17, 2023
9965be8
added left and right gps using groups
rahdal Nov 26, 2023
77c8f2b
gps creation and subscribers
dllliu Nov 28, 2023
1348cd6
add tests for moving gps and subscribed
dllliu Nov 29, 2023
1fa6b18
started editing gps linearization
rahdal Nov 30, 2023
819952f
gps now put in sim
pearlastrid Nov 30, 2023
473c1dd
edited test subscriber
pearlastrid Dec 1, 2023
fdc6561
Merge branch 'dualGnss' into rtk
rahdal Dec 1, 2023
5aa6dac
added pose calculation using heading
rahdal Dec 1, 2023
db998ea
tests for both gps distance
dllliu Dec 3, 2023
670261f
changes for testing with convert lat long to cartesian to see offset …
dllliu Dec 3, 2023
29e0748
tests for offset
dllliu Dec 6, 2023
090866c
offset is 10?
dllliu Dec 6, 2023
069a2cf
chanegd offset to 1 and modified testing code
nehakankanala Dec 7, 2023
10d328d
Add requirements
umroverPerception Dec 10, 2023
2659e84
updated linearlization
rahdal Jan 14, 2024
820ef7e
merged
rahdal Jan 14, 2024
a3eb9e7
debug linearization function and try to debug sim
dllliu Jan 17, 2024
6ac7f8d
fixed reference points and removed z component for better rviz experi…
rbridges12 Jan 19, 2024
46e4f77
made a temporary GPS sim
rbridges12 Jan 19, 2024
e7e62ca
fixed pose publishing offset temporarily
rbridges12 Jan 19, 2024
b7c97f8
Add starter work for gps
qhdwight Jan 20, 2024
aee2d8c
cartesian to geodetic conversion
rbridges12 Jan 20, 2024
12a9710
Finish off gps and add imu
qhdwight Jan 20, 2024
ba650e1
Merge remote-tracking branch 'origin/sim-gps-imu' into rtk
qhdwight Jan 20, 2024
ad25d42
Yo workingin the new sim
qhdwight Jan 20, 2024
39ec2cd
Submodule update for dawn
qhdwight Jan 20, 2024
594cffc
added rviz to launch file, misc cleanup
rbridges12 Jan 21, 2024
3f713e4
Merge branch 'rtk' of github.com:umrover/mrover-ros into rtk
rbridges12 Jan 21, 2024
9aabf03
refactored utils and tag detector, crashes when it sees a tag
rbridges12 Jan 21, 2024
95e0198
debugging
rbridges12 Feb 1, 2024
2082583
Init
qhdwight Feb 5, 2024
190ee1b
Work on encoders
qhdwight Feb 5, 2024
96d0ec4
Update
qhdwight Feb 5, 2024
2b03b97
Breh
qhdwight Feb 5, 2024
b377bf8
Use bgra instead of i420
qhdwight Feb 5, 2024
e971c58
partially fixed script
rbridges12 Feb 13, 2024
257b684
fixed macos std::for_each error
nehakankanala Feb 13, 2024
686d2e8
more factoring test
rbridges12 Feb 15, 2024
39ef5d2
refactored SE3 util functions back into lie library
rbridges12 Feb 15, 2024
77d3d15
refactored most of sim
rbridges12 Feb 15, 2024
8f540a6
more debugging
rbridges12 Feb 15, 2024
15065f2
Add manif as submodule, find out some disgustig things about transfor…
qhdwight Feb 15, 2024
dd19c55
refactored camera controls using tangent elements
rbridges12 Feb 15, 2024
77a03e5
merged in integration
rbridges12 Feb 15, 2024
3dd06d3
pr cleanup
rbridges12 Feb 16, 2024
a282a9e
more cleanup
rbridges12 Feb 16, 2024
ff5d48a
more cleanup
rbridges12 Feb 16, 2024
dab754f
Remove unrelated stuff, clean up some stuff, remove old lie stuff
qhdwight Feb 16, 2024
3fc5014
Rename to lie.hpp
qhdwight Feb 16, 2024
f65068c
Refactor look controls
qhdwight Feb 16, 2024
a45e9b9
Comments
qhdwight Feb 16, 2024
831c73a
Manif refactor (#648)
rbridges12 Feb 16, 2024
fb09d58
Fix collider rendering with new se3
qhdwight Feb 16, 2024
8ef4b5d
slight refactoring of simulated sensors, added untested noise
rbridges12 Feb 16, 2024
b912045
merged integration
rbridges12 Feb 16, 2024
b22ec36
changed some type names, added rviz to launch file, separate roll pit…
rbridges12 Feb 17, 2024
d172136
fixed type names and ctors
rbridges12 Feb 17, 2024
27eaa1c
slightly reduced noise and moved waypoint
rbridges12 Feb 17, 2024
96db7cc
Merge remote-tracking branch 'origin/integration' into cameras
qhdwight Feb 18, 2024
91cd8ed
Restream
qhdwight Feb 18, 2024
0345877
Merge remote-tracking branch 'origin/baja' into cameras
qhdwight Feb 18, 2024
e8c397b
Update
qhdwight Feb 18, 2024
e8f68f6
Fix format
qhdwight Feb 18, 2024
8ded248
Stream that can be reused
qhdwight Feb 18, 2024
7f80ce8
Naming
qhdwight Feb 18, 2024
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
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@
url = https://dawn.googlesource.com/dawn
shallow = true
branch = chromium/6108
[submodule "deps/emsdk"]
path = deps/emsdk
url = [email protected]:emscripten-core/emsdk.git
shallow = true
branch = 3.1.53
[submodule "deps/manif"]
path = deps/manif
url = https://github.com/artivis/manif.git
shallow = true
26 changes: 16 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,15 @@ if (MROVER_BUILD_SIM)
if (NOT Assimp_FOUND AND NOT assimp_FOUND)
message(FATAL_ERROR "Assimp not found")
endif ()

find_package(Bullet REQUIRED)

find_package(glfw3 REQUIRED)

include(cmake/webgpu.cmake)

add_subdirectory(deps/glfw3webgpu)
add_subdirectory(deps/glfw3webgpu SYSTEM)
endif ()
find_package(OpenCV REQUIRED)
find_package(ZED QUIET)
find_package(Eigen3 REQUIRED)
add_subdirectory(deps/manif SYSTEM)
find_package(PkgConfig REQUIRED)
pkg_search_module(NetLink libnl-3.0)
pkg_search_module(NetLinkRoute libnl-route-3.0)
Expand Down Expand Up @@ -147,6 +144,7 @@ catkin_package()
## Libraries

mrover_add_library(lie src/util/lie/*.cpp src/util/lie)
target_link_libraries(lie PUBLIC manif)

## ESW

Expand Down Expand Up @@ -188,6 +186,9 @@ endif ()

## Perception

mrover_add_library(streaming src/esw/streaming/*.cpp src/esw/streaming)
target_compile_definitions(streaming PUBLIC BOOST_ASIO_NO_DEPRECATED)

mrover_add_nodelet(zed_tag_detector src/perception/tag_detector/zed/*.cpp src/perception/tag_detector/zed src/perception/tag_detector/zed/pch.hpp)
mrover_nodelet_link_libraries(zed_tag_detector opencv_core opencv_objdetect opencv_aruco opencv_imgproc tbb lie)

Expand All @@ -197,13 +198,18 @@ mrover_nodelet_link_libraries(long_range_tag_detector opencv_core opencv_objdete
mrover_add_nodelet(usb_camera src/perception/long_range_cam/*.cpp src/perception/long_range_cam src/perception/long_range_cam/pch.hpp)
mrover_nodelet_link_libraries(usb_camera opencv_core opencv_objdetect opencv_aruco opencv_imgproc opencv_highgui tbb lie)
if (CUDA_FOUND)
mrover_add_library(streaming src/esw/streaming/*.c* src/esw/streaming)
# target_link_libraries(streaming PUBLIC opencv_core opencv_cudacodec)
target_link_libraries(streaming PUBLIC cuda nvidia-encode opencv_core)
target_include_directories(streaming SYSTEM PUBLIC deps/nvenc)
target_compile_definitions(streaming PUBLIC BOOST_ASIO_NO_DEPRECATED)
mrover_add_node(hardware_h265_encoder src/esw/hardware_h265_encoder/*.c*)
target_link_libraries(hardware_h265_encoder PUBLIC cuda nvidia-encode opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio streaming)
target_include_directories(hardware_h265_encoder SYSTEM PUBLIC deps/nvenc)
endif ()

add_subdirectory(deps/libde265)
include_directories(deps/libde265/extra deps/libde265 SYSTEM)

mrover_add_node(software_h265_encoder src/esw/software_h265_encoder/*.c*)
target_link_libraries(software_h265_encoder PUBLIC opencv_core opencv_imgproc opencv_imgcodecs de265 streaming)
target_include_directories(software_h265_encoder SYSTEM PUBLIC deps/nvenc)

if (ZED_FOUND)
mrover_add_nodelet(object_detector src/perception/object_detector/*.c* src/perception/object_detector src/perception/object_detector/pch.hpp)
mrover_nodelet_link_libraries(object_detector PRIVATE opencv_core opencv_dnn opencv_imgproc lie nvinfer nvonnxparser tbb)
Expand Down
2 changes: 1 addition & 1 deletion config/simulator/simulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ objects:
- type: urdf
name: tag_0
uri: package://mrover/urdf/world/tag_0.urdf.xacro
translation: [ -3, -3, 0.7 ]
translation: [ -2, -2, 0.7 ]
- type: urdf
name: tag_1
uri: package://mrover/urdf/world/tag_1.urdf.xacro
Expand Down
1 change: 1 addition & 0 deletions deps/emsdk
Submodule emsdk added at 2aa749
1 change: 1 addition & 0 deletions deps/manif
Submodule manif added at c8a9fc
6 changes: 6 additions & 0 deletions launch/simulator.launch
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<launch>
<arg name="run_rviz" default="true" />
<rosparam command="load" file="$(find mrover)/config/simulator/simulator.yaml" />

<include file="$(find mrover)/launch/autonomy.launch">
Expand All @@ -13,4 +14,9 @@
args="load mrover/SimulatorNodelet perception_nodelet_manager" output="screen" />

<node name="arm_controller" pkg="mrover" type="arm_controller" output="screen" />

<group if="$(arg run_rviz)">
<arg name="rvizconfig" default="$(find mrover)/config/rviz/auton_sim.rviz" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" />
</group>
</launch>
5 changes: 5 additions & 0 deletions scripts/build_teleop_stream_client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source deps/emsdk/emsdk_env.sh
emcmake cmake -B src/teleoperation/streaming/embuild -G Ninja -DCMAKE_BUILD_TYPE=Release src/teleoperation/streaming/
cmake --build src/teleoperation/streaming/embuild
14 changes: 11 additions & 3 deletions scripts/toggle_basestation_networking
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# !/usr/bin/env bash
# !/usr/bin/env zsh

# Script to add or remove ROS basestation networking script from bashrc
# TODO: make this work for bash and other catkin workspace locations

if grep -q "source ~/catkin_ws/src/mrover/ansible/roles/basestation_networks/files/networking_setup_basestation.sh" ~/.zshrc; then
CATKIN_WORKSPACE_PATH=~/catkin_ws
network_script_path="${CATKIN_WORKSPACE_PATH}/src/mrover/ansible/roles/basestation_networks/files/networking_setup_basestation"
enable_message="Basestation network setup enabled, disable with scripts/toggle_basestation_networking"

if grep -q "source ${network_script_path}" ~/.zshrc; then
echo "Removing basestation networking script from .zshrc"
sed -i '/source ~\/catkin_ws\/src\/mrover\/ansible\/roles\/basestation_networks\/files\/networking_setup_basestation.sh/d' ~/.zshrc
else
echo "Adding basestation networking script to .zshrc"
echo "source ~/catkin_ws/src/mrover/ansible/roles/basestation_networks/files/networking_setup_basestation.sh" >> ~/.zshrc
if [[ $(tail -c1 ~/.zshrc | wc -l) -eq 0 ]]; then
echo "\n" >> ~/.zshrc
fi
echo "echo '${enable_message}'" >> ~/.zshrc
echo "source ${network_script_path}" >> ~/.zshrc
fi
99 changes: 0 additions & 99 deletions src/esw/cameras/cameras.cpp

This file was deleted.

84 changes: 84 additions & 0 deletions src/esw/hardware_h265_encoder/hardware_h265_encoder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include "hardware_h265_encoder.hpp"

#include <ros/init.h>
#include <ros/node_handle.h>
#include <ros/subscriber.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/image_encodings.h>

#include <streaming.hpp>

#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>

std::optional<StreamServer> streamServer;

std::optional<Encoder> encoder;

auto imageCallback(sensor_msgs::ImageConstPtr const& msg) -> void {
try {
if (msg->encoding != sensor_msgs::image_encodings::BGR8) throw std::runtime_error{"Unsupported encoding"};

cv::Size size{static_cast<int>(msg->width), static_cast<int>(msg->height)};

if (!encoder) encoder.emplace(size);

cv::Mat bgrFrame{size, CV_8UC3, const_cast<std::uint8_t*>(msg->data.data()), msg->step};
cv::Mat bgraFrame;
cv::cvtColor(bgrFrame, bgraFrame, cv::COLOR_BGR2BGRA);

bool feedSuccessful = false;
{
Encoder::BitstreamView view = encoder->feed(bgraFrame);
std::span span{static_cast<std::byte*>(view.lockParams.bitstreamBufferPtr), view.lockParams.bitstreamSizeInBytes};
feedSuccessful = streamServer->feed(span);
}
if (!feedSuccessful) encoder.reset();

} catch (std::exception const& e) {
ROS_ERROR_STREAM(std::format("Exception encoding frame: {}", e.what()));
ros::requestShutdown();
}
}

// auto capture() -> void {
// cv::VideoCapture cap{std::format("v4l2src ! videoconvert ! video/x-raw,width={},height={},format=I420,framerate=30/1 ! appsink", 640, 480), cv::CAP_GSTREAMER};
// if (!cap.isOpened()) throw std::runtime_error{"Failed to open capture"};
//
// while (cap.isOpened()) {
// cv::Mat i420Frame;
// if (!cap.read(i420Frame)) throw std::runtime_error{"Failed to read frame"};
//
// cv::Mat bgraFrame;
// cvtColor(i420Frame, bgraFrame, cv::COLOR_YUV2BGRA_I420);
//
// Encoder::BitstreamView view = encoder->feed(bgraFrame);
// std::span span{static_cast<std::byte*>(view.lockParams.bitstreamBufferPtr), view.lockParams.bitstreamSizeInBytes};
// streamServer->feed(span);
//
// ros::spinOnce();
// }
// }

auto main(int argc, char** argv) -> int {
try {
ros::init(argc, argv, "software_h265_encoder");
ros::NodeHandle nh, pnh{"~"};

std::string imageTopic = pnh.param("image_topic", std::string{"/camera/left/image"});

streamServer.emplace("0.0.0.0", 8080);

ros::Subscriber imageSubscriber = nh.subscribe(imageTopic, 1, imageCallback);

// capture();

ros::spin();
return EXIT_SUCCESS;

} catch (std::exception const& e) {
ROS_ERROR_STREAM(std::format("Exception initializing: {}", e.what()));
return EXIT_FAILURE;
}
}
Loading