Skip to content

Commit

Permalink
working with joy setup - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikN committed Jun 23, 2024
1 parent 582cda2 commit f83631f
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions snap/hooks/install
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ cp -r $SNAP/usr/share/rosbot-xl/config/teleop_twist_joy_params.yaml ${SNAP_COMMO

# copy joy params
cp -r $SNAP/usr/share/rosbot-xl/config/joy_servo.yaml ${SNAP_COMMON}/
cp -r $SNAP/usr/share/rosbot-xl/config/joy_teleop.config.yaml ${SNAP_COMMON}/
cp -r $SNAP/usr/share/rosbot-xl/config/joy_params.yaml ${SNAP_COMMON}/

# copy webui layouts
cp -r $SNAP/usr/share/$SNAP_NAME/config/foxglove-*.json ${SNAP_COMMON}/
7 changes: 7 additions & 0 deletions snap/local/arm_activate_launcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash -e

STATE=$1

ros2 service call /controller_manager/set_hardware_component_state \
controller_manager_msgs/srv/SetHardwareComponentState \
"{name: 'manipulator', target_state: {id: 0, label: '${STATE}'}}"
19 changes: 19 additions & 0 deletions snap/local/joy_launcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -e

ros2 run joy joy_node --ros-args --params-file $SNAP_COMMON/joy_params.yaml

# # Retrieve the namespace using snapctl
# NAMESPACE="$(snapctl get ros.namespace)"

# # Check if NAMESPACE is not set or is empty
# if [ -z "$NAMESPACE" ]; then
# # No namespace is set, run the launch command without the namespace argument
# ros2 launch teleop_twist_joy teleop-launch.py \
# config_filepath:=$SNAP_COMMON/joy_teleop.config.yaml
# # ros2 launch teleop_twist_joy teleop-launch.py
# else
# # Namespace is set, include it in the launch command
# ros2 launch teleop_twist_joy teleop-launch.py \
# config_filepath:=$SNAP_COMMON/joy_teleop.config.yaml --ros-args -r __ns:=/$NAMESPACE
# # ros2 launch teleop_twist_joy teleop-launch.py --ros-args -r __ns:=/$NAMESPACE
# fi
6 changes: 6 additions & 0 deletions snap/local/joy_params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
joy_node:
ros__parameters:
dev: "/dev/input/js0" # Replace with your joystick device
deadzone: 0.1
autorepeat_rate: 20.0
# dev_ff: "/dev/input/event18" # based on evtest
26 changes: 26 additions & 0 deletions snap/local/joy_teleop.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# joy_node:
# ros__parameters:
# device_id: 4
# device_name: "''"
# deadzone: 0.5
# autorepeat_rate: 20.0
# sticky_buttons: false
# coalesce_interval_ms: 1
---
/**:
ros__parameters:
axis_linear:
x: 1
scale_linear:
x: 0.7
scale_linear_turbo:
x: 1.5

axis_angular:
yaw: 2
scale_angular:
yaw: 0.4

require_enable_button: true
enable_button: 4 # TL shoulder button
enable_turbo_button: -1 # disabled
23 changes: 23 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,29 @@ apps:
slots: [shm-slot]
extensions: [ros2-humble-ros-base]

joy:
command: usr/bin/joy_launcher.sh
command-chain: [usr/bin/ros_setup.sh]
environment:
LD_LIBRARY_PATH: "$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio:$LD_LIBRARY_PATH"
plugs: [hardware-observe, joystick, network, network-bind, shm-plug]
slots: [shm-slot]
extensions: [ros2-humble-ros-base]

arm-activate:
command: usr/bin/arm_activate_launcher.sh active
command-chain: [usr/bin/ros_setup.sh]
plugs: [network, network-bind, shm-plug]
slots: [shm-slot]
extensions: [ros2-humble-ros-base]

arm-disactivate:
command: usr/bin/arm_activate_launcher.sh inactive
command-chain: [usr/bin/ros_setup.sh]
plugs: [network, network-bind, shm-plug]
slots: [shm-slot]
extensions: [ros2-humble-ros-base]

print-serial-number:
command: usr/bin/serial_number_launcher.sh
command-chain: [usr/bin/ros_setup.sh]
Expand Down

0 comments on commit f83631f

Please sign in to comment.