Skip to content

Commit af75e0e

Browse files
dtbpkmteNhiNguyencmt8
authored andcommitted
Add cartpole URDF and gazebo
1 parent 4f4fa9a commit af75e0e

18 files changed

+1074
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(cartpole_description)
3+
4+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5+
add_compile_options(-Wall -Wextra -Wpedantic)
6+
endif()
7+
8+
# find dependencies
9+
find_package(ament_cmake REQUIRED)
10+
# uncomment the following section in order to fill in
11+
# further dependencies manually.
12+
# find_package(<dependency> REQUIRED)
13+
14+
install(DIRECTORY launch urdf config meshes
15+
DESTINATION share/${PROJECT_NAME})
16+
17+
ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/env-hooks/${PROJECT_NAME}.dsv.in")
18+
19+
if(BUILD_TESTING)
20+
find_package(ament_lint_auto REQUIRED)
21+
# the following line skips the linter which checks for copyrights
22+
# comment the line when a copyright and license is added to all source files
23+
set(ament_cmake_copyright_FOUND TRUE)
24+
# the following line skips cpplint (only works in a git repo)
25+
# comment the line when this package is in a git repo and when
26+
# a copyright and license is added to all source files
27+
set(ament_cmake_cpplint_FOUND TRUE)
28+
ament_lint_auto_find_test_dependencies()
29+
endif()
30+
31+
ament_package()

