Skip to content

Commit

Permalink
virtual building: added method to launch PR2 by script
Browse files Browse the repository at this point in the history
  • Loading branch information
kecks committed Apr 22, 2024
1 parent bd718a2 commit 109edf5
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
51 changes: 51 additions & 0 deletions demos/pycram_virtual_building_demos/setup/launch_robot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import time
import roslaunch
import rospy
import rospkg


def launch_pr2():
"""
Method to launch PR2
"""
# name = 'pr2'
# urdf = 'pr2.urdf'
executable = 'pr2_standalone.launch'
launch_robot(executable)


# For future work / robots
# def launch_hsrb():
# # name = 'hsrb'
# # urdf = 'hsrb.urdf'
# executable = 'hsrb_standalone.launch'
# launch_robot(executable)


# def launch_armar6():
# # name = 'armar6'
# # urdf = 'armar6.urdf'
# executable = 'armar6_standalone.launch'
# launch_robot(executable)


def launch_robot(launch_file, package='pycram', launch_folder='/launch/'):
"""
General method to launch a specified file in given parameters
:param launch_file: File name of the launch file
:param package: Name of the package
:param launch_folder: Location of the launch file inside the package
"""

rospath = rospkg.RosPack()

uuid = roslaunch.rlutil.get_or_generate_uuid(None, False)
roslaunch.configure_logging(uuid)
launch = roslaunch.parent.ROSLaunchParent(uuid, [rospath.get_path(package) + launch_folder + launch_file])
launch.start()

rospy.loginfo(f'{launch_file} started')

# Wait for ik server to launch
time.sleep(2)
26 changes: 26 additions & 0 deletions launch/pr2_standalone.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<launch>
<arg name="use_knowrob" default="false"/>

<node pkg="kdl_ik_service" type="start_ros_server.py" name="kdl_ik_service" output="screen" />

<!-- PR2 URDF -->
<include file="$(find pr2_arm_kinematics)/launch/pr2_ik_larm_node.launch"/>
<include file="$(find pr2_arm_kinematics)/launch/pr2_ik_rarm_node.launch"/>
<param name="robot_description"
textfile="$(find pycram)/resources/pr2.urdf"/>


<!-- Use Knowrob -->
<group if="$(eval use_knowrob)">
<include file="$(find knowrob)/launch/knowrob.launch"/>
</group>

<!--
In ROS Noetic the xacro file for boxy doesnt seem to work, as a quick fix use the line above
<include file="$(find iai_boxy_description)/launch/upload_boxy.launch" />
-->
<!--
<include file="$(find rosbridge_server)/launch/rosbridge_websocket.launch"/>
-->

</launch>

0 comments on commit 109edf5

Please sign in to comment.