Ask Your Question
0

rosserial working, arduino not outputing

asked 2012-04-26 08:27:04 -0500

matt2027 gravatar image

updated 2012-07-02 13:52:24 -0500

mjcarroll gravatar image

First off, I am Publishing String Data on a "set_pins_mode" topic. When I echo the topic, the data looks like this

---
Data: lights on

When I set up the arduino, everything seems to connect good but I am not getting an output. I believe it may be in the data structure or something. Here is my simplified arduino code.

#include <ros.h>
#include <std_msgs/String.h>

ros::NodeHandle  nh;

String Pin;

int Lights = 22;

void messageCb( const std_msgs::String& str_msg){

  Pin = str_msg.data;

}

ros::Subscriber(std_msgs::String)  sub("set_pins_mode", &messageCb);

void setup(){ 

  pinMode(13, OUTPUT);

  nh.initNode();

  nh.subscribe(sub);

  //Set all the pins we need to output pins

  pinMode(Lights, OUTPUT);

}

void loop()
{  

  if (Pin = "light on"){

    digitalWrite(Lights, HIGH);
  }

  if (Pin = "light off"){

    digitalWrite(Lights, LOW);
  }


nh.spinOnce();

delay(1);
}

The program will get more complex with more lights added. I wanted to try and get one light working first, then its just a simple thing of copy/paste. I know this has to be easy. The output just doesn't come on.

edit retag flag offensive close merge delete

Comments

I've tried to setup Poark but I am getting this error.

/home/octavius/ros_workspace/poark/poark_server/poark_server.cpp:8:29: fatal error: ros/node_handle.h: No such file or directory compilation terminated.

matt2027 gravatar image matt2027  ( 2012-04-28 13:02:43 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
2

answered 2012-04-30 10:21:51 -0500

Cody gravatar image

updated 2012-04-30 10:24:46 -0500

(Pin = "light off")

will do assignment rather than comparison (one '=' means assign). The fix:

(Pin == "light off")

I assume here that by "output" you mean the led changing.

edit flag offensive delete link more
1

answered 2012-04-29 21:31:31 -0500

___Jul___ gravatar image

Hey Matt, I am the project maintainer of Poark. Please feel free to contact me if you have any troubles getting Poark compiled in the future.

For this particular case, can you be more specific about what steps have you taken to get the library compiled? Did you use the proper version of the rosserial code from the rosserial repository in our project (which is a compatible fork of the Parsec's rosserial port...which itself is an incompatible port of the original rosserial code)? I guess not using this version of resserial is the core of your problem but if this hint doesn't help just file an issue on our bug tracker and we'll try to help further.

Best, Julian

edit flag offensive delete link more
0

answered 2012-04-26 21:39:30 -0500

damonkohler gravatar image

Depending on what you're doing, you may want to check out poark. It could make your life easier :)

http://code.google.com/p/poark/

edit flag offensive delete link more

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: 2012-04-26 08:27:04 -0500

Seen: 1,128 times

Last updated: Apr 30 '12