Revision 08be08ec
Ran astyle, though astyle options still need to be refined
buggysim/tutorials/mimic.cpp | ||
---|---|---|
5 | 5 |
class Mimic |
6 | 6 |
{ |
7 | 7 |
public: |
8 |
Mimic(); |
|
8 |
Mimic();
|
|
9 | 9 |
|
10 | 10 |
private: |
11 |
void poseCallback(const turtlesim::PoseConstPtr& pose); |
|
11 |
void poseCallback(const turtlesim::PoseConstPtr& pose);
|
|
12 | 12 |
|
13 |
ros::Publisher vel_pub_; |
|
14 |
ros::Subscriber pose_sub_; |
|
13 |
ros::Publisher vel_pub_;
|
|
14 |
ros::Subscriber pose_sub_;
|
|
15 | 15 |
}; |
16 | 16 |
|
17 | 17 |
Mimic::Mimic() |
18 | 18 |
{ |
19 |
ros::NodeHandle input_nh("input"); |
|
20 |
ros::NodeHandle output_nh("output"); |
|
21 |
vel_pub_ = output_nh.advertise<turtlesim::Velocity>("command_velocity", 1); |
|
22 |
pose_sub_ = input_nh.subscribe<turtlesim::Pose>("pose", 1, &Mimic::poseCallback, this); |
|
19 |
ros::NodeHandle input_nh("input"); |
|
20 |
ros::NodeHandle output_nh("output"); |
|
21 |
vel_pub_ = output_nh.advertise<turtlesim::Velocity>("command_velocity", 1); |
|
22 |
pose_sub_ = input_nh.subscribe<turtlesim::Pose>("pose", 1, &Mimic::poseCallback, |
|
23 |
this); |
|
23 | 24 |
} |
24 | 25 |
|
25 | 26 |
void Mimic::poseCallback(const turtlesim::PoseConstPtr& pose) |
26 | 27 |
{ |
27 |
turtlesim::Velocity vel; |
|
28 |
vel.angular = pose->angular_velocity; |
|
29 |
vel.linear = pose->linear_velocity; |
|
30 |
vel_pub_.publish(vel); |
|
28 |
turtlesim::Velocity vel;
|
|
29 |
vel.angular = pose->angular_velocity;
|
|
30 |
vel.linear = pose->linear_velocity;
|
|
31 |
vel_pub_.publish(vel);
|
|
31 | 32 |
} |
32 | 33 |
|
33 | 34 |
int main(int argc, char** argv) |
34 | 35 |
{ |
35 |
ros::init(argc, argv, "turtle_mimic"); |
|
36 |
Mimic mimic; |
|
36 |
ros::init(argc, argv, "turtle_mimic");
|
|
37 |
Mimic mimic;
|
|
37 | 38 |
|
38 |
ros::spin(); |
|
39 |
ros::spin();
|
|
39 | 40 |
} |
40 | 41 |
|
Also available in: Unified diff