aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2016-04-18 03:09:11 -0700
committerJakob Odersky <jakob@odersky.com>2016-04-18 03:09:11 -0700
commitea468fe2af5dbc674c08e2f2c1d6766e6596f9a1 (patch)
tree69e68a814bd5482d269aa29c389adb96b8e96c80
parentdae336ee5514970fee93b0db25ce272ab83bd3c7 (diff)
downloadmavigator-ea468fe2af5dbc674c08e2f2c1d6766e6596f9a1.tar.gz
mavigator-ea468fe2af5dbc674c08e2f2c1d6766e6596f9a1.tar.bz2
mavigator-ea468fe2af5dbc674c08e2f2c1d6766e6596f9a1.zip
Roll angle fixes
-rw-r--r--mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala16
-rw-r--r--mavigator-cockpit/src/main/scala/mavigator/cockpit/Layout.scala1
-rw-r--r--mavigator-cockpit/src/main/scala/mavigator/cockpit/MavlinkWebSockets.scala5
-rw-r--r--mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala2
4 files changed, 15 insertions, 9 deletions
diff --git a/mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala b/mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala
index 7c4bf92..c8715f4 100644
--- a/mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala
+++ b/mavigator-cockpit/src/main/scala/mavigator/cockpit/Instruments.scala
@@ -35,7 +35,7 @@ trait Instruments { page: Page =>
/** Called when element has been loaded. */
private def load(event: dom.Event): Unit = {
for (part <- moveable) {
- part.style.transition = "transform 20ms ease-out"
+ //part.style.transition = "transform 300ms ease"
}
}
@@ -59,7 +59,7 @@ trait Instruments { page: Page =>
/** Applies rotation styling to an element. */
def rotate(elem: html.Element, rad: Double): Unit = {
- elem.style.transform = "rotateZ(" + rad + "rad)";
+ elem.style.transform = "rotate(" + rad + "rad)";
}
}
@@ -74,7 +74,7 @@ trait Instruments { page: Page =>
import SvgInstrument._
val (pitch, roll) = pitchRoll
translate(pitchPart, 0, (pitch * 180 / math.Pi * 10).toInt) // 1deg === 10px
- rotate(rollPart, roll)
+ rotate(rollPart, -roll)
}
}
@@ -82,15 +82,16 @@ trait Instruments { page: Page =>
import SvgInstrument._
override def element = div(`class`:="hud-overlay")(objectElement).render
- lazy val horizon = part("horizon")
- lazy override val moveable = Seq(horizon)
+ lazy val rollPart = part("roll")
+ lazy val pitchPart = part("pitch")
+ lazy override val moveable = Seq(rollPart, pitchPart)
override def update(pitchRoll: (Float, Float)) = {
val (pitch, roll) = pitchRoll
-
val t = (pitch * 180 / math.Pi * 10).toInt // 1deg === 10px
- horizon.style.transform = s"rotateZ(${roll}rad)translate(0px, ${t}px) "
+ SvgInstrument.rotate(rollPart, -roll)
+ SvgInstrument.translate(pitchPart, 0, t)
}
}
@@ -171,3 +172,4 @@ trait Instruments { page: Page =>
def instrumentStyles: Seq[String] = Seq(overlayStyle, modeStyle)
}
+
diff --git a/mavigator-cockpit/src/main/scala/mavigator/cockpit/Layout.scala b/mavigator-cockpit/src/main/scala/mavigator/cockpit/Layout.scala
index 887c4d6..991ee9a 100644
--- a/mavigator-cockpit/src/main/scala/mavigator/cockpit/Layout.scala
+++ b/mavigator-cockpit/src/main/scala/mavigator/cockpit/Layout.scala
@@ -18,6 +18,7 @@ trait Layout { self: Page with Instruments =>
/** Element to deisplay on heads-up display (main area). */
def hud = div(id :="hud")(
+ horizonOverlay.element,
attitudeOverlay.element
)
diff --git a/mavigator-cockpit/src/main/scala/mavigator/cockpit/MavlinkWebSockets.scala b/mavigator-cockpit/src/main/scala/mavigator/cockpit/MavlinkWebSockets.scala
index 3797005..b2ecf48 100644
--- a/mavigator-cockpit/src/main/scala/mavigator/cockpit/MavlinkWebSockets.scala
+++ b/mavigator-cockpit/src/main/scala/mavigator/cockpit/MavlinkWebSockets.scala
@@ -52,7 +52,10 @@ trait MavlinkWebSockets { self: Instruments =>
}
private def onMessage(msg: Message): Unit = msg match {
- case a: Attitude => attitudeOverlay.update((a.pitch.toFloat, a.roll.toFloat))
+ case a: Attitude =>
+ attitudeOverlay.update((a.pitch, a.roll))
+ horizonOverlay.update((a.pitch, a.roll))
+
case _ => ()
}
diff --git a/mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala b/mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala
index 7e59ed8..dc0febc 100644
--- a/mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala
+++ b/mavigator-cockpit/src/main/scala/mavigator/index/ActiveVehicle.scala
@@ -26,7 +26,7 @@ object ActiveVehicle {
def autopilot(tpe: Int) = tpe match {
case MavAutopilot.MavAutopilotGeneric => "Generic"
case MavAutopilot.MavAutopilotInvalid => "Invalid"
- case MavAutopilot.MavAutopilotPixhawk => "Pixhawk"
+ case MavAutopilot.MavAutopilotPx4 => "PX4"
case _ => "Other"
}