3 #include <std_msgs/Float32.h>
4 #include <std_msgs/Bool.h>
5 #include <visualization_msgs/Marker.h>
9 void rvizUpdater(
const std_msgs::Float32::ConstPtr&);
10 void shutdown(
const std_msgs::Bool::ConstPtr&);
24 int main(
int argc,
char **argv){
28 ros::Subscriber subscriber = n.subscribe(
"phidget_value", 1000,
rvizUpdater);
29 ros::Subscriber sd = n.subscribe(
"shutdown", 1,
shutdown);
30 cylinder_pub = n.advertise<visualization_msgs::Marker>(
"visualization_marker", 1);
47 void rvizUpdater(
const std_msgs::Float32::ConstPtr& msg){
48 const double diameter = 0.06, height=0.1;;
51 ROS_INFO(
"rziv distance: %f", distance);
53 visualization_msgs::Marker marker;
54 marker.header.frame_id =
"base";
55 marker.header.stamp = ros::Time::now();
56 marker.ns=
"shape_cylinder";
58 marker.type = visualization_msgs::Marker::CYLINDER;
61 marker.action = visualization_msgs::Marker::DELETE;
67 marker.action = visualization_msgs::Marker::ADD;
71 marker.pose.position.x = 0;
72 marker.pose.position.y = -distance/100;
73 marker.pose.position.z = height/2-0.02;
75 marker.pose.orientation.x = 0.0;
76 marker.pose.orientation.y = 0.0;
77 marker.pose.orientation.z = 0.0;
78 marker.pose.orientation.w = 1.0;
80 marker.scale.x = diameter;
81 marker.scale.y = diameter;
82 marker.scale.z = height;
84 marker.color.r = 0.0f;
85 marker.color.g = 1.0f;
86 marker.color.b = 0.0f;
89 marker.lifetime = ros::Duration();
101 void shutdown(
const std_msgs::Bool::ConstPtr& b){