Commit dc53ac12 authored by p x's avatar p x
Browse files

调通车辆位姿

parent 1b8c1b49
......@@ -64,7 +64,7 @@ class MockVM @Inject constructor(
fun onVehicleMock(
carVehicle: MutableLiveData<CarVehicle>
) {
HighMapApi.setCameraAngle(30f)
// HighMapApi.setCameraAngle(30f)
viewModelScope.launch {
var cCar: CarVehicle? = null
......@@ -108,12 +108,12 @@ class MockVM @Inject constructor(
)
}
cCar = CarVehicle().apply {
var temps=this.vehiclePos?.toMutableList()
var temps = this.vehiclePos?.toMutableList()
if ((head - oldHead).absoluteValue < 45) {
temps?.set(2,head)
temps?.set(2, head)
}
temps?.set(0,it[0])
temps?.set(1,it[1])
temps?.set(0, it[0])
temps?.set(1, it[1])
// latitude = it[1]
// longitude = it[0]
}
......@@ -123,7 +123,12 @@ class MockVM @Inject constructor(
carVehicle.value = cCar
//更新小地图小车
showNavingCarPosition(
Tools.latLngToNdsPoint(LatLng(cCar.vehiclePos!!.get(1), cCar.vehiclePos.get(0))),
Tools.latLngToNdsPoint(
LatLng(
cCar.vehiclePos!!.get(1),
cCar.vehiclePos.get(0)
)
),
cCar.vehiclePos.get(2).toFloat()
)
//更新小地图路径
......@@ -152,10 +157,10 @@ class MockVM @Inject constructor(
var forword = parkPath.result.routes.find { it.gear == 3 }
forword?.polyline?.forEach { poly ->
cCar = CarVehicle().apply {
var temps=this.vehiclePos?.toMutableList()
temps?.set(0,poly.get(0))
temps?.set(1,poly.get(1))
temps?.set(2,poly.get(3))
var temps = this.vehiclePos?.toMutableList()
temps?.set(0, poly.get(0))
temps?.set(1, poly.get(1))
temps?.set(2, poly.get(3))
// latitude = poly.get(1)
// longitude = poly.get(0)
// heading = poly.get(3)
......@@ -164,7 +169,12 @@ class MockVM @Inject constructor(
carVehicle.value = cCar
//更新小地图小车
showNavingCarPosition(
Tools.latLngToNdsPoint(LatLng(cCar.vehiclePos!!.get(1), cCar.vehiclePos.get(0))),
Tools.latLngToNdsPoint(
LatLng(
cCar.vehiclePos!!.get(1),
cCar.vehiclePos.get(0)
)
),
cCar.vehiclePos.get(2).toFloat()
)
delay(300)
......@@ -183,16 +193,21 @@ class MockVM @Inject constructor(
var fBack = parkPath.result.routes.find { it.gear == 1 }
fBack?.polyline?.forEach { poly ->
cCar = CarVehicle().apply {
var temps=this.vehiclePos?.toMutableList()
temps?.set(0,poly.get(0))
temps?.set(1,poly.get(1))
temps?.set(2,poly.get(3))
var temps = this.vehiclePos?.toMutableList()
temps?.set(0, poly.get(0))
temps?.set(1, poly.get(1))
temps?.set(2, poly.get(3))
}
//更新主车位置
carVehicle.value = cCar
//更新小地图小车
showNavingCarPosition(
Tools.latLngToNdsPoint(LatLng(cCar.vehiclePos!!.get(1), cCar.vehiclePos.get(0))),
Tools.latLngToNdsPoint(
LatLng(
cCar.vehiclePos!!.get(1),
cCar.vehiclePos.get(0)
)
),
cCar.vehiclePos!!.get(1).toFloat()
)
delay(300)
......@@ -212,6 +227,25 @@ class MockVM @Inject constructor(
}
/***跑服务器的模拟数据**/
fun subVehicle(
carLiveData: MutableLiveData<CarVehicle>
) {
viewModelScope.launch {
var gson = Gson()
var datas = mutableListOf<String>()
FileIoUtils.getAssetMock(context, "mock/CarVehicle_Test.txt", datas)
datas.forEach { str ->
val cCar = gson.fromJson<CarVehicle>(str, CarVehicle::class.java)
if (cCar.vehiclePos != null) {
carLiveData.postValue(cCar)
delay(200)
}
}
}
}
var sPolyline: Polyline? = null
//点坐标集合
......
package com.sd.cavphmi.websockets
import com.sd.cavphmi.intfaces.OnWebSocketCb
import org.java_websocket.client.WebSocketClient
import org.java_websocket.drafts.Draft
import org.java_websocket.handshake.ServerHandshake
import java.net.URI
import java.nio.ByteBuffer
......@@ -25,7 +23,7 @@ class V2xWSClient : BaseWsClient {
override fun onOpen(handshakedata: ServerHandshake?) {
// send("Hello, it is me. Mario :)")
println(TAG + "------------v2x预警 "+uri.toString())
println(TAG + "------v2x预警 "+uri.toString())
}
override fun onMessage(message: String?) {
......@@ -33,28 +31,19 @@ class V2xWSClient : BaseWsClient {
if (message.isNullOrEmpty())
return
onWebSocketCb?.onMsg(message)
// onSocketCb?.onMessage(message)
}
override fun onMessage(bytes: ByteBuffer?) {
// System.out.println(TAG + " received ByteBuffer")
}
override fun onClose(code: Int, reason: String?, remote: Boolean) {
// System.out.println(TAG + " closed with exit code " + code + " additional info: " + reason);
}
override fun onError(ex: Exception?) {
// System.err.println(TAG + "an error occurred:" + ex)
}
// var onDataCb: OnDataCb? = null
// interface OnDataCb {
// fun onMsg(str: String)
// }
}
\ No newline at end of file
......@@ -145,7 +145,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="直接到首页" />
android:text="直接到首页"
android:visibility="gone"/>
</LinearLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingVertical="5dp">
<TextView
android:id="@+id/tv_plate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:gravity="center"
android:textSize="14sp"/>
</LinearLayout>
\ No newline at end of file
......@@ -191,7 +191,8 @@
android:layout_centerVertical="true"
android:layout_marginLeft="2dp"
android:layout_toRightOf="@id/img_auto"
android:text="自动驾驶"
tools:text="自动驾驶"
app:showAutoDri="@{cpBean.driveMode}"
android:textColor="@color/text_black"
android:textSize="@dimen/sp_12"
/>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_dialog_custom"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="10dp">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="选择车辆"
android:textColor="@color/black"
android:textSize="16sp" />
<!-- <TextView-->
<!-- android:id="@+id/tv_cancle"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:text="取消"-->
<!-- android:textColor="#555"-->
<!-- android:textSize="14sp" />-->
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</LinearLayout>
\ No newline at end of file
......@@ -2,6 +2,7 @@
<resources>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="transparent">#00000000</color>
<color name="text_blue">#3385FE</color>
<color name="text_black">#000000</color>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment