Ask Your Question
0

How to properly create a Joy Node or any node.

asked 2017-06-22 10:25:39 -0600

renanmb gravatar image

I made this post because I couldn`t find any detailed explanation on the web about how to build a node from scratch and it may help anyone trying to self-learn ROS. I tried to build a node for controlling the Turtle sim using my PS4 joystick using different buttons and axis with learning purpose for later applying at my robot.

However while trying to run I receive back the message:

couldn`t find executable named teleop_joy below /home/rmb/workspace1/src/test_node

My code: https://github.com/renanmb/SURP

It happens using rosrun and roslaunch. I don`t understand why since I tryied to keep the code very similar to the code found at the Ros Joy Tutorial ( http://wiki.ros.org/joy/Tutorials/Wri... ).

I also used as example the code found at JetsonHacks https://github.com/jetsonhacks/jetson...

Thanks for the support.

edit retag flag offensive close merge delete

Comments

Probably not the answer you are looking for, but: have you completed the regular -- beginner -- ROS tutorials on the wiki? This would seem to be something that is covered there.

gvdhoorn gravatar imagegvdhoorn ( 2017-06-22 10:58:39 -0600 )edit

One thing to check: have you built your workspace (ie: ran catkin_make) and then sourced the devel/setup.bash file?

gvdhoorn gravatar imagegvdhoorn ( 2017-06-22 10:59:25 -0600 )edit

Yes, I did all tutorials. I know that I need to compile running catkin_make or cmake, and for each workspace that I will be working with I need to source the devel/setup.bash . I followed all that and still get the message that there is no executable. The mistake is probably at CMakeLists, file .cpp

renanmb gravatar imagerenanmb ( 2017-06-22 11:09:44 -0600 )edit

If I try to compile your code, I get three compiler errors. Is the code on your github repo identical to what you have on your machine? If so, then it would make sense that rosrun can't find teleop_joy, as it won't be created due to the compiler failing.

gvdhoorn gravatar imagegvdhoorn ( 2017-06-22 11:20:37 -0600 )edit

If I fix those errors, the binary is generated and after source devel/setup.bash I can successfully run: rosrun test_node teleop_joy. The CMakeLists.txt seems ok. At least on my end only the compiler errors were preventing things from working.

gvdhoorn gravatar imagegvdhoorn ( 2017-06-22 11:24:19 -0600 )edit

but why the compiler is failing? Is It probably something in the CMakeLists? I don`t know what I made wrong because I just followed like it says in the Tutorial. I not included the directory include, but I think is only necessary CMakeLists.txt , package.xml and the executable in the src directory.

renanmb gravatar imagerenanmb ( 2017-06-22 11:26:19 -0600 )edit

There is nothing wrong with CMakeLists.txt. See my answer.

gvdhoorn gravatar imagegvdhoorn ( 2017-06-22 11:28:52 -0600 )edit

So what was the errors in the compiler? I got lost trying to learn CMake in 1 night. So do you think it is an installation problem with the compiler? Both my devices run on ARM 64.

renanmb gravatar imagerenanmb ( 2017-06-22 11:29:46 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-06-22 11:28:21 -0600

gvdhoorn gravatar image

Bit of a strange answer, but see below for the diff that shows how I fixed the errors in your program:

diff --git a/src/teleop_joy.cpp b/src/teleop_joy.cpp
index 740d928..645d14a 100644
--- a/src/teleop_joy.cpp
+++ b/src/teleop_joy.cpp
@@ -37,12 +37,12 @@ TeleopTurtle::TeleopTurtle():
   angular_(0),
   deadman_axis_(4),
   l_scale_(2.0),
-  a_scale(2.0)
+  a_scale_(2.0)
 {

   ph_.param("axis_linear", linear_, linear_);
   ph_.param("axis_angular", angular_, angular_);
-  ph.param("axis_deadman", deadman_axis_, deadman_axis_);
+  ph_.param("axis_deadman", deadman_axis_, deadman_axis_);
   ph_.param("scale_angular", a_scale_, a_scale_);
   ph_.param("scale_linear", l_scale_, l_scale_);

@@ -53,7 +53,7 @@ TeleopTurtle::TeleopTurtle():

   joy_sub_ = nh_.subscribe<sensor_msgs::Joy>("joy", 10, &TeleopTurtle::joyCallback, this);

-  timer_ = nh_.createTimer(ros::Duration(0.1), boost::bind(&TurtlebotTeleop::publish, this));
+  timer_ = nh_.createTimer(ros::Duration(0.1), boost::bind(&TeleopTurtle::publish, this));
 }

After that I could successfully build the workspace and after source devel/setup.bash everything 'just worked'.

edit flag offensive delete link more

Comments

PS: if I may suggest: unless you are writing a teleop node for the learning experience, I would really suggest you see if teleop_twist_joy works for what you need. Always better to reuse than to reimplement.

gvdhoorn gravatar imagegvdhoorn ( 2017-06-22 11:31:36 -0600 )edit

My mistake was terrible. I may need a pair of glasses. But the code still doesnt work as supposed. I believe it can be button mapping for the DS4 or I made a mess trying to put this "Deadman" button. I am writing it for learning experience, reusing is fast but dont teach as much as trying to write

renanmb gravatar imagerenanmb ( 2017-06-22 18:38:17 -0600 )edit

teleop_twist_joy could still be a reference for what you are trying to achieve. It depends a bit on what you want to spend your time: getting your robot to work or fight with joysticks.

gvdhoorn gravatar imagegvdhoorn ( 2017-06-23 01:29:10 -0600 )edit

Later on I solved the problem by trial and error and making a controller mapping. I was writing a teleop node for the learning experience and later on I applied on some projects that required personalized teleop node

renanmb gravatar imagerenanmb ( 2018-09-23 19:00:16 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2017-06-22 10:25:39 -0600

Seen: 700 times

Last updated: Jun 22 '17