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 #16

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

Software Training #16

wants to merge 9 commits into from

Conversation

hr-ti
Copy link

@hr-ti hr-ti commented Jan 11, 2021

No description provided.

<build_depend>actionlib</build_depend>
<exec_depend>actionlib</exec_depend>
<build_depend>actionlib_msgs</build_depend>
<exec_depend>actionlib_msgs</exec_depend>

Choose a reason for hiding this comment

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

if its build_depend and exec_depend you can just put the depend tag, its cleaner

{
public:
ros::NodeHandle node;
GotoAction(std::string name) : as_(node, name, boost::bind(&GotoAction::executeCB, this, _1), false)

Choose a reason for hiding this comment

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

instead of having NodeHandle as public you can pass the NodeHandle into the constructor. Nobody should be modifying the NodeHandle so it should be private

void executeCB(const software_training_assignment::GotoGoal::ConstPtr &goal)
{

ROS_INFO("executeCB called");

Choose a reason for hiding this comment

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

this formatting is all off, make sure to format properly so that it's easy to read the code


ROS_INFO("executeCB called");
double relativeX = goal->x - x,
relativeY = goal->y - y,

Choose a reason for hiding this comment

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

separate each double declaration, it's cleaner and easier to read


pub.publish(rotation);

ros::Duration(1).sleep();

Choose a reason for hiding this comment

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

what is this sleep for?


ros::Duration(1).sleep();

double gotoCount = (int)relativeDist / 2, gotoRe = relativeDist - (gotoCount * 2);

Choose a reason for hiding this comment

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

same as above for declaring variables

@@ -0,0 +1,8 @@
#ifndef KILLTURTLES_H

Choose a reason for hiding this comment

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

should just use #pragma once instead of header guards, its standard for most compilers


#include <ros/ros.h>

bool killTurtles(ros::NodeHandle n);

Choose a reason for hiding this comment

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

should always pass NodeHandle by reference, we don't want create another copy


namespace P
{
class Publisher

Choose a reason for hiding this comment

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

shouldn't use Publisher as a name, it will be confusing. Instead be more descriptive - PositionPublisher

bool resetPos(std_srvs::Empty::Request &req,
std_srvs::Empty::Response &res)
{
ros::NodeHandle n;

Choose a reason for hiding this comment

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

should pass the NodeHandle by reference, you ideally should only need 1 NodeHandle per node you write

y = msg->y;
}

void executeCB(const software_training_assignment::GotoGoal::ConstPtr &goal)

Choose a reason for hiding this comment

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

the easiest way to write this function would be to determine distance and angle from the point and send the twist msg until you've reached the point. the feedback would be given as distance from the goal and once you have reached the succeed flag could be set. this is something to think about

@@ -0,0 +1,9 @@
#ifndef RESETPOS_H

Choose a reason for hiding this comment

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

see comment above about header guards

#include "spawnTurtles.h"


bool spawnTurtles(ros::NodeHandle n, std::string name, int x, int y)

Choose a reason for hiding this comment

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

NodeHandle by reference

posPublisher.sub = n.subscribe("moving_turtle/pose", 1000, &Publisher::subCallback, &posPublisher);

GotoAction goTo("goto");
goTo.node = n;

Choose a reason for hiding this comment

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

same with my comment above, instead of setting it equal, it should be passed by reference through the constructor so it is immutable by other processes


software_training_assignment::GotoGoal goal;

goal.x = atoll(argv[1]);

Choose a reason for hiding this comment

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

we don't use command line arguments for nodes usually. most of the time the data is passed through subscriber or publisher callbacks

Copy link

@azumnanji azumnanji left a comment

Choose a reason for hiding this comment

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

looks good, there is a few comments but nothing too major

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