ros2/src/cartpole_description/LICENSE

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Permission is hereby granted, free of charge, to any person obtaining a copy
2+
of this software and associated documentation files (the "Software"), to deal
3+
in the Software without restriction, including without limitation the rights
4+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5+
copies of the Software, and to permit persons to whom the Software is
6+
furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in
9+
all copies or substantial portions of the Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
14+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17+
THE SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
Panels:
2+
- Class: rviz_common/Displays
3+
Help Height: 78
4+
Name: Displays
5+
Property Tree Widget:
6+
Expanded:
7+
- /Global Options1
8+
- /Status1
9+
- /RobotModel1
10+
- /RobotModel1/Description Topic1
11+
Splitter Ratio: 0.5
12+
Tree Height: 549
13+
- Class: rviz_common/Selection
14+
Name: Selection
15+
- Class: rviz_common/Tool Properties
16+
Expanded:
17+
- /2D Goal Pose1
18+
- /Publish Point1
19+
Name: Tool Properties
20+
Splitter Ratio: 0.5886790156364441
21+
- Class: rviz_common/Views
22+
Expanded:
23+
- /Current View1
24+
Name: Views
25+
Splitter Ratio: 0.5
26+
- Class: rviz_common/Time
27+
Experimental: false
28+
Name: Time
29+
SyncMode: 0
30+
SyncSource: ""
31+
Visualization Manager:
32+
Class: ""
33+
Displays:
34+
- Alpha: 0.5
35+
Cell Size: 1
36+
Class: rviz_default_plugins/Grid
37+
Color: 160; 160; 164
38+
Enabled: true
39+
Line Style:
40+
Line Width: 0.029999999329447746
41+
Value: Lines
42+
Name: Grid
43+
Normal Cell Count: 0
44+
Offset:
45+
X: 0
46+
Y: 0
47+
Z: 0
48+
Plane: XY
49+
Plane Cell Count: 10
50+
Reference Frame: <Fixed Frame>
51+
Value: true
52+
- Alpha: 1
53+
Class: rviz_default_plugins/RobotModel
54+
Collision Enabled: false
55+
Description File: ""
56+
Description Source: Topic
57+
Description Topic:
58+
Depth: 5
59+
Durability Policy: Volatile
60+
History Policy: Keep Last
61+
Reliability Policy: Reliable
62+
Value: /robot_description
63+
Enabled: true
64+
Links:
65+
All Links Enabled: true
66+
Expand Joint Details: false
67+
Expand Link Details: false
68+
Expand Tree: false
69+
Link Tree Style: Links in Alphabetic Order
70+
cart:
71+
Alpha: 1
72+
Show Axes: false
73+
Show Trail: false
74+
Value: true
75+
pole:
76+
Alpha: 1
77+
Show Axes: false
78+
Show Trail: false
79+
Value: true
80+
world:
81+
Alpha: 1
82+
Show Axes: false
83+
Show Trail: false
84+
Value: true
85+
Mass Properties:
86+
Inertia: false
87+
Mass: false
88+
Name: RobotModel
89+
TF Prefix: ""
90+
Update Interval: 0
91+
Value: true
92+
Visual Enabled: true
93+
Enabled: true
94+
Global Options:
95+
Background Color: 48; 48; 48
96+
Fixed Frame: world
97+
Frame Rate: 30
98+
Name: root
99+
Tools:
100+
- Class: rviz_default_plugins/Interact
101+
Hide Inactive Objects: true
102+
- Class: rviz_default_plugins/MoveCamera
103+
- Class: rviz_default_plugins/Select
104+
- Class: rviz_default_plugins/FocusCamera
105+
- Class: rviz_default_plugins/Measure
106+
Line color: 128; 128; 0
107+
- Class: rviz_default_plugins/SetInitialPose
108+
Covariance x: 0.25
109+
Covariance y: 0.25
110+
Covariance yaw: 0.06853891909122467
111+
Topic:
112+
Depth: 5
113+
Durability Policy: Volatile
114+
History Policy: Keep Last
115+
Reliability Policy: Reliable
116+
Value: /initialpose
117+
- Class: rviz_default_plugins/SetGoal
118+
Topic:
119+
Depth: 5
120+
Durability Policy: Volatile
121+
History Policy: Keep Last
122+
Reliability Policy: Reliable
123+
Value: /goal_pose
124+
- Class: rviz_default_plugins/PublishPoint
125+
Single click: true
126+
Topic:
127+
Depth: 5
128+
Durability Policy: Volatile
129+
History Policy: Keep Last
130+
Reliability Policy: Reliable
131+
Value: /clicked_point
132+
Transformation:
133+
Current:
134+
Class: rviz_default_plugins/TF
135+
Value: true
136+
Views:
137+
Current:
138+
Class: rviz_default_plugins/Orbit
139+
Distance: 6.897698879241943
140+
Enable Stereo Rendering:
141+
Stereo Eye Separation: 0.05999999865889549
142+
Stereo Focal Distance: 1
143+
Swap Stereo Eyes: false
144+
Value: false
145+
Focal Point:
146+
X: 0
147+
Y: 0
148+
Z: 0
149+
Focal Shape Fixed Size: true
150+
Focal Shape Size: 0.05000000074505806
151+
Invert Z Axis: false
152+
Name: Current View
153+
Near Clip Distance: 0.009999999776482582
154+
Pitch: 0.19039809703826904
155+
Target Frame: <Fixed Frame>
156+
Value: Orbit (rviz)
157+
Yaw: 0.7553979158401489
158+
Saved: ~
159+
Window Geometry:
160+
Displays:
161+
collapsed: false
162+
Height: 846
163+
Hide Left Dock: false
164+
Hide Right Dock: false
165+
QMainWindow State: 000000ff00000000fd000000040000000000000156000002b0fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d000002b0000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002b0fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d000002b0000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004b00000003efc0100000002fb0000000800540069006d00650100000000000004b0000002fb00fffffffb0000000800540069006d006501000000000000045000000000000000000000023f000002b000000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
166+
Selection:
167+
collapsed: false
168+
Time:
169+
collapsed: false
170+
Tool Properties:
171+
collapsed: false
172+
Views:
173+
collapsed: false
174+
Width: 1200
175+
X: 70
176+
Y: 60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
prepend-non-duplicate;GAZEBO_MODEL_PATH;share
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Copyright 2021 Stogl Robotics Consulting UG (haftungsbeschränkt)
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# Copyright 2023 HURON Project
16+
17+
import os
18+
from ament_index_python.packages import get_package_share_directory
19+
from launch import LaunchDescription
20+
from launch.actions import DeclareLaunchArgument
21+
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
22+
23+
from launch_ros.actions import Node
24+
from launch_ros.substitutions import FindPackageShare
25+
26+
27+
def generate_launch_description():
28+
# Declare arguments
29+
declared_arguments = []
30+
declared_arguments.append(
31+
DeclareLaunchArgument(
32+
"description_package",
33+
default_value="cartpole_description",
34+
description="Description package with robot URDF/xacro files. Usually the argument \
35+
is not set, it enables use of a custom description.",
36+
)
37+
)
38+
declared_arguments.append(
39+
DeclareLaunchArgument(
40+
"description_file",
41+
default_value="cartpole.urdf",
42+
description="URDF/XACRO description file with the robot.",
43+
)
44+
)
45+
declared_arguments.append(
46+
DeclareLaunchArgument(
47+
"prefix",
48+
default_value='""',
49+
description="Prefix of the joint names, useful for \
50+
multi-robot setup. If changed than also joint names in the controllers' configuration \
51+
have to be updated.",
52+
)
53+
)
54+
55+
# Initialize Arguments
56+
description_package = LaunchConfiguration("description_package")
57+
description_file = LaunchConfiguration("description_file")
58+
prefix = LaunchConfiguration("prefix")
59+
60+
# Load URDF
61+
urdf_file_name = 'cartpole.urdf'
62+
urdf = os.path.join(
63+
get_package_share_directory('cartpole_description'),
64+
'urdf',
65+
urdf_file_name)
66+
with open(urdf, 'r') as infp:
67+
robot_desc = infp.read()
68+
robot_description = {"robot_description": robot_desc}
69+
70+
# rviz_config_file = PathJoinSubstitution(
71+
# [FindPackageShare(description_package), "config", "huron.rviz"]
72+
# )
73+
74+
joint_state_publisher_node = Node(
75+
package="joint_state_publisher_gui",
76+
executable="joint_state_publisher_gui",
77+
)
78+
robot_state_publisher_node = Node(
79+
package="robot_state_publisher",
80+
executable="robot_state_publisher",
81+
output="both",
82+
parameters=[robot_description],
83+
arguments=[urdf]
84+
)
85+
rviz_node = Node(
86+
package="rviz2",
87+
executable="rviz2",
88+
name="rviz2",
89+
output="log",
90+
# arguments=["-d", rviz_config_file],
91+
)
92+
93+
nodes = [
94+
joint_state_publisher_node,
95+
robot_state_publisher_node,
96+
rviz_node,
97+
]
98+
99+
return LaunchDescription(declared_arguments + nodes)
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>cartpole_description</name>
5+
<version>0.0.0</version>
6+
<description>TODO: Package description</description>
7+
<maintainer email="[email protected]">duk3</maintainer>
8+
<license>MIT</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
12+
<test_depend>ament_lint_auto</test_depend>
13+
<test_depend>ament_lint_common</test_depend>
14+
15+
<export>
16+
<build_type>ament_cmake</build_type>
17+
</export>
18+
</package>

0 commit comments

Comments
 (0)