VEXProServoSubscribe.cpp
Go to the documentation of this file.
1 /*
2  * VEXProServoSubscribe.cpp
3  *
4  * Created on: Jul 12, 2012
5  * Author: bouchier
6  * Drives a servo or motor on VEXPro motor1 connection to the requested value: 0 - 255
7  * that is received on subscribed topic servo1
8  */
9 
10 #include <ros.h>
11 #include <std_msgs/Int32.h>
12 #include <iostream>
13 #include <qeservo.h>
14 using namespace std;
15 
17 CQEServo &servo = CQEServo::GetRef();
18 char *rosSrvrIp = "192.168.15.149";
19 
20 void messageCb(const std_msgs::Int32& servo1_msg){
21  int position = servo1_msg.data;
22  printf("Received subscribed servo position %d\n", position);
23  servo.SetCommand(0, position);
24 }
26 
27 int main() {
28  //nh.initNode();
29  nh.initNode(rosSrvrIp);
30  nh.subscribe(sub);
31 
32  while(1) {
33  sleep(1);
34  nh.spinOnce();
35  }
36 }
ros::NodeHandle nh
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
int main()
char * rosSrvrIp
ros::Subscriber< std_msgs::Int32 > sub("servo1", messageCb)
void messageCb(const std_msgs::Int32 &servo1_msg)
CQEServo & servo


rosserial_embeddedlinux
Author(s): Paul Bouchier
autogenerated on Mon Jun 10 2019 14:53:23