-
Notifications
You must be signed in to change notification settings - Fork 0
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
Full-Resolution Camera Downloads #71
base: main
Are you sure you want to change the base?
Changes from 10 commits
c9f729e
337dcdc
2e82759
23abf31
a83567b
dda7fae
7693ed7
472873f
45e22dd
470151e
145334d
7afc428
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ The rover can be operated through Mission Control with either a keyboard or two | |
![Armo controls](/src/components/help/armControls.png) | ||
![Keyboard controls](/src/components/help/keyboardControls.png) | ||
|
||
## Messages (`v2024.1.2`) | ||
## Messages (`v2024.2.0`) | ||
The JSON objects sent between Mission Control and the rover server are termed *messages*. Each message has a type property and a number of additional parameters depending on the type. The usage of each type of message is detailed below. | ||
|
||
## Mounted Peripheral Report | ||
|
@@ -380,6 +380,38 @@ Sent from the rover server to inform Mission Control of a single frame of a came | |
- `camera` - the name of the camera: `mast|hand|wrist` | ||
- `data` - the raw h264 frame data, or `null` if no data is available | ||
|
||
## Camera Frame Request | ||
### Description | ||
Sent from Mission Control to instruct the rover server to send a Camera Frame Report. | ||
|
||
### Syntax | ||
``` | ||
{ | ||
type: "cameraFrameRequest", | ||
camera: string | ||
} | ||
``` | ||
|
||
### Parameters | ||
- `camera` - the name of the camera | ||
|
||
## Camera Frame Report | ||
### Description | ||
Sent from the rover server to inform Mission Control of a full resolution lossless camera frame. | ||
|
||
### Syntax | ||
``` | ||
{ | ||
type: "cameraFrameReport", | ||
camera: string, | ||
data: string | null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Under what circumstances would |
||
} | ||
``` | ||
|
||
### Parameters | ||
- `camera` - the name of the camera | ||
- `data` - the image, base64 encoded | ||
|
||
|
||
## Autonomous Waypoint Navigation Request | ||
### Description | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,16 @@ import { | |
openCameraStream, | ||
closeCameraStream, | ||
cameraStreamDataReportReceived, | ||
requestCameraFrame, | ||
} from "../camerasSlice"; | ||
import { | ||
messageReceivedFromRover, | ||
messageRover, | ||
roverConnected, | ||
roverDisconnected | ||
} from "../roverSocketSlice"; | ||
import camelCaseToTitle from "../../util/camelCaseToTitle"; | ||
|
||
|
||
/** | ||
* Middleware that handles requesting and receiving camera streams from the | ||
|
@@ -39,6 +42,16 @@ const camerasMiddleware = store => next => action => { | |
break; | ||
} | ||
|
||
case requestCameraFrame.type: { | ||
store.dispatch(messageRover({ | ||
message: { | ||
type: "cameraFrameRequest", | ||
camera: action.payload.cameraName | ||
} | ||
})); | ||
break; | ||
} | ||
|
||
case roverConnected.type: { | ||
// Inform the rover of camera streams we would like to receive when we | ||
// connect. | ||
|
@@ -74,11 +87,26 @@ const camerasMiddleware = store => next => action => { | |
|
||
case messageReceivedFromRover.type: { | ||
const { message } = action.payload; | ||
if (message.type === "cameraStreamReport") | ||
if (message.type === "cameraStreamReport") { | ||
store.dispatch(cameraStreamDataReportReceived({ | ||
cameraName: message.camera, | ||
frameData: message.data | ||
})); | ||
} else if (message.type === "cameraFrameReport") { | ||
if (message.data !== "") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be combined into |
||
let link = document.createElement("a"); | ||
link.href = `data:image/jpg;base64,${message.data}`; | ||
let time = new Date(); | ||
let timezoneOffset = time.getTimezoneOffset() * 60000; | ||
let timeString = new Date(time - timezoneOffset).toISOString().replace(":", "_").substring(0, 19); | ||
|
||
link.download = `${camelCaseToTitle(message.camera)}-${timeString}.jpg`; | ||
document.body.appendChild(link); | ||
link.click(); | ||
document.body.removeChild(link); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing empty line |
||
} | ||
} | ||
break; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super minor, but mention how this works with the report. I.e. "If camera specifies a valid camera stream, the rover will respond with a camera frame report containing the latest frame from that camera."