Created
July 24, 2019 15:41
-
-
Save Mozyanari/1cf83766b6b352d097df8f916851d9e5 to your computer and use it in GitHub Desktop.
servo.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ros/ros.h> | |
#include <pigpiod_if2.h> | |
#include <std_msgs/Bool.h> | |
int main(int argc, char** argv){ | |
ros::init(argc, argv, "servo"); | |
ros::NodeHandle n; | |
int pi; | |
pi = pigpio_start(NULL,NULL); | |
int i = 0; | |
ros::Rate rate(1); | |
set_servo_pulsewidth(pi,26,1500); | |
while(ros::ok()){ | |
if(i == 0){ | |
set_servo_pulsewidth(pi,26,1400); | |
i = 1; | |
}else{ | |
set_servo_pulsewidth(pi,26,1600); | |
i = 0; | |
} | |
ROS_INFO("%d",i); | |
ros::spinOnce(); | |
rate.sleep(); | |
} | |
set_servo_pulsewidth(pi,26,0); | |
return 0; | |
} | |
© 2019 GitHub, Inc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment