def set_tilt_profile(position, time_from_start): cmd = LaserTrajCmd() cmd.profile = 'blended_linear' cmd.position = position cmd.time_from_start = [rospy.Time.from_sec(x) for x in time_from_start] cmd.max_velocity = 10 cmd.max_acceleration = 30 try: tilt_profile_client.call(cmd) except rospy.ServiceException, e: rospy.logerr("Couldn't set the profile on the laser. Exception %s" % e) return False
from pr2_msgs.srv import * from time import sleep def print_usage(exit_code=0): print '''Usage: send_periodic_cmd.py [controller] ''' sys.exit(exit_code) if __name__ == '__main__': if len(sys.argv) < 2: print_usage() cmd = LaserTrajCmd() controller = sys.argv[1] cmd.header = rospy.Header(None, None, None) cmd.profile = "blended_linear" cycle_time = rospy.get_param('~cycle_time', 5.0) min_tilt_angle = rospy.get_param('~min_tilt_angle', -0.7) max_tilt_angle = rospy.get_param('~max_tilt_angle', 1.0) cmd.position = [min_tilt_angle, max_tilt_angle, min_tilt_angle] cmd.time_from_start = [0.0, cycle_time - 1.0, cycle_time] cmd.time_from_start = [ rospy.Duration.from_sec(x) for x in cmd.time_from_start ] cmd.max_velocity = 10 cmd.max_acceleration = 30