Skip to content

Commit

Permalink
Merge pull request #318 from toppers/develop
Browse files Browse the repository at this point in the history
Added controller config and fixed debug code
  • Loading branch information
buildko89 authored Sep 7, 2024
2 parents 8d4e726 + f70615c commit 8cf32bc
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 40 deletions.
21 changes: 7 additions & 14 deletions demo/demo.bash
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function activate_vreal()
function adjust_initial_pos()
{
CONFIG_PATH=`pwd`/demo/xr_config.json
cp ${CONFIG_PATH} ${HAKONIWA_VREAL_PATH}/ar-demo/
AR_DEVICE_IPADDR=`jq -r '.server_url' ${CONFIG_PATH} | awk -F: '{print $1}'`
CURR_DIR=`pwd`
cd $HAKONIWA_VREAL_PATH
Expand Down Expand Up @@ -128,17 +129,16 @@ sleep 1

activate_vreal

sleep 1

echo "Pleaser Enter key after clicking START button..."
read
sleep 5
hako-cmd start

sleep 1
if [ ${ACT_MODE} = "ar-demo" ]
then
sleep 1
echo "START ADJUST INITIAL POSITION"
adjust_initial_pos
else
sleep 1
echo "START CAMERA"
camera_control
fi
Expand All @@ -147,12 +147,5 @@ sleep 1
echo "START RADIO CONTROL"
radio_control

echo "START"
while true; do
echo "Press ENTER to stop..."
read input
if [ -z "$input" ]; then
kill_process
break
fi
done
kill_process

6 changes: 3 additions & 3 deletions demo/xr_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"server_url": "192.168.2.101:54002",
"client_url": "192.168.2.100:54001",
"position": [
-1.0900000000000003,
0.99,
1.1
0.5,
0.5,
0
],
"rotation": [
0,
Expand Down
82 changes: 82 additions & 0 deletions drone_api/sample/rc_config/Nintendo-ProControl-lnx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"Os": [ "Darwin" ],
"mode": 2,
"stick": {
"Left": {
"UD": {
"index": 1,
"average": true,
"valueInverse": false,
"conversion": {
"paramA": 0.9,
"paramB": 0.1,
"paramC": 0.0
}
},
"LR": {
"index": 0,
"average": true,
"valueInverse": false,
"conversion": {
"paramA": 0.9,
"paramB": 0.1,
"paramC": 0.0
}
}
},
"Right": {
"UD": {
"index": 3,
"average": true,
"valueInverse": false,
"conversion": {
"paramA": 0.9,
"paramB": 0.1,
"paramC": 0.0
}
},
"LR": {
"index": 2,
"average": true,
"valueInverse": false,
"conversion": {
"paramA": 0.9,
"paramB": 0.1,
"paramC": 0.0
}
}
}
},
"Event": {
"RadioControlEnable": {
"index": 0,
"type": "switch",
"off": "up",
"on": "down"
},
"Camera": {
"index": 3,
"type": "push",
"off": "up",
"on": "down"
},
"GrabBaggage": {
"index": 1,
"type": "toggle",
"off": "up",
"on": "down"
},
"CameraMoveUp": {
"index": 5,
"type": "switch",
"off": "up",
"on": "down"
},
"CameraMoveDown": {
"index": 6,
"type": "switch",
"off": "up",
"on": "down"
}
}
}
33 changes: 10 additions & 23 deletions drone_api/sample/rc_debug/rc_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
joystick.init()
print('ジョイスティックの名前:', joystick.get_name())
print('ボタン数 :', joystick.get_numbuttons())
print("ジョイスティック数 : " + str(joystick.get_numaxes()))
print("十字キー数 : " + str(joystick.get_numhats()))
except pygame.error:
print('ジョイスティックが接続されていません')

Expand All @@ -18,28 +20,14 @@
active = False

if e.type == pygame.locals.JOYHATMOTION:
if e.value[0] == 0:
if e.value[1] == 1:
print("十字キー:上")
elif e.value[1] == 0:
print("十字キー:ー")
else:
print("十字キー:下")
elif e.value[0] == 1:
if e.value[1] == 0:
print("十字キー:右")
elif e.value[1] == 1:
print("十字キー:右上")
else:
print("十字キー:右下")
else:
if e.value[1] == 0:
print("十字キー:左")
elif e.value[1] == 1:
print("十字キー:左上")
else:
print("十字キー:左下")

if e.value[0] > 0:
print("十字キー 右", e.value[0])
if e.value[0] < 0:
print("十字キー 左", e.value[0])
if e.value[1] > 0:
print("十字キー 上", e.value[1])
if e.value[1] < 0:
print("十字キー 下", e.value[1])
elif e.type == pygame.locals.JOYAXISMOTION:
if e.axis == 0 or e.axis == 1:
if e.value == 0.0 or e.value == 1.0 or e.value == -1.0:
Expand All @@ -62,4 +50,3 @@
print('ボタン押す {0}'.format(e.button))
elif e.type == pygame.locals.JOYBUTTONUP:
print('ボタン離す {0}'.format(e.button))

0 comments on commit 8cf32bc

Please sign in to comment.