Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ros.h>
- #include <std_msgs/Float64.h>
- const int pot_pin = A0;
- int posicao = 0, sensor = 0;
- ros::NodeHandle nh;
- std_msgs::Float64 posi;
- //std_msgs::Float64 corr;
- //void contr_callback(const std_msgs::Float64& msg){
- // termo_pd_escalonado = msg.data;
- //}
- //ros::Subscriber<std_msgs::Float64> sc("controle", &contr_callback);
- //ros::Subscriber<std_msgs::Float64> ss("setpt", &setpoint_callback);
- ros::Publisher p("posicao_mestre", &posi);
- //ros::Publisher c("corrente_mestre", &corr);
- void setup() {
- nh.initNode();
- nh.advertise(p);
- }
- void loop() {
- sensor = analogRead(pot_pin);
- posicao = map(sensor, 0, 1023, 0, 180);
- posi.data = posicao;
- p.publish( &posi );
- nh.spinOnce();
- delay(20);
- }
Advertisement
Add Comment
Please, Sign In to add comment