Professional Documents
Culture Documents
#!/usr/bin/env python
import rospy
from std_msgs.msg import Float32
from gazebo_msgs.msg import ContactsState
import math
"""
rosmsg show gazebo_msgs/ContactState
string info
string collision1_name
string collision2_name
geometry_msgs/Wrench[] wrenches
geometry_msgs/Vector3 force
float64 x
float64 y
float64 z
geometry_msgs/Vector3 torque
float64 x
float64 y
float64 z
geometry_msgs/Wrench total_wrench
geometry_msgs/Vector3 force
float64 x
float64 y
float64 z
geometry_msgs/Vector3 torque
float64 x
float64 y
float64 z
geometry_msgs/Vector3[] contact_positions
float64 x
float64 y
float64 z
geometry_msgs/Vector3[] contact_normals
float64 x
float64 y
float64 z
float64[] depths
"""
class LoadSensorInfo(object):
def __init__(self, gravity=9.81):
self.min_pressure = 0.0
self.max_pressure = 2.0
self._gravity = gravity
self.load_msg = Float32()
self.load_msg.data = 0.0
rospy.Subscriber("/loadsensor_link_contactsensor_state",
ContactsState, self.loadsensor_callback)
self._pub = rospy.Publisher('/load_sensor', Float32,
queue_size=10)
rospy.loginfo("Simulated LOAD Sensor Ready")
total_force += force_magnitude
mass = force_magnitude / self._gravity
rospy.logdebug("ForceMagnitude =" +
str(force_magnitude))
rospy.logdebug("mass =" + str(mass))
rospy.logdebug("[F=" + str(force_magnitude) +
",M=" + str(mass) + "]")
else:
# We have already added that weight
pass
else:
rospy.logdebug("NO object on top detected...")
self.load_msg.data = 0.0
self._pub.publish(self.load_msg)
if __name__ == '__main__':
rospy.init_node('loadsensor_node', anonymous=True,
log_level=rospy.INFO)
loadsensor_object = LoadSensorInfo()
rospy.spin()
Gmapping Module
<launch>
<!--
<include file="$(find
barista_description)/launch/rviz_gmapping.launch"/>
-->
</launch>
Teleop Module
<launch>
<arg name="cmd_vel_topic" default="cmd_vel_mux/input/teleop"/>
<!-- turtlebot_teleop_key already has its own built in velocity
smoother -->
<node pkg="turtlebot_teleop" type="turtlebot_teleop_key"
name="turtlebot_teleop_keyboard" output="screen">
<param name="scale_linear" value="0.5" type="double"/>
<param name="scale_angular" value="1.5" type="double"/>
<!--<remap from="turtlebot_teleop_keyboard/cmd_vel"
to="cmd_vel_mux/input/teleop"/>-->
<remap from="turtlebot_teleop_keyboard/cmd_vel" to="$(arg
cmd_vel_topic)"/>
</node>
</launch>