6 from costmap_converter.msg
import ObstacleArrayMsg, ObstacleMsg
7 from geometry_msgs.msg
import PolygonStamped, Point32, QuaternionStamped, Quaternion, TwistWithCovariance
8 from tf.transformations
import quaternion_from_euler
12 pub = rospy.Publisher(
'/test_optim_node/obstacles', ObstacleArrayMsg, queue_size=1)
14 rospy.init_node(
"test_obstacle_msg")
21 obstacle_msg = ObstacleArrayMsg()
22 obstacle_msg.header.stamp = rospy.Time.now()
23 obstacle_msg.header.frame_id =
"map" 26 obstacle_msg.obstacles.append(ObstacleMsg())
27 obstacle_msg.obstacles[0].id = 99
28 obstacle_msg.obstacles[0].polygon.points = [Point32()]
29 obstacle_msg.obstacles[0].polygon.points[0].x = -1.5
30 obstacle_msg.obstacles[0].polygon.points[0].y = 0
31 obstacle_msg.obstacles[0].polygon.points[0].z = 0
33 yaw = math.atan2(vel_y, vel_x)
34 q = tf.transformations.quaternion_from_euler(0,0,yaw)
35 obstacle_msg.obstacles[0].orientation = Quaternion(*q)
37 obstacle_msg.obstacles[0].velocities.twist.linear.x = vel_x
38 obstacle_msg.obstacles[0].velocities.twist.linear.y = vel_y
39 obstacle_msg.obstacles[0].velocities.twist.linear.z = 0
40 obstacle_msg.obstacles[0].velocities.twist.angular.x = 0
41 obstacle_msg.obstacles[0].velocities.twist.angular.y = 0
42 obstacle_msg.obstacles[0].velocities.twist.angular.z = 0
46 while not rospy.is_shutdown():
50 obstacle_msg.obstacles[0].polygon.points[0].y = y_0 + (vel_y*t)%range_y
52 obstacle_msg.obstacles[0].polygon.points[0].y = y_0 + (vel_y*t)%range_y - range_y
56 pub.publish(obstacle_msg)
62 if __name__ ==
'__main__':
65 except rospy.ROSInterruptException:
def publish_obstacle_msg()