

Port='COM4', timeout=5 # set your parameters as needed, reading timeout 5 seconds Just add the serial port parameters ( baudrate etc.) as needed, adjust the timeout and you will probably want to collect the received values into a list ( your_list.append(value)). The following code should resolve the problem.

PuTTY and other terminals do not show NUL characters. It looks like your device sends null-terminated records. Range_msg.field_of_view = (10.0/180.0) * 3.I think it is practically impossible that wrong parameter settings of the serial port would cause it to read extra NUL characters ( b'\x00', also called null character) and otherwise read correct data. Range_msg.radiation_type = sensor_msgs::Range::ULTRASOUND //set the message type and the sensor radiation type NewPing sensor(sonar_pin, sonar_pin, 25) Tf::TransformBroadcaster sonar_broadcaster Ĭhar base_link = "/base_link" //set the TF child frame

Ros::Publisher pub_range( "/ultrasound", &range_msg) The next time I run it I get the above errors. Whats weirder is if I restart the PC and run the code it works fine, I can launch RVIZ, with "roslaunch robot_description robot_description.py" and it will show me the range sensor and move about as i move my hand to and from the sensor. After that it may continue to connect but the error "Serial Port read returned short (expected 78 bytes, received 5 instead)." comes up, or it may just not connect and keep trying. When running "rosrun rosserial_python serial_node.py /dev/ttyACM0" I get the error message "wrong checksum for topic id and msg".
