Skip to content

Commit

Permalink
Merge pull request #26 from clubcapra/Controller-fixes-with-docker
Browse files Browse the repository at this point in the history
Merge Controller fixes with docker to main
  • Loading branch information
patates-cipsi418 authored Feb 3, 2024
2 parents 10ca241 + ab209c8 commit 5c0c06b
Show file tree
Hide file tree
Showing 12 changed files with 293 additions and 151 deletions.
5 changes: 2 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FROM ghcr.io/clubcapra/gazebo:harmonic



# Add vscode user with same UID and GID as your host system
# (copied from https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user)
ARG USERNAME=rove
Expand All @@ -11,7 +9,8 @@ ARG USER_GID=$USER_UID
WORKDIR /workspace/$USERNAME

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& groupadd -g 107 input \
&& useradd -s /bin/bash --uid $USER_UID -g $USER_GID -G 107 -m $USERNAME \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
Expand Down
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,20 @@ Working in a dev container will allow you to have the same environnement as the

### Linux installation

To be tested, but it should be similar to the Windows installation without the Xserver part.
Same as the windows installation, step 4 and 8 can be skiped.

Replace the DISPLAY environemnt variable in the .env file
```bash
echo DISPLAY=$DISPLAY
```

To be able to use the controller node, the user need read/write permissions on the inputs.
Exemple:
```bash
cat /dev/input/event0
```

**Suggestion:** Configure docker to be able to run as non-root user https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user

## Native installation (Ubuntu 22.04 LTS, other distros not supported)

