ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Ros451's profile - activity

2016-08-08 01:35:34 -0500 marked best answer Serial Communication problem - ROS

Hello,

I've written a serial communication program/driver for controlling a servo. Now I wanted to use it with ROS.

  1. First of all, I setup an empty c++ ROS package.
  2. Second I put the code inside and compiled it using ROS facilities. No ROS code yet, should basically spit out the same functionality, BUT DOES NOT!

The issue is that the serial communication doesn't work properly, for instance it can't read the right values at the serial port any more, it does strange things.

If I do compile my prog. using "g++ serial.cpp" and then run the executable everything works fine.

What does ROS do with my program different from the simple "g++ serial.cpp" command!

Thank you very much!

Greetings!

2016-08-08 00:40:04 -0500 marked best answer rosmake -> builds something with catkin!?

Hi,

I've created a package with a source file as always.

roscreate-pkg testpkg roscpp

rosmake testpkg

But now it created several strange catkin files in the folder build and no source file of my code was build:

catkin/ CATKIN_IGNORE CMakeFiles/ devel/ Makefile catkin_generated/ CMakeCache.txt cmake_install.cmake gtest/ test_results/

And it doesn't work :/, I've never used catkin where does it come from!?

2014-07-09 05:21:20 -0500 received badge  Famous Question (source)
2014-06-18 17:52:51 -0500 received badge  Famous Question (source)
2014-04-06 20:19:14 -0500 received badge  Famous Question (source)
2014-03-23 09:31:19 -0500 received badge  Famous Question (source)
2013-10-16 09:41:44 -0500 received badge  Famous Question (source)
2013-10-15 06:06:50 -0500 marked best answer Basic understanding of ROS for: dynamixel and a joystick

Hi everybody,

I own some dynamixel AX-12 servos. My task is to controll them with a joystick via ROS with a self-build "USB2Dynamixel" (U2D). The main issue is that the available ROS package for my dynamixel controllers doesn't work properly with my U2D, I do receive everything but can't send anything.

IMO it's a hardware issue because the controller of my U2D doesn't buffer anything and only works on send or receive, but the ROS program from the package receives endless status stacks from the servo all the time. That's why I can't send anything via the existing "ROS package" due to my "one way connection". Anyway it is how it is and I can't change it (from the hardware side).

I've already written a small c++ programm which basically would be enough for me if I don't have to use ROS for this task. I can simply controll the servo with my joystick (turn right, turn left) and read some status, like position etc..

That is acutally what I want (or have to) realize in the ROS environment, I've completed every available ROS tutorial and I thing that I understand the basics, though I don't get how to "start" and realize my project.

Could somebody describe me my steps, what I actually have to do. Especially how to implement the whole communication from my c++ files.

Thank you in advance.

2013-10-15 06:06:19 -0500 received badge  Notable Question (source)
2013-09-20 19:42:09 -0500 received badge  Notable Question (source)
2013-09-10 23:17:42 -0500 received badge  Notable Question (source)
2013-09-10 17:51:15 -0500 received badge  Popular Question (source)
2013-09-10 13:34:02 -0500 received badge  Scholar (source)
2013-09-10 12:39:16 -0500 commented answer subscribe and publish - doesn't work properly

Thank you!

2013-09-10 11:59:05 -0500 asked a question subscribe and publish - doesn't work properly

Hi,

I've written a small program which subscribes the topic "joy" from the joy_node (joystick) then it should process the date and publish it on a new topic "sub_dynamixel". Well but it doesn't, the code compiles but no published data available.

#include <sensor_msgs/Joy.h>
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "message/message_back.h"

#include <sstream>

#include <stdio.h>
#include <iostream>




void chatterCallback(const sensor_msgs::Joy::ConstPtr &joy)
{ 
  float position;
  int position_move;  

  ros::NodeHandle r;
  ros::Publisher chatter_pub = r.advertise<message::message_back>("sub_dynamixel", 1000);
  message::message_back msg; 
  position = joy->axes[0];


 if(position>0)
 {
 position_move=position*512;
 position_move+=512;
 }
 else if(position<0)
 position_move=512-(position*(-1)*512);
 else if(position==0)
 position_move=512;


 msg.position_move = position_move;      
 chatter_pub.publish(msg); 
}




