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

jonagf's profile - activity

2019-05-20 02:06:10 -0500 marked best answer Rosserial connection doesn't work due to signal

Hi all,

I have an arduino MEGA and I want to communicate via rosserial with my ros node.

Somewhere in my arduino code I have the following line.

if(intensity[n] <= myCounter) 
{
        digitalWrite((2*(n-8))+shiftSaidaInicial, LOW);
}

When I try to make the connection running rosrun rosserial_python serial_node.py /dev/ttyACM0 it says that it's unnable to conenct to the device.

However, if I change the previous line to the following it syncs perfectly.

if(intensity[n] >= myCounter) 
{
        digitalWrite((2*(n-8))+shiftSaidaInicial, LOW);
}

The only thing I changed was the <= to >=. Sadly, so the code makes sense, I need the <= instead..

Anyone knows why this is happening?

Thanks!

2018-12-05 10:58:03 -0500 received badge  Famous Question (source)
2018-06-15 17:13:35 -0500 received badge  Famous Question (source)
2018-06-15 17:13:35 -0500 received badge  Notable Question (source)
2017-11-20 06:19:17 -0500 received badge  Famous Question (source)
2017-10-16 03:23:39 -0500 received badge  Famous Question (source)
2017-10-01 04:07:19 -0500 received badge  Notable Question (source)
2017-06-26 08:17:21 -0500 received badge  Popular Question (source)
2017-05-12 08:31:18 -0500 received badge  Popular Question (source)
2017-05-08 08:46:27 -0500 edited question Rosserial connection doesn't work due to signal

Rosserial connection doesn't work due to sign Hi all, I have an arduino MEGA and I want to communicate via rosserial wi

2017-05-08 08:23:56 -0500 asked a question Rosserial connection doesn't work due to signal

Rosserial connection doesn't work due to sign Hi all, I have an arduino MEGA and I want to communicate via rosserial wi

2017-05-08 08:17:55 -0500 marked best answer qt gui global variables

Hi,

I created a Qt gui with c++ and I'm compiling it with cmake. Below you can find my CMakeLists.

**CMakeLists**
#My CMakeLists.txt

cmake_minimum_required (VERSION 2.8) project (teste)

#---------------------------------

FIND_PACKAGE(Qt4 REQUIRED) INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS})

SET(teste_SOURCES main.cpp mainwindow.cpp) SET(teste_FORMS mainwindow.ui) SET(teste_HEADERS mainwindow.h globals.h) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON)

QT4_WRAP_CPP(teste_HEADERS_MOC ${SimpleProject_HEADERS}) QT4_WRAP_UI(teste_FORMS_HEADERS ${SimpleProject_FORMS})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) ADD_EXECUTABLE(teste
    ${teste_SOURCES}
    ${teste_HEADERS_MOC}
    ${teste_FORMS_HEADERS} )

TARGET_LINK_LIBRARIES(teste ${QT_LIBRARIES})

In my Qt GUI I created some global variables (globals.h) and now I want my ROS node to get those variables.

**globals.h**

 #ifndef GLOBALS_H

#define GLOBALS_H

// ALL THE GLOBAL DECLARATIONS

extern int numberOfMotors;
extern int intensidade[16];
extern int local[16];

#endif // GLOBALS_H

I assume that I have to include globals.h in my ROS node and then act conform it. However, I don't know how to make the globals.h available for ROS. I think I need to probably mix my cmake makefile and my catkin_make makefile, but I have no idea how. Here's my catkin_make CMakeLists:

cmake_minimum_required(VERSION 2.8.3)
project(tentativa)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
 message_generation
  message_runtime
)

## Generate messages in the 'msg' folder
 add_message_files(
   FILES
   Dados.msg
   Dados2.msg
 )

## Generate added messages and services with any dependencies listed here
 generate_messages(
  DEPENDENCIES
   std_msgs  # Or other packages containing msgs
 )

catkin_package(
  CATKIN_DEPENDS roscpp rospy std_msgs message_runtime #rwsua2017_msgs
)
# include_directories(include)
include_directories(
  ${catkin_INCLUDE_DIRS}
)
add_executable(publish_arduino src/publish_arduino.cpp)
target_link_libraries(publish_arduino ${catkin_LIBRARIES})
add_dependencies(publish_arduino tentativa_generate_message_cpp)

Does anyone know how to do it? Thanks in advance!

2017-05-03 06:08:38 -0500 asked a question Where to put ros variables in a qt gui?

Where to put ros variables in a qt gui? So, I have a Qt Gui in a ROS node and after some fights with CMakeLists I manage

