Skip to content

Commit 9a9bb84

Browse files
committed
🎉 adopt dribbler sensor
1 parent 87b6c00 commit 9a9bb84

10 files changed

Lines changed: 267 additions & 444 deletions

File tree

api.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,23 @@ func HandleRequest(conn net.Conn) {
213213
fmt.Fprintf(conn, "Content-Type: application/json; charset=utf-8\r\n\r\n")
214214

215215
// JSON形式で返す
216+
217+
// 左から1ビットだけを取り出す
218+
detectPhotoSensor := 0b10000000&recvdata.SensorInformation != 0
219+
// 左から2ビット目だけを取り出す
220+
detectDribblerSensor := 0b01000000&recvdata.SensorInformation != 0
221+
// 左から3ビット目だけを取り出す
222+
isNewDribbler := 0b00100000&recvdata.SensorInformation != 0
223+
216224
response := fmt.Sprintf(`{
217225
"VOLT": %f,
218-
"ISHOLDBALL": %t,
226+
"ISDETECTPHOTOSENSOR": %t,
227+
"ISDETECTDRIBBLERSENSOR": %t,
228+
"ISNEWDRIBBLER": %t,
219229
"ERROR": %t,
220230
"ERRORCODE": %d,
221231
"ERRORMESSAGE": "%s"
222-
}`, float32(recvdata.Volt)/10.0, recvdata.IsDetectPhotosensor, isRobotError, RobotErrorCode, RobotErrorMessage)
232+
}`, float32(recvdata.Volt)/10.0, detectPhotoSensor, detectDribblerSensor, isNewDribbler, isRobotError, RobotErrorCode, RobotErrorMessage)
223233

224234
fmt.Fprint(conn, response)
225235

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func kickCheck(chkicker chan bool) {
4141
//ループを行うため、少し待機する
4242
time.Sleep(16 * time.Millisecond)
4343
}
44+
<-chkicker
4445
}
4546

4647
func main() {

proto/pb_gen/grSim_Commands.pb.go

Lines changed: 60 additions & 101 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)