Skip to content

CI setup #522

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

Merged
merged 2 commits into from
Jun 23, 2025
Merged
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
32 changes: 32 additions & 0 deletions .github/workflows/python_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Ensure Python code is linted and formatted, matching the style guide
name: Python Linting

on: [push, pull_request]

jobs:
black-lint:
runs-on: ubuntu-latest
name: Python black Lint
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
flake8-lint:
runs-on: ubuntu-latest
name: Python flake8 Lint
steps:
- name: Check out source repository
uses: actions/checkout@v3

- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: flake8 Lint
uses: py-actions/flake8@v2
with:
ignore: "E701,W503,E203"
exclude: "docs,.idea"
max-line-length: "88"
path: "."
plugins: "flake8-docstrings flake8-black"
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
from launch_ros.actions import Node
import yaml


def generate_launch_description():
shared_dir = get_package_share_directory('kobuki_launch')
shared_dir = get_package_share_directory("kobuki_launch")

params_file = os.path.join(shared_dir, 'config', 'kobuki_node_params.yaml')
with open(params_file, 'r') as f:
kobuki_params = yaml.safe_load(f)['kobuki_ros_node']['ros__parameters']
params_file = os.path.join(shared_dir, "config", "kobuki_node_params.yaml")
with open(params_file, "r") as f:
kobuki_params = yaml.safe_load(f)["kobuki_ros_node"]["ros__parameters"]

kobuki_cmd = Node(package='kobuki_node',
executable='kobuki_ros_node',
output='screen',
kobuki_cmd = Node(
package="kobuki_node",
executable="kobuki_ros_node",
output="screen",
parameters=[kobuki_params],
)
)

ld = LaunchDescription()

ld.add_action(kobuki_cmd)

return ld
Original file line number Diff line number Diff line change
Expand Up @@ -42,62 +42,54 @@
def generate_launch_description():

urdf_path = PathJoinSubstitution(
[FindPackageShare('custom_robots'), 'urdf', 'kobuki_standalone.urdf.xacro']
[FindPackageShare("custom_robots"), "urdf", "kobuki_standalone.urdf.xacro"]
)

rviz_config_path = PathJoinSubstitution(
[FindPackageShare('custom_robots'), 'rviz', 'model.rviz']
[FindPackageShare("custom_robots"), "rviz", "model.rviz"]
)

return LaunchDescription([

DeclareLaunchArgument(
name='urdf',
default_value=urdf_path,
description='URDF path'
),

DeclareLaunchArgument(
name='use_sim_time',
default_value='false',
description='Use simulation time'
),

DeclareLaunchArgument(
name='rviz',
default_value='false',
description='Run rviz'
),

Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
output='screen',
parameters=[{
'use_sim_time': LaunchConfiguration('use_sim_time'),
'robot_description': Command(['xacro ', LaunchConfiguration('urdf')])
}]
),

Node(
package='joint_state_publisher',
executable='joint_state_publisher',
name='joint_state_publisher',
parameters=[{
'use_sim_time': LaunchConfiguration('use_sim_time')
}]
),

Node(
package='rviz2',
executable='rviz2',
name='rviz2',
output='screen',
arguments=['-d', rviz_config_path],
condition=IfCondition(LaunchConfiguration('rviz')),
parameters=[{
'use_sim_time': LaunchConfiguration('use_sim_time')
}]
),
])
return LaunchDescription(
[
DeclareLaunchArgument(
name="urdf", default_value=urdf_path, description="URDF path"
),
DeclareLaunchArgument(
name="use_sim_time",
default_value="false",
description="Use simulation time",
),
DeclareLaunchArgument(
name="rviz", default_value="false", description="Run rviz"
),
Node(
package="robot_state_publisher",
executable="robot_state_publisher",
name="robot_state_publisher",
output="screen",
parameters=[
{
"use_sim_time": LaunchConfiguration("use_sim_time"),
"robot_description": Command(
["xacro ", LaunchConfiguration("urdf")]
),
}
],
),
Node(
package="joint_state_publisher",
executable="joint_state_publisher",
name="joint_state_publisher",
parameters=[{"use_sim_time": LaunchConfiguration("use_sim_time")}],
),
Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="screen",
arguments=["-d", rviz_config_path],
condition=IfCondition(LaunchConfiguration("rviz")),
parameters=[{"use_sim_time": LaunchConfiguration("use_sim_time")}],
),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,44 @@
from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import ExecuteProcess, DeclareLaunchArgument, IncludeLaunchDescription, SetEnvironmentVariable
from launch.actions import (
ExecuteProcess,
DeclareLaunchArgument,
IncludeLaunchDescription,
SetEnvironmentVariable,
)
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, Command
from launch_ros.actions import Node


def generate_launch_description():

ld = LaunchDescription()
ld = LaunchDescription()

use_sim_time = LaunchConfiguration('use_sim_time', default='True')

pkg_gazebo_ros = get_package_share_directory('gazebo_ros')
use_sim_time = LaunchConfiguration("use_sim_time", default="True")

gazebo_server = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py'))
)
pkg_gazebo_ros = get_package_share_directory("gazebo_ros")

