Skip to content

Commit

Permalink
Merge pull request #147 from K3cks/virtual-building-setup
Browse files Browse the repository at this point in the history
[virtual building]: Added method to launch robots with script
  • Loading branch information
sunava authored Apr 22, 2024
2 parents b06fe58 + 65fc599 commit fa88edd
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
52 changes: 52 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,52 @@
import time
import roslaunch
import rospy
import rospkg


def launch_pr2():
"""
Method to launch PR2 on the parameter server and start the ik service
"""
# 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 start a specified launch file with given parameters.
Default location for launch files here is in the folder 'launch' inside the pycram package
: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 fa88edd

Please sign in to comment.