Skip to content
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
41 changes: 41 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM osrf/ros:foxy-desktop

# Add ubuntu user with same UID and GID as your host system, if it doesn't already exist
# Since Ubuntu 24.04, a non-root user is created by default with the name vscode and UID=1000
ARG USERNAME=ubuntu
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN if ! id -u $USER_UID >/dev/null 2>&1; then \
groupadd --gid $USER_GID $USERNAME && \
useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME; \
fi
# Add sudo support for the non-root user
RUN apt-get update && \
apt-get install -y sudo && \
echo "$USERNAME ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME

# Switch from root to user
USER $USERNAME

# Add user to video group to allow access to webcam
RUN sudo usermod --append --groups video $USERNAME

# Update all packages
RUN sudo apt update && sudo apt upgrade -y

# Install Git
RUN sudo apt install -y git

# Rosdep update
RUN rosdep update

# Source the ROS setup file
RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc

################################
## ADD ANY CUSTOM SETUP BELOW ##
################################
# Install essential simulation utilities
RUN sudo apt-get install -y ros-foxy-joint-state-publisher-gui ros-foxy-xacro \
ros-foxy-gazebo-ros-pkgs
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "foxy desktop",
"dockerFile": "Dockerfile",
"runArgs": [
"--privileged",
"--network=host"
],
"workspaceMount": "source=${localWorkspaceFolder},target=/${localWorkspaceFolderBasename},type=bind",
"workspaceFolder": "/${localWorkspaceFolderBasename}",
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.bash_history,target=/home/vscode/.bash_history,type=bind"
],
"features": {
"ghcr.io/devcontainers/features/desktop-lite": {}
},
"forwardPorts": [6080, 5901],
"portsAttributes": {
"6080": {
"label": "Desktop (Web)"
},
"5901" : {
"label": "Desktop (VNC)"
}
}
}
53 changes: 53 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.5)
project(urdf_ex)

# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

# Install launch files.
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)

# Install urdf directory
install(DIRECTORY
urdf
DESTINATION share/${PROJECT_NAME}/
)

# Install worlds directory
install(DIRECTORY
worlds
DESTINATION share/${PROJECT_NAME}/
)

ament_package()
4 changes: 4 additions & 0 deletions gazebo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/gazebo:
ros__parameters:
publish_rate: 10.0
use_sim_time: true
38 changes: 38 additions & 0 deletions gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Virtual Env
.venv