int main(int argc, char **argv)
{
ros::init(argc, argv, "dynamixel_teleoperation");
ros::NodeHandle n;

ros::Subscriber sub = n.subscribe("joy", 1000, chatterCallback);
ros::spin();


return 0;
}
2013-09-10 05:36:05 -0500 received badge  Popular Question (source)
2013-09-10 05:07:06 -0500 commented answer How can I use the subscribed message?

Thank you for your reply, I've tried myself and failed, the code doesn't compile (I edited my post see the new code). I want just to pass my_arg to the callback function.

2013-09-10 04:11:12 -0500 received badge  Notable Question (source)
2013-09-10 03:54:17 -0500 commented answer How can I use the subscribed message?

Thank you! This is what I was looking for, but can I also pass some parameters to the callback function from the main() like my filedescriptor for my port etc. ?

2013-09-10 03:51:26 -0500 commented answer How can I use the subscribed message?

Thank you very much, this helps me a lot! For the second case I have a further question: can I also pass some parameters to the callback function from the main() like my filedescriptor for my port etc. ?

2013-09-10 03:05:55 -0500 asked a question How can I use the subscribed message?

Hi,

I've written a very simple subscriber and now my task is to use the subscribed message as a "position value" for my servo. But how to do this ? Let's image that I would have a function called motor_position(uint16_t position) which I have to call and give it the new position value, when and where do I have to call the function?

So my question is, what is the simplest way to use the received message.

Thank you in advance

    #include "ros/ros.h"
    #include "message/message.h" //is a uint16_t var

    uint16_t a;

    void chatterCallback(const message::message::ConstPtr &msg)
    {
      a = msg->position;
      ROS_INFO("I heard: [%d]", a);


    }

    int main(int argc, char **argv)
    {

    ros::init(argc, argv, "subscriber");
    ros::NodeHandle n;

    ros::Subscriber sub = n.subscribe("topicname", 1000, chatterCallback);
    ros::spinOnce();

    // HOW CAN I CALL MY FUNCTION ?
    // motor_position(a); THIS is wrong for sure.  

    return 0;
    }

////////////////////////////EDIT//////////////////////////////// Does not compile ?!

#include "ros/ros.h"
#include "message/message.h"


void chatterCallback(const message::message::ConstPtr &msg, int arg)
{
  //do something with arg
  uint16_t a = msg->position;
  ROS_INFO("I heard: [%d]", a);
}

int main(int argc, char **argv)
{

int my_arg= 0;

ros::init(argc, argv, "subscriber");
ros::NodeHandle n;

ros::Subscriber sub = n.subscribe("topicname", 1000, boost::bind(chatterCallback, _1, my_arg ));
ros::spin();

return 0;
}
2013-09-09 23:06:21 -0500 received badge  Notable Question (source)
2013-09-09 21:28:26 -0500 received badge  Popular Question (source)
2013-09-09 07:23:33 -0500 received badge  Popular Question (source)
2013-09-09 06:45:47 -0500 received badge  Popular Question (source)
2013-09-09 05:47:46 -0500 answered a question Serial Communication problem - ROS

Thank you for your replies, it was a very weird error inside the code. It has nothing to do with ROS, though it was very strange.

2013-09-09 05:41:51 -0500 commented question Serial Communication problem - ROS

Thank you for your replies, it was a very weird error inside the code. It has nothing to do with ROS, though it was very strange.

2013-09-09 02:16:39 -0500 commented question Serial Communication problem - ROS

Thank you very much :)! I will try it!

2013-09-09 01:43:40 -0500 commented question Serial Communication problem - ROS

Thank you very much for your reply. This is what I get: pastebin.com/rDxmUxxV