ros-drivers / rosserial

A ROS client library for small, embedded devices, such as Arduino. See: http://wiki.ros.org/rosserial
517 stars 525 forks source link

Arduino uno wifi rev2 & rosserial #555

Open viso951 opened 3 years ago

viso951 commented 3 years ago

Hello! I am using an Arduino uno wifi rev2, ros noetic and ubuntu 20. When I try start my ros node on the arduino with "rosrun rosserial_python serial_node.py tcp" command (after a roscore), it says "[INFO] [1512416583.799159]: ROS Serial Python Node Fork_server is: False [INFO] [1512416583.816673]: Waiting for socket connections on port 11411 waiting for socket connection". I am also using the latest release of rosserial. The arduino is able to create a rosnode via serial connection and is connecting to the internet successfully. Does anybody have any idea? the code is:

include

include

include <std_msgs/Float32.h>

//#define USE_USBCON ros::NodeHandle nh; std_msgs::Float32 str_msg; ros::Publisher chatter("chatter", &str_msg); int temp; void setup() { //Serial.begin(9600); nh.initNode(); nh.advertise(chatter); delay(10000); } void loop() { temp = 2; str_msg.data = temp; chatter.publish( &str_msg ); nh.spinOnce(); delay(200); }

romainreignier commented 3 years ago

First, you should add the following line before including ros.h:

#define ROSSERIAL_ARDUINO_TCP

And then, you should have code to setup your Wifi connection.

See this example as reference.