Expand All @@ -38,8 +51,19 @@ source install/setup.bash
ros2 launch rove_description sim.launch.py
```

**Note:** To move the robot, you need to use gazebo as there is no controller yet
## Running the controller with a usb cable

```bash
source install/setup.bash
ros2 launch rove_bringup rove_controller_usb.launch.py
```

## Running the controller with a usb cable

```bash
source install/setup.bash
ros2 launch rove_bringup rove_controller_bluethoot.launch.py
```

## Adding New Packages

Expand All @@ -57,4 +81,4 @@ It's possible to run the entire project into multiple docker containers. Each co

# Documentation

To update the UML diagram, create a new encoded link on the PlantUML website. Copy the existing UML, make your changes, and then update the markdown file with the new link.
To update the UML diagram, create a new encoded link on the PlantUML website. Copy the existing UML, make your changes, and then update the markdown file with the new link.
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ services:
- ./:/workspace/rove
- /tmp/.X11-unix:/tmp/.X11-unix
- /tmp/.Xauthority:/tmp/.Xauthority:rw
- /dev/input:/dev/input:rw
devices:
- /dev/input:/dev/input:rw
env_file:
- .env
command: sleep infinity
Expand Down
7 changes: 4 additions & 3 deletions src/rove_bringup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ project(rove_bringup)
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(Qt5 COMPONENTS Widgets REQUIRED)

add_executable(rove_controller src/rove_controller.cpp)
add_executable(rove_controller_node src/rove_controller_node.cpp)

# Link dependencies
ament_target_dependencies(rove_controller rclcpp sensor_msgs)
ament_target_dependencies(rove_controller_node rclcpp sensor_msgs)

# Install executable
install(TARGETS
rove_controller
rove_controller_node
DESTINATION lib/${PROJECT_NAME}
)

Expand Down
24 changes: 24 additions & 0 deletions src/rove_bringup/config/bluethoot_mapping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/rove_controller_node:
ros__parameters:
# Buttons
A: 0
B: 1
X: 3
Y: 4
LB: 6
RB: 7
VIEW: 10
MENU: 11
XBOX: 12
LS: 13
RS: 14
SHARE: 15
# Axes
LS_X: 0
LS_Y: 1
LT: 5
RS_X: 2
RS_Y: 3
RT: 4
D_PAD_X: 6
D_PAD_Y: 7
21 changes: 8 additions & 13 deletions src/rove_bringup/config/joy_params.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
/game_controller_node:
ros__parameters:
# 0 (publish on change)
autorepeat_rate: 0.0
# 1000ms / 20 (refresh rate in Hz) = 50
autorepeat_rate: 20.0 # 0 (publish on change)
coalesce_interval_ms: 50 # 1000ms / 20 (refresh rate in Hz) = 50
deadzone: 0.05
sticky_buttons: false

/joy_node:
ros__parameters:
autorepeat_rate: 20.0
coalesce_interval_ms: 50
deadzone: 0.05
device_id: 0
device_name: ''
qos_overrides:
/parameter_events:
publisher:
depth: 1000
durability: volatile
history: keep_last
reliability: reliable
sticky_buttons: false
use_sim_time: false
33 changes: 12 additions & 21 deletions src/rove_bringup/config/teleop_joy_params.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
/teleop_twist_joy_node:
ros__parameters:
axis_angular:
pitch: 0 #LS_X
roll: 1 #LS_Y
yaw: -1 #not set
pitch: -1 #not set
roll: -1 #not set
yaw: 0 #LS_X
axis_linear:
x: 5
y: -1
z: -1
x: 1 #LS_Y
y: -1 #not set
z: -1 #not set
enable_button: 0 #A
enable_turbo_button: -1
qos_overrides:
/parameter_events:
publisher:
depth: 1000
durability: volatile
history: keep_last
reliability: reliable
enable_turbo_button: -1 # not set
require_enable_button: true
scale_angular:
pitch: 0.5
roll: 0.5
pitch: 0.0
roll: 0.0
yaw: 0.5
scale_angular_turbo:
pitch: 1.0
roll: 1.0
pitch: 0.0
roll: 0.0
yaw: 1.0
scale_linear:
x: 0.5
Expand All @@ -33,6 +26,4 @@
scale_linear_turbo:
x: 1.0
y: 0.0
z: 0.0
use_sim_time: false

z: 0.0
24 changes: 24 additions & 0 deletions src/rove_bringup/config/usb_mapping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/rove_controller_node:
ros__parameters:
# Buttons
A: 0
B: 1
X: 2
Y: 3
LB: 4
RB: 5
VIEW: 6
MENU: 7
XBOX: 8
LS: 9
RS: 10
SHARE: 11
# Axes
LS_X: 0
LS_Y: 1
LT: 2
RS_X: 3
RS_Y: 4
RT: 5
D_PAD_X: 6
D_PAD_Y: 7
38 changes: 38 additions & 0 deletions src/rove_bringup/launch/rove_controller_bluethoot.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory

def generate_launch_description():
package_name = 'rove_bringup'
dir = get_package_share_directory(package_name)
# Get params files
joy_params_file = dir + '/config/joy_params.yaml'
teleope_joy_params_file = dir + '/config/teleop_joy_params.yaml'
bluethoot_mapping_file = dir + '/config/bluethoot_mapping.yaml'

return LaunchDescription([
Node(
package='joy',
executable='joy_node',
name='game_controller_node',
output='screen',
parameters=[joy_params_file],
),
Node(
package='teleop_twist_joy',
executable='teleop_node',
name='teleop_twist_joy_node',
parameters=[teleope_joy_params_file],
remappings=[
('/joy', '/rove/joy'),
# ('/cmd_vel', '/model/rove/cmd_vel')
],
),
Node(
package=package_name,
executable='rove_controller_node',
name='rove_controller_node',
parameters=[bluethoot_mapping_file],
output='screen',
),
])
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

def generate_launch_description():
package_name = 'rove_bringup'
dir = get_package_share_directory(package_name)
# Get params files
joy_params_file = get_package_share_directory(package_name) + '/config/joy_params.yaml'
teleope_joy_params_file = get_package_share_directory(package_name) + '/config/teleop_joy_params.yaml'
joy_params_file = dir + '/config/joy_params.yaml'
teleope_joy_params_file = dir + '/config/teleop_joy_params.yaml'
usb_mapping_file = dir + '/config/usb_mapping.yaml'

return LaunchDescription([
Node(
package='joy',
executable='game_controller_node',
executable='joy_node',
name='game_controller_node',
output='screen',
parameters=[joy_params_file],
Expand All @@ -23,13 +25,14 @@ def generate_launch_description():
parameters=[teleope_joy_params_file],
remappings=[
('/joy', '/rove/joy'),
('/cmd_vel', '/model/rove/cmd_vel')
# ('/cmd_vel', '/model/rove/cmd_vel')
],
),
Node(
package=package_name,
executable='rove_controller',
name='rove_controller',
executable='rove_controller_node',
name='rove_controller_node',
parameters=[usb_mapping_file],
output='screen',
),
])
Loading

0 comments on commit 5c0c06b

Please sign in to comment.