Skip to content

Commit

Permalink
Added orientation support to Omicontrol, fix for demo on Monday
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyoung101 committed Jul 30, 2020
1 parent f9c2774 commit 6932714
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Teensy/lib/nanopb/UART.pb.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.3.9.3 at Mon Jul 13 23:03:26 2020. */
/* Generated by nanopb-0.3.9.3 at Sun Jul 19 20:45:16 2020. */

#include "UART.pb.h"

Expand Down
2 changes: 1 addition & 1 deletion Teensy/lib/nanopb/UART.pb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.9.3 at Mon Jul 13 23:03:26 2020. */
/* Generated by nanopb-0.3.9.3 at Sun Jul 19 20:45:16 2020. */

#ifndef PB_UART_PB_H_INCLUDED
#define PB_UART_PB_H_INCLUDED
Expand Down
10 changes: 5 additions & 5 deletions omicam/src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/** Omicam will be running locally on a PC for debugging. Uses test imagery and some features are disabled. */
#define BUILD_TARGET_PC 1
/** which platform Omicam will be running on */
#define BUILD_TARGET (BUILD_TARGET_PC)
#define BUILD_TARGET (BUILD_TARGET_SBC)

/**
* Version history:
Expand Down Expand Up @@ -45,11 +45,11 @@
#define VISION_LOAD_TEST_VIDEO 0

/** send a debug frame every N real frames */
#define REMOTE_FRAME_INTERVAL 1
#define REMOTE_FRAME_INTERVAL 2
/** quality of remote debugger JPEG, 0 being the worst and 100 being the best */
#define REMOTE_JPEG_QUALITY 75
#define REMOTE_JPEG_QUALITY 60
/** zlib compression level for threshold masks, 0 being cheapest and 10 being most expensive */
#define REMOTE_COMPRESS_LEVEL 6
#define REMOTE_COMPRESS_LEVEL 7
/** which port the remote debug TCP server runs on */
#define REMOTE_PORT 42708
/** whether or not remote debug is enabled */
Expand Down Expand Up @@ -88,7 +88,7 @@
/** Whether or not to use a moving average to smooth the localiser output. Recommended due to noise. */
#define LOCALISER_ENABLE_SMOOTHING 1
/** The size of the moving average history for smoothing, larger values mean smoother but less precision. */
#define LOCALISER_SMOOTHING_SIZE 16
#define LOCALISER_SMOOTHING_SIZE 64
/** If true, smooths using the moving median instead of the moving average */
#define LOCALISER_SMOOTHING_MEDIAN 0
/** If true, the localiser uses the mouse sensor for initial estimate calculation. If false, it only uses the goals. */
Expand Down
3 changes: 2 additions & 1 deletion omicontrol/src/main/kotlin/com/omicron/omicontrol/Values.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import org.greenrobot.eventbus.EventBus
* 3.5a: fixed some bugs, added some more tools to for debugging
* 4.5b: Omicontrol enters beta, added support for hybrid localiser displays, fixed some bugs
* 4.6b: added built-in mirror model calculation with exponential and polynomial (instead of CSV export)
* 4.7b: (WIP) added camera dewarp tool and frontend for obstacle detection and robot orientation
* 4.7b: added camera dewarp tool and frontend for obstacle detection and robot orientation
* 4.8b: (WIP) ???
*/
const val OMICONTROL_VERSION = "4.7b"
const val DEFAULT_IP = "192.168.12.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import com.omicron.omicontrol.field.FieldObject
import com.omicron.omicontrol.field.Robot
import javafx.geometry.Point2D
import javafx.geometry.Pos
import javafx.scene.SnapshotParameters
import javafx.scene.canvas.GraphicsContext
import javafx.scene.control.Alert
import javafx.scene.control.Label
import javafx.scene.image.Image
import javafx.scene.image.ImageView
import javafx.scene.input.KeyCode
import javafx.scene.input.KeyCodeCombination
import javafx.scene.input.KeyCombination
import javafx.scene.layout.Priority
import javafx.scene.paint.Color
import javafx.scene.transform.Rotate
import org.apache.commons.io.FileUtils
import org.greenrobot.eventbus.Subscribe
import org.tinylog.kotlin.Logger
Expand All @@ -24,6 +27,7 @@ import kotlin.math.roundToInt
import kotlin.math.sin
import kotlin.system.exitProcess


/**
* This screen displays the localised positions of the robots on a virtual field and allows you to control them
* @param isOffline if true, we are loading a replay from disk, otherwise we are connected to the robot
Expand All @@ -35,9 +39,9 @@ class FieldView(private val isOffline: Boolean = false) : View() {
private lateinit var ballLabel: Label
private val fieldImage = Image("field_cropped_scaled.png")
private val targetIcon = Image("target.png")
private val robotDefaultSprite = Image("robot.png")
private val robotUnknownSprite = Image("robot_unknown2.png")
private val robotSelectedSprite = Image("robot_selected.png")
private val robotDefaultSprite = ImageView(Image("robot.png", ROBOT_CANVAS_DIAMETER, ROBOT_CANVAS_DIAMETER, false, true))
private val robotUnknownSprite = ImageView(Image("robot_unknown2.png", ROBOT_CANVAS_DIAMETER, ROBOT_CANVAS_DIAMETER, false, true))
private val robotSelectedSprite = ImageView(Image("robot_selected.png", ROBOT_CANVAS_DIAMETER, ROBOT_CANVAS_DIAMETER, false, true))
private lateinit var localiserPerfLabel: Label
private val robots = listOf(
Robot(0),
Expand Down Expand Up @@ -126,9 +130,15 @@ class FieldView(private val isOffline: Boolean = false) : View() {
val half = ROBOT_CANVAS_DIAMETER / 2.0
val pos = robot.position.toCanvasPosition()
val sprite = if (selectedRobot == robot) robotSelectedSprite else if (robot.isPositionKnown) robotDefaultSprite else robotUnknownSprite
sprite.rotate = robot.orientation.toDouble()

// this is dumb, source: https://stackoverflow.com/a/33618088/5007892
val params = SnapshotParameters()
params.fill = Color.TRANSPARENT
val rotatedImage = sprite.snapshot(params, null)

display.globalAlpha = if (isReduceTransparency) 0.3 else 1.0
display.drawImage(sprite, pos.x - half, pos.y - half, ROBOT_CANVAS_DIAMETER, ROBOT_CANVAS_DIAMETER)
display.drawImage(rotatedImage, pos.x - half, pos.y - half)
display.globalAlpha = 1.0

display.fill = Color.MAGENTA
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6932714

Please sign in to comment.