-
Notifications
You must be signed in to change notification settings - Fork 34
software training #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| #include <ros/ros.h> | ||
| #include <actionlib/client/simple_action_client.h> | ||
| #include <actionlib/> | ||
| #include "std_msgs/String.h" | ||
| #include "geometry_msgs/Twist.h" | ||
| #include <actionlib> | ||
| #include <std_msgs/String.h> | ||
| #include <geometry_msgs/Twist.h> | ||
| #include <sstream> | ||
| #include <cmath> | ||
| #include "software_training/Distance.h" | ||
|
|
@@ -17,15 +17,16 @@ int main (int argc, char **argv) | |
| = nh.advertise<geometry_msgs::Twist>("/moving_turtle/cmd_vel", 1000); | ||
| // create the action client | ||
| // true causes the client to spin its own thread | ||
|
|
||
| actionlib::SimpleActionClient<goemetry_msgs::Twist>("action", true); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry forgot to mention this, action Client and Server should never be in the same node, it defeats the purpose of having an action server. |
||
| //actionlib::SimpleActionClient<goemetry_msgs::Twist>("action", true); | ||
| actionlib::SimpleActionClient<software_training_assignment::Action> actionClient("action", true); | ||
|
|
||
| Server server(n, "action", boost::bind(&execute, _1, &server), false); | ||
| server.start(); | ||
|
|
||
| ROS_INFO("Waiting for action server to start."); | ||
| // wait for the action server to start | ||
| ac.waitForServer(); //will wait for infinite time | ||
| actionClient.waitForServer(); //will wait for infinite time | ||
|
|
||
| ROS_INFO("Action server started, sending goal."); | ||
| // send a goal to the action | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,14 +45,21 @@ int main(int argc, char **argv){ | |
|
|
||
| ros::service::waitForService("spawn", ros::Duration(5)); | ||
| bool success = spawnClient.call(req,resp); | ||
| success = spawnClient.call(req2,resp2); | ||
| bool success2 = spawnClient.call(req2,resp2); | ||
|
|
||
|
|
||
| if(success){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is good but if the first turtle does not spawn but the second one does this will be true. |
||
| ROS_INFO_STREAM("Spawned a turtle named " | ||
| << resp.name); | ||
| }else{ | ||
| ROS_ERROR_STREAM("Failed to spawn."); | ||
| } | ||
|
|
||
| if(success2){ | ||
| ROS_INFO_STREAM("Spawned a turtle named " | ||
| << resp2.name); | ||
| }else{ | ||
| ROS_ERROR_STREAM("Failed to spawn."); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should be adding the action file for building