diff --git a/docs/camera-research/README.md b/docs/camera-research/README.md new file mode 100644 index 0000000..0e97b8a --- /dev/null +++ b/docs/camera-research/README.md @@ -0,0 +1,38 @@ +# Camera Document Index + +## Initial Research Documents + +These google docs are still editable and may be changed +- [Initial Doctor View Research Document](https://docs.google.com/document/d/1OfJ6v8o2l7Od17A9XfhbKtnIbXPvU-SVXBNiBWnNtfE/edit?tab=t.0#heading=h.opf0zp86jmkf) +- [First Prototype Camera Requirements](https://docs.google.com/document/d/19sTK0wt7DqVyj-hby_aYes9H3HzxA_KSLALwobuXmB0/edit?tab=t.0#heading=h.34oim445jif) +- [Camera's Mechanical Requirements](https://docs.google.com/document/d/15i2DtYXTZA4_sDSY5-uei4Io7vbqmeA7kBANB8NLVCQ/edit?tab=t.0) + +## Current Best Source +The [camera system design](doctor_camera_system_design.md) is so far the most up to date document surrounding the camera, constraints, and everything that mechanical and electrical has told us. + +## Current Recommendation (first testing) + +MVP Camera Setup: A camera that lives above the arm, preferably either in the ceiling or attached to the surgery light above the patient. + +Interface: Within the ground station interface like a plugin/add-on. + +Resolution/Rate Assumptions: 1080p with a frame rate of 30fps. + +Availability: Should be available to switch to and from the camera at all times. + +Integration Effort: The hardest part would be connecting the camera to Ros itself + +Expected ROS Topics: + - /doctor_view/left|right/image_raw - A topic for each of the raw camera feeds (left and/or right depends on stereoscopic camera capabilities) + - /doctor_view/left|right/camera_info - A topic that contains the calibration settings for the left and/or right cameras + - /doctor_view/preview/image_view - A topic that gives the overall view for the operator. + +Latency Target: Should remain below 30 to 50ms. + +Unresolved Hardware Questions: + - Mechanical envelope for the camera. + - Working with electrical to make the camera work with the robot and the ground station. + +Test/Purchase decision: + - I personally would recommend the [Orbbec Gemini 2 Camera](https://d1cd332k3pgc17.cloudfront.net/wp-content/uploads/2023/07/Orbbec-Gemini-2-Series-DatasheetPublicV1.720240316.pdf?_gl=1*ffjzs5*_gcl_au*NzAxNTA3NDEzLjE3ODI1ODg5MzAuODcxNjc2MDcuMTc4MjU4ODk5OC4xNzgyNTg5MDAw) as it is a stereo camera and a good fit for an initial test camera. It works with a lot of the camera requirements specified in the system design md file. + - For now, a webcam would also be suitable for initial, universal testing of the latency monitor and/or doctor view interface. diff --git a/docs/camera-research/cameraTesting.jpeg b/docs/camera-research/cameraTesting.jpeg new file mode 100644 index 0000000..f1c58c9 Binary files /dev/null and b/docs/camera-research/cameraTesting.jpeg differ diff --git a/docs/camera-research/cameraTesting.md b/docs/camera-research/cameraTesting.md new file mode 100644 index 0000000..4678540 --- /dev/null +++ b/docs/camera-research/cameraTesting.md @@ -0,0 +1,39 @@ +# Camera Testing + +> Note: All data was collected with a Logitech Brio 100 Full HD Webcam that shoots in a maximum resolution of 1080p (1280x720) at an expected frame rate of 30fps. + +## Five Minute Experiment Results +### Ran at 1280x720 at and average of 30fps +- Taking a picture of the timer and the doctor view, there is a **0.54s (540ms)** difference in the timer. + - The monitor measures from when the bridge reads a frame from the camera to when the ground station receives it, while the stopwatch also includes the camera and the screen. The stopwatch test only covers visible delays, not internal. +- The minimum camera delay was **0.17ms** +- The maximum camera delay was **1031.21ms** +- The average camera delay was **153.53ms** +- There were 10833 frames captured, and over five minutes (+51.93s for set-up/take-down time), the average frame rate was **30.78fps** +- The average jitter was **16.51 ms for capture jitter** and **57.69 ms for receiving jitter**. + +## Five Minute Experiment Results with Demo +### Ran at 1280x720 at an average of 31.59fps +- Taking a picture of the timer and the doctor view, there is a **0.56s (560ms)** difference in the timer. + - The monitor measures from when the bridge reads a frame from the camera to when the ground station receives it, while the stopwatch also includes the camera and the screen. The stopwatch test only covers visible delays, not internal. +- The minimum camera delay was **0.13ms** +- The maximum camera delay was **1069.63ms** +- The average camera delay was **511.56ms** +- There were 10818 frames captured over 342.48 seconds (5 minutes + time for setup/takedown) and the average frame rate was **31.59fps** +- The average jitter was **16.80 ms for capture jitter** and **54.51 ms for receiving jitter**. + +## Result Discussion +Overall, the results with the demo running in the background was not too different from the one without the demo. + +- The overall average camera delay is significantly higher with the demo running in the background compared to the one without. + - This could be due to the constant movement needing to be captured by the camera, thus creating more delay compared to a stopwatch moving. +- The average jitter for capture and receiving weren't very different in the two experiments. +- The experiment with the demo seemed to capture more frames per second compared to the one without. Although, this difference in frame rate is not by much. + +## Disconnect/Reconnect Behaviour +- Doctor view went black and stopped sending frames. There was a camera warning in the alert section. + - The camera bridge in the terminal showed a message saying "Ground Station disconnected; retrying" +- On reconnect, the camera simply came back to the doctor view and resumed as if nothing happened. + - The camera bridge in the terminal showed a message saying "Connected to ground" + - The latency monitor picks up on negative frames, missing and stale frames and shows it in the alert section. + diff --git a/docs/camera-research/doctor_camera_system_design.md b/docs/camera-research/doctor_camera_system_design.md new file mode 100644 index 0000000..fc98e1f --- /dev/null +++ b/docs/camera-research/doctor_camera_system_design.md @@ -0,0 +1,113 @@ +# Camera System Design (First Prototype Recommendations) +- [Specific Camera Needs](#specific-camera-needs) +- [Electrical Requirements](#electrical-requirements) +- [Mechanical Requirements](#mechanical-requirements) +- [Benchtop Testing](#benchtop-testing) +- [ROS2 Topic Name Proposals](#ros2-topic-name-proposal) +- [Timestamps](#timestamps) +- [Latency](#latency-measurement-method) +- [Long Term Plan](#long-term-targets) +- [Component Shortlist](#component-shortlist) + +## Specific External Camera Needs + +| Specific | Requirements | Why? | +| --- | --- | --- | +| Resolution | 1080p | Minimum resolution needed for surgeries | +| Frame Rate | 30fps | Minimum FPS required for surgeries | +| Shutter | Rolling | The camera model I suggest uses a rolling shutter for the colour version of the camera. | +| Lighting | Dark with a light backing it | A surgery room is usually dark with an overhead light. I am going off of that visual. | +| Internal/Tool-Side View | Not required | Would be nice to have, but for a first prototype might not be as viable | +| External Room View | Required | I think that a birds-eye view for the initial prototype would be a good idea since it doesn't interfere with the mechanical aspects too much in case they don't get back with mechanical requirements | +| Camera Type | Stereo | Gives us a good starting point on working with stereo cameras | +| Camera Model | [Gemini 2 by Orbbec](https://www.orbbec.com/products/stereo-vision-camera/gemini-2/) | A relatively inexpensive stereo USB3.0 camera that will be good for initial benchtop testing. | +| Expected number of cameras | 1 or 2 | We can have a camera directly on the arm and/or one mounted elsewhere | +| Placement | On the robot or overhead | Gives the surgeon a more active view or a more natural view. | + +## Electrical Requirements +> Note: All assumptions are based off of the Gemini2 Camera by Orbbec + +### Camera Requirements +| Subject | Requirement | +| --- | --- | +| Power Input | **5V** via USB-C | +| Power Consumption | Typical Average: **<2.0W**, Max Average: <2.5W, Max Peak Average: <6.5W | +| Cable/Connector | **1 - 1.5m** in length | +| CPU needed | **quad-core, 2.9GHz** | +| RAM needed | **4GB** | + +## Mechanical Requirements + +| Requirement | External | Endoscope | +| --- | --- | --- | +| **Approximate Location** | Around the arm | On the arm, as an extra tool | +| **Working Distance** | 3 feet* | Close to the body/internally | +| **Field of View** | Birds eye view | 100-170 degrees (based on average endoscopic camera FOV) | +| **Camera/Lens Envelope** | Somewhere above the arm, for example in the surgery light | Within the arm | +| **Adjustment Needs** | May be adjusted by zooming in and out | Can be adjusted to look around internally | +| **Occlusion Risks** | View may be blocked or impacted by the tools of the arm. This needs to be considered in mounting position and arm movement. | Since the camera is so small, tools may have a bigger impact on the occlusion | +| **Cable Routing** | Similar to motors on the arm | Similar to the motors on the arm | +| **Lighting Conditions** | Must be able to handle very harsh light | Must work in darker areas (with light mounted?)| +| **Mounting** | A removeable mount may be helpful for maintenance purpose | Directly attached to arm | + +> \* for personnel who are NOT scrubbed in... not sure if this applies for our robot + + +## Benchtop Testing +Using the Gemini 2 by Orbbec, we can test the camera formatting of a stereo camera and can also test how it works in harsh, high contrast lighting. First, we can test simply via our laptops to make sure the camera works. Then, we can try implementing it into our UI which can be made easier since we would have the actual camera with camera feed. + +We should keep these in mind/log information during the first test: +- frame timestamp +- subscriber receive time +- frame number +- resolution +- FPS +- latency per frame + +Then, we should note down: +- average latency +- minimum latency +- maximum latency +- jitter + +## ROS2 Topic Name Proposal + +| Stream | Proposed Topic Name | Purpose | +| --- | --- | --- | +| Left raw image | /doctor_view/left/image_raw | Unprocessed left camera feed | +| Right raw image | /doctor_view/right/image_raw | Unprocessed right camera feed| +| Left processed image | /doctor_view/left/image_proc | Calibrated/stabilized left camera feed | +| Right processed image | /doctor_view/right/image_proc | Calibrated/stabilized right camera feed | +| Left camera info | /doctor_view/left/camera_info| This is where calibration settings for the left camera live| +| Right camera info| /doctor_view/right/camera_info | This is where calibration setting for the right camera live | +| Operator preview | /doctor_view/preview/image_view | An overall view for the operator | + +## Timestamps + +| Requirement | Expectation | +| --- | --- | +| header.stamp | This will display when the frame was captured, not time displayed | +| Left and right stereo sync | The two cameras in the stereo setup should have matching timestamps | +| Frame ID | Using doctor_view_right or left_optical_frame gives the 3D data for the camera views | + +## Latency Measurement Method +- We can manual measure latency by subtracting the *ROS_System_Time* - *Message_Header.stamp* as long as the ROS2 time is synchronized and the header.stamp for the camera feeds are working properly. +- There's a GitHub Repo that is able to calculate latency using OpenCV and ROS, though I don't know if it is helpful for us ([ros-can-latency](https://github.com/plusk01/ros-cam-latency)) +- Another manual method is using a stopwatch to view how it changes on screen vs in real time + +## Long-term Targets + +For long term, a **GigE** camera would be best due to its ability to send camera feeds over long distances. It has low latency and is relatively easier to implement compared to the MIPI CSI cameras. ROS2 also has drivers that are compatible with many GigE cameras. + +**Stereo Camera**: Stereo cameras on the market are generally very small and are automatically synchronized. With this type of camera, the placement of the camera only needs to be considered if we are using two separate cameras to make a stereo camera (which is harder than buying an already stereoscopic camera) + +**Endoscopic Camera**: Endoscopic cameras would be very helpful for seeing closer internal footage. With this camera, we would need to decide how exactly we are going to implement this tool with the rest of the robotic arm. For a short-term target, it might not be possible to add this as endoscopic cameras can get expensive... but would be good to implement for a long-term project. + +## Component Shortlist +> Note: (TBD when mechanical gets back to us with more concrete materials needed) + +### Camera Options +> Note: I am leaning towards the Orbbec Gemini 2 Camera for the initial testing with decent quality... most assumptions are based off of that. + +- Orbbec Gemini 2 Stereo Camera (cable included) -> ~332.15CAD +- Tara Stereo Camera (e-con Systems) -> ~325.05CAD diff --git a/docs/camera-research/orbbec-compatibility.md b/docs/camera-research/orbbec-compatibility.md new file mode 100644 index 0000000..7b35f79 --- /dev/null +++ b/docs/camera-research/orbbec-compatibility.md @@ -0,0 +1,34 @@ +# Orbbec Gemini 2 Camera and OpenCV Compatibility + +OpenCV and the Orbbec cameras do work well together! There is some documentation on how to use the Orbbec camera with OpenCV, and it's very similar to our bridge as it currently stands. + +Here is the documentation on the [Orbbec camera and OpenCV](https://docs.opencv.org/4.13.0/d1/d33/tutorial_orbbec_uvc.html) + +> Here is the official documentation for the [Orbbec Gemini 2 camera](https://d1cd332k3pgc17.cloudfront.net/wp-content/uploads/2023/07/Orbbec-Gemini-2-Series-DatasheetPublicV1.720240316.pdf?_gl=1*ffjzs5*_gcl_au*NzAxNTA3NDEzLjE3ODI1ODg5MzAuODcxNjc2MDcuMTc4MjU4ODk5OC4xNzgyNTg5MDAw) +> Here is the [Orbbec Gemini 2 ROS2 Wrapper Manual](https://doc.orbbec.com/documentation/Orbbec%20Gemini%20330%20Series%20Documentation/ROS2%20Wrapper%20User%20Manual) + +## Limitations +- The maximum RGB resolution would be 1920 x 1080 and its maximum frame rate would be up to 30fps. + - It can also be set with a RBG resolution of 1280 x 720 and its maximum frame rate with that resolution would be 60fps. + +- The Orbbec Gemini 2 has a depth capturing range of 0.15m - 10m with its ideal range being between 0.2m - 5m. + +- The only thing we would have to change within the bridge would be the handling of the stereo camera. This can be found inside of the documentation/tutorial I found. + +- A C++ implementation seems to have an extra feature that flattens colours. I don't think we need this, so we can continue the bridge in Python. + +## Expected Formats +- Listed on the documentation sheet, the expected formats are MJPEG (JPEG images) or YUYV. + - YUYV might be a bit more difficult to integrate, so I would say stick with MJPEG formatting. + +## Bridge Modifications +- We would most likely have to tweak the camera bridge a bit in order to account for the stereo image capturing and the Orbbec camera in general + +- There are a few resources out there covering how to properly use the 3D/Stereo option for the Orbbec Gemini 2, so we can always refer to those when setting up the camera with the Ground Station + +## Unverified Hardware Questions +- Where will this be mounted? +- How is the proper stereo image going to be conveyed? + - Usually, stereo images or video frames are viewed like a binocular (two eyes at once). What kind of mechanism are we going to implement for the doctor to properly view this? + - Would we use VR headsets? + diff --git a/docs/controller-research/controller-comparison.md b/docs/controller-research/controller-comparison.md new file mode 100644 index 0000000..86d96b2 --- /dev/null +++ b/docs/controller-research/controller-comparison.md @@ -0,0 +1,17 @@ +# Controller research + +## Surgeon-Oriented Controller Comparison +> This would likely be a controller to get much later. A lot of specifically surgeon-oriented controllers are **very** expensive. + +| Controller | Precision | Joint or Tool-tip | Enable/Deadman | Ergonomics | Haptics | ROS2 | Cost | +| --- | --- | --- | --- | --- | --- | --- | --- | +| [Haply MinVerse](https://www.haply.co/minverse) | Should have good precision. | Depending on how it's implemented, it can be either tool-tip or joint controlled | The controller has 2 buttons that can be used for the enable. | Should be very ergonomic. Pencil-shaped. | There can be a force feedback from 2N-4N of resistance and can enable the user to feel textures. | Compatible with ROS2 but might be a bit more effort to integrate.* | $1140+ | +| [SpaceMouse Controller](https://3dconnexion.com/us/product/spacemouse-enterprise/)| Is a 6DOF controller and should be very precise. | Tool-tip controlled | There are many buttons that can be used for an enable switch | This would not be the most ergonomic option for a surgeon since they would control the SpaceMouse with their non-dominant hand. | No haptic feedback | Compatible with the [spacenavd](https://index.ros.org/p/spacenav/) driver package. | $564.41+ | + +> \*There is a [driver](https://www.haply.co/blog/haply-robotics-to-offer-its-haptic-controller-with-pickniks-moveitpro) under the same brand that is compatible with MoveIt, however it's only compatible with the [Inverse3](https://www.haply.co/inverse3) model which is a more advanced controller but is far more expensive. + +## Recommendation + +The Haply MinVerse would be a good choice for a long term controller. It is very suitable for controlling surgeries and provides haptics as well. + +Fallback: The SpaceMouse controller would be good for simply controlling the arm. Since it has lots of buttons, many different shortcuts can be mapped and it is a bit cheaper compared to the MinVerse. diff --git a/docs/controller-research/controller-mapping.md b/docs/controller-research/controller-mapping.md new file mode 100644 index 0000000..0758bbc --- /dev/null +++ b/docs/controller-research/controller-mapping.md @@ -0,0 +1,41 @@ +## Controller Mapping + +### MinVerse (better controls, less inputs) +> Note: The MinVerse only has two buttons. This could complicate controls, especially since the buttons are located directly on the stylus which can be easily be misclicked by a pinch. + +| Input | Action | +|---|---| +| Button 1 | Toggle between base and upper joints | +| Button 2 | Return to 0 pose or stop/hold current position* | + +> \* The most important buttons need to be used here... this means choosing between either or. Or, we could have a separate control pad for more inputs/controls. + +--- + +### SpaceMouse (fallback: more inputs, less intuitive controls) +> Note: The [SpaceMouse Wireless](https://3dconnexion.com/manuals/spacemouse-wireless/en/Manual_3Dconnexion-SpaceMouse-Wireless_EN.pdf) has way less inputs than the [SpaceMouse Pro](https://3dconnexion.com/manuals/spacemouse-pro/en/Manual_3Dconnexion-SpaceMouse-Pro_EN.pdf). These are all based off of the SpaceMouse **Pro** +> 's control pad as the Wireless has none. +> +> The pro has 15 different buttons on its interface, which would be helpful for configurations and controls. + +| Input | Action | +| --- | --- | +| 1 | Toggle between base and upper joints | +| 2 | Toggle between controlling base/shoulder and elbow | +| 3 | Toggle biomedical tools | +| 4 | Toggle biomedical tools | +| MENU | Switching speeds | +| FIT | Return to 0 pose | +| LOCK | Stop and hold current pose | +| ESC | Close/open the placeholder end effector | +| CTRL* | - | +| ALT* | - | +| SHIFT* | - | +| T* | - | +| R* | - | +| F* | - | +| ROLL* | - | + +> Note: Lots more controls that can be used for different diagnostic functions instead of controlling robot? + +