2017-04-29 11:18:30 -0500 received badge  Enthusiast
2017-04-29 11:18:29 -0500 received badge  Enthusiast
2017-04-24 09:30:04 -0500 commented answer qt gui global variables

I'm gonna try that. Thank you!

2017-04-20 04:39:49 -0500 asked a question qt gui global variables

qt gui global variables Hi, I created a Qt gui with c++ and I'm compiling it with cmake. Below you can find my CMakeLis

2017-04-20 03:59:47 -0500 received badge  Notable Question (source)
2017-04-20 03:14:45 -0500 edited question Value received in Arduino is always 0

Value received in Arduino is always 0 Hi all, So I have two ROS nodes, one in c++ and another in Arduino. I built a cus

2017-04-03 08:33:22 -0500 received badge  Popular Question (source)
2017-04-03 04:19:33 -0500 answered a question Value received in Arduino is always 0

Solved! So apparently the problem was that even thought that another ros node could receive two int64 arrays, the arduino couldn't (it was probably too big). What I did after reinstalling ros and rosserial, was change the message type to uint8[] instead and now it works fine :) I didn't know there was some kind of limitation on data that we could sent (still don't know if its true), but well, since it works perfectly now I'm gonna leave it this way!

2017-03-30 09:30:14 -0500 received badge  Editor (source)
2017-03-30 05:05:51 -0500 answered a question Value received in Arduino is always 0

I thank that what happened is that my communication with ROS and Arduino stopped working, but I don't know why, since it worked fine before...

My c++ code works well with another c++ node, so I assume the problem is in the arduino part.

2017-03-30 04:22:09 -0500 asked a question Value received in Arduino is always 0

Hi all,

So I have two ROS nodes, one in c++ and another in Arduino. I built a custom message (DataToArduino.h) in the c++ node in which i send two int arrays and one string to the arduino:

Then, in the arduino node I wanted to be able to take those values out, like intensity[0], intensity[1], etc, so I did the following:

#include <projecto/DataToArduino.h>
#include <ros.h>
#include <std_msgs/Int64.h>

ros::NodeHandle nh;

int duration[10]; 
int location[10];
int x;

void messageCb( const projecto::DataToArduino& subscMsg){
  for(int j=0;j<10;j++)
  {
    duration[j] = subscMsg.intensity[j];
    location[j] = subscMsg.location[j];
  }
  x = duration[5];
}

std_msgs::Int64 test;

ros::Subscriber<projecto::DataToArduino> s("chatter", &messageCb);
ros::Publisher p("my_topic", &test);

void setup()
{  
nh.initNode();
  nh.subscribe(s);
  nh.advertise(p);

}

void loop()
{
  test.data = x;
  p.publish( &test );
  nh.spinOnce();
}

I created a publisher topic so I could see some data to check if what I was receiving was ok. However, when I checked the echo of the topic in the terminal the result was always data 0 and I don't understand why.

Do you have any idea in what the problem can be and any suggestions?

Thank you so much!

Update: I thank that what happened is that my communication with ROS and Arduino stopped working, but I don't know why, since it worked fine before...

My c++ code works well with another c++ node, so I assume the problem is in the arduino part.

2017-03-30 03:56:06 -0500 received badge  Notable Question (source)
2017-03-22 12:20:52 -0500 commented answer Access all the fields in ROS msg

Thank you very much! It was very useful! The package part was missing in my head, now it makes sense!

2017-03-22 12:20:16 -0500 received badge  Scholar (source)
2017-03-22 12:20:12 -0500 received badge  Supporter (source)
2017-03-22 12:20:04 -0500 received badge  Popular Question (source)
2017-03-22 10:51:30 -0500 received badge  Student (source)
2017-03-22 07:45:27 -0500 asked a question Access all the fields in ROS msg

This is probably a very simple and stupid question, but I searched everywhere, and maybe because it's so simple I can't find an answer.

I created a msg like this (and maybe Im gonna add a string later as well)

int64 intensity 
int64 location
int64 duration

And now I'm trying to give values to each of this variables and publish them in a topic. I did the follow:

// (dont know how I'll do if I had the string, but thats not the problem **yet**)
ros::Publisher chatter_pub = n.advertise<std_msgs::Int64>("chatter", 1000);
std_msgs::Int64 msg;

Now the question comes here. In the ros publisher tutorials, we use msg.data, and as I searched online I found that data was the name of our variable. However, I did not understand that. How can I give values to every field of my message? I thought on doing something like this, but I know its not correct...

msg.data.intensity = 15;
msg.data.location = 100;
msg.data.duration = 37;

//ROS_INFO("intensity %d, local %d, dura %d ", msg.data.intensity,msg.data, msg.data);
chatter_pub.publish(msg);

Thank you!!