Last active
July 23, 2024 19:43
-
-
Save umhan35/f7dfd3ae935af0c849e1338a62c2f3e6 to your computer and use it in GitHub Desktop.
Revisions
-
umhan35 revised this gist
Jul 23, 2024 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,11 +4,12 @@ ros::NodeHandle nh; bool messageCb(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res) { digitalWrite(LED_BUILTIN, HIGH-digitalRead(LED_BUILTIN)); // blink the led nh.loginfo("LED is ON"); return true; } ros::ServiceServer<std_srvs::Empty::Request, std_srvs::Empty::Response> blinkServer("/led/blink", &messageCb); @@ -23,8 +24,8 @@ void setup() void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(10); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(10); // wait for a second nh.spinOnce(); } -
umhan35 created this gist
Jul 23, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #include <ros.h> #include <std_msgs/String.h> #include <std_srvs/Empty.h> ros::NodeHandle nh; void messageCb(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res) { digitalWrite(LED_BUILTIN, HIGH-digitalRead(LED_BUILTIN)); // blink the led nh.loginfo("LED is ON"); } ros::ServiceServer<std_srvs::Empty::Request, std_srvs::Empty::Response> blinkServer("/led/blink", &messageCb); void setup() { pinMode(LED_BUILTIN, OUTPUT); nh.initNode(); nh.advertiseService(blinkServer); } void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second nh.spinOnce(); }