# Solutions
solution*.ipynb
85 changes: 85 additions & 0 deletions joint_state_publisher.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/joint_state_publisher:
ros__parameters:
delta: 0.0
publish_default_efforts: false
publish_default_positions: true
publish_default_velocities: false
rate: 10
robot_description: <?xml version="1.0" ?> <!-- ===================================================================================
--> <!-- | This document was autogenerated by xacro from /ros2_ws/install/urdf_ex/share/urdf_ex/urdf/robot.xacro
| --> <!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED |
--> <!-- ===================================================================================
--> <robot name="four_wheel_robot"> <!-- Material description --> <material
name="white"> <color rgba="1 1 1 1"/> </material> <material name="orange"> <color
rgba="1 0.3 0.1 1"/> </material> <material name="blue"> <color rgba="0.2 0.2
1 1"/> </material> <material name="black"> <color rgba="0 0 0 1"/> </material>
<material name="red"> <color rgba="1 0 0 1"/> </material> <!-- Comment out the
gazebo include for now --> <!-- <xacro:include filename="/ros2_ws/src/urdf_ex/urdf/robot.gazebo"/>
--> <!-- Dummy link --> <link name="base_link"/> <!-- Body link --> <link name="body_link">
<visual> <geometry> <box size="1 0.6 0.3"/> </geometry> <origin rpy="0 0 3.141592653589793"
xyz="0 0 0"/> </visual> <collision> <geometry> <box size="1 0.6 0.3"/> </geometry>
<origin rpy="0 0 3.141592653589793" xyz="0 0 0"/> </collision> <inertial> <origin
rpy="0 0 3.141592653589793" xyz="0 0 0"/> <mass value="487.79999999999995"/>
<inertia ixx="18.292499999999993" ixy="0" ixz="0" iyy="44.308499999999995" iyz="0"
izz="55.283999999999985"/> </inertial> </link> <!-- Fixed joint between dummy
and body --> <joint name="base_joint" type="fixed"> <parent link="base_link"/>
<child link="body_link"/> <origin xyz="0 0 0.25"/> </joint> <link name="rear_right_wheel">
<visual> <geometry> <cylinder length="0.1" radius="0.15"/> </geometry> <origin
rpy="0 0 0" xyz="0 0 0"/> <material name="blue"/> </visual> <collision> <geometry>
<cylinder length="0.1" radius="0.15"/> </geometry> <origin rpy="0 0 0" xyz="0
0 0"/> </collision> <inertial> <origin rpy="0 0 0" xyz="0 0 0"/> <mass value="19.155861183375002"/>
<inertia ixx="0.12371493680929685" ixy="0" ixz="0" iyy="0.12371493680929685"
iyz="0" izz="0.21550343831296875"/> </inertial> </link> <joint name="rear_right_wheel_joint"
type="continuous"> <parent link="body_link"/> <child link="rear_right_wheel"/>
<origin rpy="1.5707963267948966 0 0" xyz="-0.32 -0.36 -0.1"/> <axis xyz="0 0
-1"/> <limit effort="1000" velocity="1000"/> <dynamics damping="1.0" friction="1.0"/>
</joint> <link name="rear_left_wheel"> <visual> <geometry> <cylinder length="0.1"
radius="0.15"/> </geometry> <origin rpy="0 0 0" xyz="0 0 0"/> <material name="blue"/>
</visual> <collision> <geometry> <cylinder length="0.1" radius="0.15"/> </geometry>
<origin rpy="0 0 0" xyz="0 0 0"/> </collision> <inertial> <origin rpy="0 0 0"
xyz="0 0 0"/> <mass value="19.155861183375002"/> <inertia ixx="0.12371493680929685"
ixy="0" ixz="0" iyy="0.12371493680929685" iyz="0" izz="0.21550343831296875"/>
</inertial> </link> <joint name="rear_left_wheel_joint" type="continuous"> <parent
link="body_link"/> <child link="rear_left_wheel"/> <origin rpy="-1.5707963267948966
0 0" xyz="-0.32 0.36 -0.1"/> <axis xyz="0 0 1"/> <limit effort="1000" velocity="1000"/>
<dynamics damping="1.0" friction="1.0"/> </joint> <link name="front_right_wheel">
<visual> <geometry> <cylinder length="0.1" radius="0.15"/> </geometry> <origin
rpy="0 0 0" xyz="0 0 0"/> <material name="blue"/> </visual> <collision> <geometry>
<cylinder length="0.1" radius="0.15"/> </geometry> <origin rpy="0 0 0" xyz="0
0 0"/> </collision> <inertial> <origin rpy="0 0 0" xyz="0 0 0"/> <mass value="19.155861183375002"/>
<inertia ixx="0.12371493680929685" ixy="0" ixz="0" iyy="0.12371493680929685"
iyz="0" izz="0.21550343831296875"/> </inertial> </link> <joint name="front_right_wheel_joint"
type="continuous"> <parent link="body_link"/> <child link="front_right_wheel"/>
<origin rpy="1.5707963267948966 0 0" xyz="0.32 -0.36 -0.1"/> <axis xyz="0 0
-1"/> <limit effort="1000" velocity="1000"/> <dynamics damping="1.0" friction="1.0"/>
</joint> <link name="front_left_wheel"> <visual> <geometry> <cylinder length="0.1"
radius="0.15"/> </geometry> <origin rpy="0 0 0" xyz="0 0 0"/> <material name="blue"/>
</visual> <collision> <geometry> <cylinder length="0.1" radius="0.15"/> </geometry>
<origin rpy="0 0 0" xyz="0 0 0"/> </collision> <inertial> <origin rpy="0 0 0"
xyz="0 0 0"/> <mass value="19.155861183375002"/> <inertia ixx="0.12371493680929685"
ixy="0" ixz="0" iyy="0.12371493680929685" iyz="0" izz="0.21550343831296875"/>
</inertial> </link> <joint name="front_left_wheel_joint" type="continuous">
<parent link="body_link"/> <child link="front_left_wheel"/> <origin rpy="-1.5707963267948966
0 0" xyz="0.32 0.36 -0.1"/> <axis xyz="0 0 1"/> <limit effort="1000" velocity="1000"/>
<dynamics damping="1.0" friction="1.0"/> </joint> <!-- Camera --> <link name="camera_link">
<visual> <origin xyz="0 0 0"/> <geometry> <cylinder length="0.05" radius="0.0125"/>
</geometry> <material name="black"/> </visual> <visual> <geometry> <box size="0.05
0.05 0.05"/> </geometry> <origin rpy="0 0 0" xyz="0 0 0.05"/> </visual> <collision>
<geometry> <box size="0.05 0.05 0.05"/> </geometry> <origin rpy="0 0 0" xyz="0
0 0"/> </collision> <inertial> <origin rpy="0 0 0" xyz="0 0 0"/> <mass value="0.5"/>
<inertia ixx="1e-6" ixy="0.0" ixz="0.0" iyy="1e-6" iyz="0.0" izz="1e-6"/> </inertial>
</link> <joint name="camera_joint" type="fixed"> <parent link="body_link"/>
<child link="camera_link"/> <origin xyz="-0.25 0 0.175"/> <axis xyz="0 1 0"/>
</joint> <!-- Sonar --> <link name="sonar_link"> <visual> <geometry> <box size="0.05
0.1 0.05"/> </geometry> <origin rpy="0 0 0" xyz="0 0 0.025"/> <material name="black"/>
</visual> <visual> <geometry> <box size="0.025 0.025 0.05"/> </geometry> <origin
rpy="0 0 0" xyz="0 0 0"/> <material name="black"/> </visual> <collision> <geometry>
<box size="0.05 0.05 0.05"/> </geometry> <origin rpy="0 0 0" xyz="0 0 0"/> </collision>
<inertial> <origin rpy="0 0 0" xyz="0 0 0"/> <mass value="0.5"/> <inertia ixx="1e-6"
ixy="0.0" ixz="0.0" iyy="1e-6" iyz="0.0" izz="1e-6"/> </inertial> </link> <joint
name="sonar_joint" type="fixed"> <parent link="body_link"/> <child link="sonar_link"/>
<origin xyz="0.4875 0 0.175"/> <axis xyz="0 1 0"/> </joint> </robot>
source_list: []
use_mimic_tags: true
use_sim_time: false
use_smallest_joint_limits: true
116 changes: 58 additions & 58 deletions launch/simulation.launch.py
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription, ExecuteProcess
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.actions import Node
from launch.substitutions import FindExecutable, PathJoinSubstitution
from launch.substitutions import Command, PathJoinSubstitution
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
pkg_name = FindPackageShare("pkg_name")
pkg_name = FindPackageShare("urdf_ex")

# Robot description using xacro
robot_description = Command([
"xacro ",
PathJoinSubstitution([pkg_name, "urdf", "robot.xacro"])
])

return LaunchDescription([
# Load Gazebo world
IncludeLaunchDescription(
PythonLaunchDescriptionSource([
PathJoinSubstitution([
FindPackageShare("gazebo_ros"),
"launch",
"gazebo.launch.py",
])
]),
launch_arguments={
"world": PathJoinSubstitution([pkg_name, "worlds", "four_walls.world"]),
"paused": "false",
"use_sim_time": "true",
"gui": "true",
"headless": "false",
"debug": "false",
}.items(),
),

# Robot state publisher
Node(
package="robot_state_publisher",
executable="robot_state_publisher",
name="robot_state_publisher",
output="screen",
parameters=[{"robot_description": robot_description}]
),

# Xacro command to generate URDF
xacro_command = [
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution([pkg_name, "urdf", "robot.xacro"]),
]
# Joint state publisher
Node(
package="joint_state_publisher",
executable="joint_state_publisher",
name="joint_state_publisher",
output="screen",
parameters=[{"robot_description": robot_description}]
),

return LaunchDescription(
[
# TODO: Create the control node
# Node
# Load Gazebo world
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
PathJoinSubstitution(
[
FindPackageShare("gazebo_ros"),
"launch",
"gazebo.launch.py",
]
)
]
),
# TODO: Provide the correct values for the argumentsarguments
launch_arguments={
"world": PathJoinSubstitution(
[pkg_name, "worlds", "four_walls.world"]
),
"paused": "TODO: Provide the correct value",
"use_sim_time": "TODO: Provide the correct value",
"gui": "TODO: Provide the correct value",
"headless": "TODO: Provide the correct value",
"debug": "TODO: Provide the correct value",
}.items(),
),
# Robot description parameter
ExecuteProcess(
cmd=[
"ros2",
"param",
"set",
"/robot_state_publisher",
"robot_description",
PathJoinSubstitution([FindExecutable(name="xacro")]),
PathJoinSubstitution([pkg_name, "urdf", "robot.xacro"]),
],
shell=True,
),
# TODO: Create the robot state publisher node
# Robot state publisher
# TODO: Spawn the robot in Gazebo
# Spawn robot in Gazebo
]
)
# Spawn robot in Gazebo
Node(
package="gazebo_ros",
executable="spawn_entity.py",
name="spawn_entity",
output="screen",
arguments=[
"-topic", "robot_description",
"-entity", "robot",
],
),
])
18 changes: 18 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>urdf_ex</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="yutharsansivabalan@gmail.com">ubuntu</maintainer>
<license>TODO: License declaration</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading