Skip to content
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

software training #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

software training #15

wants to merge 2 commits into from

Conversation

ariwasch
Copy link
Member

@ariwasch ariwasch commented Jan 7, 2021

No description provided.

@@ -0,0 +1,13 @@
# Catkin Tools Metadata

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont commit this file

@@ -0,0 +1 @@
0.6.1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont commit this file

blacklist: []
build_space: build
catkin_make_args: []
cmake_args: []

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont commit this file

@@ -0,0 +1,13 @@
/home/ariwasch/catkin_ws/src/software_training/build/catkin_tools_prebuild

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont commit this file

@@ -0,0 +1,10 @@
<package>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont commit this file

@@ -0,0 +1 @@

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file should be used to ignore all the .catkin_tools stuff from commits

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you won't have to worry about this for the software repo but just for future reference

cmake_minimum_required(VERSION 3.0.2)
project(software_training)

## Compile as C++11, supported in ROS Kinetic and newer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete these comments

service.srv
)

## Generate actions in the 'action' folder

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

@@ -0,0 +1,49 @@
#include <ros/ros.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <actionlib/>
#include <actionlib>

#include <ros/ros.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/>
#include "std_msgs/String.h"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "std_msgs/String.h"
#include <std_msgs/String.h>

#include <actionlib/client/simple_action_client.h>
#include <actionlib/>
#include "std_msgs/String.h"
#include "geometry_msgs/Twist.h"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above


add_executable(service src/service.cpp)
target_link_libraries(service ${catkin_LIBRARIES})
add_dependencies(service software_training_generate_cpp)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
add_dependencies(service software_training_generate_cpp)
add_dependencies(service software_training_generate_messages_cpp)


ROS_INFO("Waiting for action server to start.");
// wait for the action server to start
ac.waitForServer(); //will wait for infinite time

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ac should be the simple action client, here its not defined so this won't compile

// create the action client
// true causes the client to spin its own thread

actionlib::SimpleActionClient<goemetry_msgs::Twist>("action", true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to set this to a variable

success = spawnClient.call(req2,resp2);


if(success){

Choose a reason for hiding this comment

The 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.
better to evaluate individually and use the response msg

@azumnanji azumnanji self-requested a review January 24, 2021 00:51
@@ -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);

Choose a reason for hiding this comment

The 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.

// send a goal to the action
actionlib_tutorials::FibonacciGoal goal;
goal.order = 20;
ac.sendGoal(goal);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like you didn't build this because it does not compile, this should be actionClient. the client sends the goal to the server. make sure to run catkin build so that you can catch these mistakes in the code

@azumnanji
Copy link

you need to delete the .catkin_tools folder completely

ros::ServiceClient spawnClient
= nh.serviceClient<turtlesim::Spawn>("spawn");
std_srvs::Empty srv;
srv.request;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be setting this equal to something??

turtlesim::Kill srv2;
srv2.request.name = "turtle1";

reset.call(srv);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should also be waiting for each service before these calls

* is the number of messages that will be buffered up before beginning to throw
* away the oldest ones.
*/
ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what this is doing, this is a copy of the code from the tutorial? why is it included?

#include <software_training/service.h>
#include "turtlesim/TeleportAbsolute.h"

/*class Service {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is commented out on purpose?



return true;
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compile errors, no semicolon and 2 returns for true? please compile your code!

turtlesim::Pose pos1
turtlesim::Pose pos2

void chatterCallBack(const std_msgs::String::ConstPtr& msg)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should name these functions based on what they are doing

int main(int argc, char **argv)
{
/**
* The ros::init() function needs to see argc and argv so that it can perform

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

ros::spinOnce();

loop_rate.sleep();
++count;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count is never used

msg.x = pos1.x - pos2.x;
msg.y = pos1.y - pos2.y;
msg.distance = sqrt(pow(msg.x,2) + pow(msg.y, 2));
std::stringstream ss;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this variable is never used

@@ -0,0 +1,91 @@
#include "Turtle.h"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what is going on with this file, it replicates functionality from other files. did you mean to commit the other files or this one? only one of these files needs to be committed

Turtle(ros::NodeHandle &n, float x, float y, std::string name);

// kill `name` turtle
static bool kill(ros::NodeHandle &n, std::string name);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making it static and taking in the name defeats the purpose of the class, make it a member function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants