-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
406 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
project(virtual_joystick) | ||
|
||
find_package(catkin REQUIRED COMPONENTS | ||
roscpp | ||
rospy | ||
duckietown_msgs # Every duckietown packages should use this. | ||
) | ||
|
||
|
||
catkin_python_setup() | ||
|
||
|
||
catkin_package() | ||
|
||
include_directories( | ||
${catkin_INCLUDE_DIRS} | ||
) |
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.
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.
11 changes: 11 additions & 0 deletions
11
packages/virtual_joystick/launch/virtual_joystick_cli.launch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<arg name="veh" doc="name of the vehicle"/> | ||
<arg name="pkg_name" value="virtual_joystick"/> | ||
<arg name="node_name" default="virtual_joystick"/> | ||
|
||
<group ns="$(arg veh)"> | ||
<remap from="$(arg node_name)/joy" to="joy" /> | ||
<node pkg="$(arg pkg_name)" type="$(arg node_name)_cli.py" name="$(arg node_name)" output="screen" /> | ||
</group> | ||
</launch> |
13 changes: 13 additions & 0 deletions
13
packages/virtual_joystick/launch/virtual_joystick_gui.launch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<arg name="veh" doc="name of the vehicle"/> | ||
<arg name="pkg_name" value="virtual_joystick"/> | ||
<arg name="node_name" default="virtual_joystick"/> | ||
|
||
<group ns="$(arg veh)"> | ||
<remap from="$(arg node_name)/joy" to="joy" /> | ||
<remap from="$(arg node_name)/intersection_go" to="coordinator_node/intersection_go" /> | ||
<remap from="$(arg node_name)/emergency_stop" to="wheels_driver_node/emergency_stop" /> | ||
<node pkg="$(arg pkg_name)" type="$(arg node_name)_gui.py" name="$(arg node_name)" output="screen" args="$(arg veh)" /> | ||
</group> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0"?> | ||
<package> | ||
<name>virtual_joystick</name> | ||
<version>1.0.0</version> | ||
<description> | ||
A package for launching the virtual joystick in gui or cli | ||
</description> | ||
|
||
<author email="[email protected]">Mack</author> | ||
<maintainer email="[email protected]">Mack</maintainer> | ||
|
||
<license>GPLv3</license> | ||
|
||
<buildtool_depend>catkin</buildtool_depend> | ||
<build_depend>duckietown_msgs</build_depend> | ||
<build_depend>roscpp</build_depend> | ||
<build_depend>rospy</build_depend> | ||
|
||
|
||
<run_depend>duckietown_msgs</run_depend> | ||
<run_depend>roscpp</run_depend> | ||
<run_depend>rospy</run_depend> | ||
|
||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env python2 | ||
import rospy | ||
|
||
from sensor_msgs.msg import Joy | ||
|
||
|
||
# Button List index of joy.buttons array: | ||
# 0: A | ||
# 1: B | ||
# 2: X | ||
# 3: Y | ||
# 4: Left Back | ||
# 5: Right Back | ||
# 6: Back | ||
# 7: Start | ||
# 8: Logitek | ||
# 9: Left joystick | ||
# 10: Right joystick | ||
|
||
|
||
# TODO: This should be a class | ||
|
||
def keyCatcher(): | ||
rospy.init_node('joy-cli') | ||
pub = rospy.Publisher('~joy', Joy, queue_size=1) | ||
|
||
while not rospy.is_shutdown(): | ||
axes = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] | ||
buttons = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | ||
direction = raw_input( | ||
'Enter direction [a,w,s,d] to move; ' | ||
'[l] to start lane following; ' | ||
'[q] to stop lane following; ' | ||
'[e] to toggle emergency stop; ' | ||
'then press enter to execute --> ') | ||
if direction == 'w': | ||
axes[1] = 1.0 | ||
elif direction == 's': | ||
axes[1] = -1.0 | ||
elif direction == 'd': | ||
axes[3] = -1.0 | ||
elif direction == 'a': | ||
axes[3] = 1.0 | ||
elif direction == 'l': | ||
buttons[7] = 1 | ||
elif direction == 'q': | ||
buttons[6] = 1 | ||
elif direction == 'e': | ||
buttons[3] = 1 | ||
# publish joy message | ||
msg = Joy(header=None, axes=axes, buttons=buttons) | ||
pub.publish(msg) | ||
rospy.sleep(0.5) | ||
|
||
|
||
if __name__ == '__main__': | ||
try: | ||
keyCatcher() | ||
except rospy.ROSInterruptException: | ||
pass | ||
|
Oops, something went wrong.