gazebo_client = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(pkg_gazebo_ros, 'launch', 'gzclient.launch.py'))
)
gazebo_server = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_gazebo_ros, "launch", "gzserver.launch.py")
)
)

execute_process = ExecuteProcess(
cmd=['ros2', 'param', 'set', '/gazebo', 'use_sim_time', use_sim_time], output='screen')

ld.add_action(gazebo_server)
ld.add_action(gazebo_client)
ld.add_action(execute_process)
gazebo_client = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(pkg_gazebo_ros, "launch", "gzclient.launch.py")
)
)

return ld
execute_process = ExecuteProcess(
cmd=["ros2", "param", "set", "/gazebo", "use_sim_time", use_sim_time],
output="screen",
)

ld.add_action(gazebo_server)
ld.add_action(gazebo_client)
ld.add_action(execute_process)

return ld
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,67 @@
from launch_ros.actions import Node
import time


def generate_launch_description():

# In order to ensure gazebo is properly intialized
time.sleep(4.0)

# Set (x, y, z) default position of turtlebot2
x_pos = LaunchConfiguration('-x', default='0')
y_pos = LaunchConfiguration('-y', default='0')
z_pos = LaunchConfiguration('-z', default='0')

# Find Turtlebot2 package
pkg_share = launch_ros.substitutions.FindPackageShare(package='custom_robots').find('custom_robots')

# Find Urdf File
urdf_file = os.path.join(pkg_share, 'urdf/turtlebot2.urdf')

# Open Urdf file
with open(urdf_file, 'r') as info:
robot_desc = info.read()

# Robot description Turtlebot2
turtlebot2_model = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
parameters=[{'robot_description': robot_desc}],
arguments=[urdf_file]
)

# TF Tree
joint_state_publisher_node = Node(
package='joint_state_publisher',
executable='joint_state_publisher',
name='joint_state_publisher'
)

# Spawn Turtlebot2
spawn_entity_node = Node(
package='gazebo_ros',
executable='spawn_entity.py',
name='entity_spawner',
output='screen',
arguments=["-topic", "/robot_description", "-entity", "turtlebot2", "-x", x_pos, "-y", y_pos, "-z", z_pos]
)

ld = LaunchDescription()
ld.add_action(turtlebot2_model)
ld.add_action(joint_state_publisher_node)
ld.add_action(spawn_entity_node)

return ld
# In order to ensure gazebo is properly intialized
time.sleep(4.0)

# Set (x, y, z) default position of turtlebot2
x_pos = LaunchConfiguration("-x", default="0")
y_pos = LaunchConfiguration("-y", default="0")
z_pos = LaunchConfiguration("-z", default="0")

# Find Turtlebot2 package
pkg_share = launch_ros.substitutions.FindPackageShare(package="custom_robots").find(
"custom_robots"
)

# Find Urdf File
urdf_file = os.path.join(pkg_share, "urdf/turtlebot2.urdf")

# Open Urdf file
with open(urdf_file, "r") as info:
robot_desc = info.read()

# Robot description Turtlebot2
turtlebot2_model = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
parameters=[{"robot_description": robot_desc}],
arguments=[urdf_file],
)

# TF Tree
joint_state_publisher_node = Node(
package="joint_state_publisher",
executable="joint_state_publisher",
name="joint_state_publisher",
)

# Spawn Turtlebot2
spawn_entity_node = Node(
package="gazebo_ros",
executable="spawn_entity.py",
name="entity_spawner",
output="screen",
arguments=[
"-topic",
"/robot_description",
"-entity",
"turtlebot2",
"-x",
x_pos,
"-y",
y_pos,
"-z",
z_pos,
],
)

ld = LaunchDescription()
ld.add_action(turtlebot2_model)
ld.add_action(joint_state_publisher_node)
ld.add_action(spawn_entity_node)

return ld
Loading
Loading