Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Update project to 0.0.2 using rclcpp::waitset #82

Open
wants to merge 21 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion github-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export RESET="\e[0m"
# Paths
export WS="/root/ros2_ws"
export ROS2_DISTRO="rolling"
export SKIP_PACKAGES="pendulum_demo"

function prepare_ws()
{
Expand All @@ -38,7 +39,8 @@ function run_rosdep()
apt update -qq && rosdep update
rosdep install -q -y --from-paths . --ignore-src --rosdistro \
"${ROS2_DISTRO}" \
--as-root=apt:false || true
--skip-keys "${SKIP_PACKAGES}" \
--as-root=apt:false
result=$?
if [ $result -ne 0 ]; then
echo -e "${RED}run_rosdep failled${RESET}"
Expand Down
3 changes: 1 addition & 2 deletions pendulum/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
<depend>pendulum2_msgs</depend>
<depend>pendulum_bringup</depend>
<depend>pendulum_controller</depend>
<depend>pendulum_demo</depend>
<depend>pendulum_driver</depend>
<depend>pendulum_utils</depend>

<depend>pendulum_tests</depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down

This file was deleted.

54 changes: 54 additions & 0 deletions pendulum_bringup/launch/controller_bringup.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2021 Carlos San Vicente
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition
import launch.substitutions
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
# Get the bringup directory
bringup_dir = FindPackageShare('pendulum_bringup').find('pendulum_bringup')

# Set parameter file path
param_file_path = os.path.join(bringup_dir, 'params', 'pendulum.param.yaml')
param_file = launch.substitutions.LaunchConfiguration('params', default=[param_file_path])

with_controller_param = DeclareLaunchArgument(
'controller',
default_value='True',
description='Launch controller node'
)

# Node definitions
pendulum_controller_runner = Node(
package='pendulum_controller',
executable='pendulum_controller_exe',
output='screen',
parameters=[param_file],
arguments=[],
condition=IfCondition(LaunchConfiguration('controller'))
)

ld = LaunchDescription()
ld.add_action(with_controller_param)
ld.add_action(pendulum_controller_runner)

return ld
53 changes: 53 additions & 0 deletions pendulum_bringup/launch/driver_bringup.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2021 Carlos San Vicente
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition
import launch.substitutions
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
# Get the bringup directory
bringup_dir = FindPackageShare('pendulum_bringup').find('pendulum_bringup')

# Set parameter file path
param_file_path = os.path.join(bringup_dir, 'params', 'pendulum.param.yaml')
param_file = launch.substitutions.LaunchConfiguration('params', default=[param_file_path])

with_driver_param = DeclareLaunchArgument(
'driver',
default_value='True',
description='Launch driver node'
)

pendulum_driver_runner = Node(
package='pendulum_driver',
executable='pendulum_driver_exe',
output='screen',
parameters=[param_file],
arguments=[],
condition=IfCondition(LaunchConfiguration('driver'))
)

ld = LaunchDescription()
ld.add_action(with_driver_param)
ld.add_action(pendulum_driver_runner)

return ld
108 changes: 11 additions & 97 deletions pendulum_bringup/launch/pendulum_bringup.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,115 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition
import launch.substitutions
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
# Get the bringup directory
bringup_dir = FindPackageShare('pendulum_bringup').find('pendulum_bringup')

# Set robot description parameters
urdf_file = os.path.join(bringup_dir, 'urdf', 'pendulum.urdf')
with open(urdf_file, 'r') as infp:
robot_desc = infp.read()
rsp_params = {'robot_description': robot_desc}

# Set parameter file path
param_file_path = os.path.join(bringup_dir, 'params', 'pendulum.param.yaml')
param_file = launch.substitutions.LaunchConfiguration('params', default=[param_file_path])

# Set rviz config path
rviz_cfg_path = os.path.join(bringup_dir, 'rviz/pendulum.rviz')

# Create the launch configuration variables
autostart_param = DeclareLaunchArgument(
name='autostart',
default_value='True',
description='Automatically start lifecycle nodes')
priority_param = DeclareLaunchArgument(
name='priority',
default_value='0',
description='Set process priority')
cpu_affinity_param = DeclareLaunchArgument(
name='cpu-affinity',
default_value='0',
description='Set process CPU affinity')
with_lock_memory_param = DeclareLaunchArgument(
name='lock-memory',
default_value='False',
description='Lock the process memory')
lock_memory_size_param = DeclareLaunchArgument(
name='lock-memory-size',
default_value='0',
description='Set lock memory size in MB')
config_child_threads_param = DeclareLaunchArgument(
name='config-child-threads',
default_value='False',
description='Configure process child threads (typically DDS threads)')
with_rviz_param = DeclareLaunchArgument(
'rviz',
default_value='False',
description='Launch RVIZ2 in addition to other nodes'
rviz_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([bringup_dir, '/launch/rviz.launch.py'])
)

# Node definitions
pendulum_demo_runner = Node(
package='pendulum_demo',
executable='pendulum_demo',
output='screen',
parameters=[param_file],
arguments=[
'--autostart', LaunchConfiguration('autostart'),
'--priority', LaunchConfiguration('priority'),
'--cpu-affinity', LaunchConfiguration('cpu-affinity'),
'--lock-memory', LaunchConfiguration('lock-memory'),
'--lock-memory-size', LaunchConfiguration('lock-memory-size'),
'--config-child-threads', LaunchConfiguration('config-child-threads')
]
controller_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([bringup_dir, '/launch/controller_bringup.launch.py'])
)

robot_state_publisher_runner = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
output='screen',
parameters=[rsp_params],
condition=IfCondition(LaunchConfiguration('rviz'))
)

rviz_runner = Node(
package='rviz2',
executable='rviz2',
name='rviz2',
arguments=['-d', str(rviz_cfg_path)],
condition=IfCondition(LaunchConfiguration('rviz'))
)

pendulum_state_publisher_runner = Node(
package='pendulum_state_publisher',
executable='pendulum_state_publisher',
condition=IfCondition(LaunchConfiguration('rviz'))
driver_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([bringup_dir, '/launch/driver_bringup.launch.py'])
)

ld = LaunchDescription()

ld.add_action(autostart_param)
ld.add_action(priority_param)
ld.add_action(cpu_affinity_param)
ld.add_action(with_lock_memory_param)
ld.add_action(lock_memory_size_param)
ld.add_action(config_child_threads_param)
ld.add_action(with_rviz_param)
ld.add_action(robot_state_publisher_runner)
ld.add_action(pendulum_demo_runner)
ld.add_action(rviz_runner)
ld.add_action(pendulum_state_publisher_runner)
ld.add_action(controller_launch)
ld.add_action(driver_launch)
ld.add_action(rviz_launch)

return ld
Loading