-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path485_test.cpp
82 lines (69 loc) · 2.01 KB
/
485_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "ros/ros.h"
#include "std_msgs/String.h"
#include <sstream>
#include <iostream>
#include <tf/transform_broadcaster.h>
double count1 = 0.0;
double count2 = 0.0;
double count3 = 0.0;
double count4 = 0.0;
double count5 = 0.0;
double count6 = 0.0;
double count7 = 0.0;
double count8 = 0.0;
ros::Publisher chatter_pub1;
ros::Publisher chatter_pub2;
ros::Publisher chatter_pub3;
ros::Publisher chatter_pub4;
ros::Publisher chatter_pub5;
ros::Publisher chatter_pub6;
ros::Publisher chatter_pub7;
ros::Publisher chatter_pub8;
int main(int argc, char **argv)
{
ros::init(argc, argv, "serial_test");
ros::NodeHandle n;
chatter_pub1 = n.advertise<geometry_msgs::Vector3>("cmd1", 1000);
chatter_pub2 = n.advertise<geometry_msgs::Vector3>("cmd2", 1000);
chatter_pub3 = n.advertise<geometry_msgs::Vector3>("cmd3", 1000);
chatter_pub4 = n.advertise<geometry_msgs::Vector3>("cmd4", 1000);
chatter_pub5 = n.advertise<geometry_msgs::Vector3>("cmd5", 1000);
chatter_pub6 = n.advertise<geometry_msgs::Vector3>("cmd6", 1000);
chatter_pub7 = n.advertise<geometry_msgs::Vector3>("cmd7", 1000);
chatter_pub8 = n.advertise<geometry_msgs::Vector3>("cmd8", 1000);
ros::Rate loop_rate(10);
while (ros::ok())
{
if (count1<=10)
{
geometry_msgs::Vector3 vector3;
vector3.x=count1;
chatter_pub1.publish(vector3);
vector3.x=count2;
chatter_pub2.publish(vector3);
vector3.x=count3;
chatter_pub3.publish(vector3);
vector3.x=count4;
chatter_pub4.publish(vector3);
vector3.x=count5;
chatter_pub5.publish(vector3);
vector3.x=count6;
chatter_pub6.publish(vector3);
vector3.x=count7;
chatter_pub7.publish(vector3);
vector3.x=count8;
chatter_pub8.publish(vector3);
ros::spinOnce();
loop_rate.sleep();
count1=count1+0.001;
count2=count2+0.001;
count3=count3+0.001;
count4=count4+0.001;
count5=count5+0.001;
count6=count6+0.001;
count7=count7+0.001;
count8=count8+0.001;
}
}
return 0;
}