ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

hx711 python library; ROS node; name 'rospy' is not defined

asked 2018-12-29 17:11:35 -0500

Vrinda gravatar image

Hello ! I am trying to read a load sensor on raspberry pi having Ubuntu Mate with ROS Kinetic. I am using the library link text. However when I create a catkin package and insert the python files, my mouse cursor shows a plus sign. Additionally when I run the by "sudo python", I get "name rospy is not defined". My aim is to read the load sensor and make a rostopic to display the numbers. I needed some guidance regarding this ! Thank you for your time!

edit retag flag offensive close merge delete


Why are you using sudo? I don't see any use of it in the README

jayess gravatar image jayess  ( 2018-12-29 23:33:43 -0500 )edit

Hello ! It says permission denied when I do "python"

Vrinda gravatar image Vrinda  ( 2018-12-30 09:40:46 -0500 )edit

I'd be very careful about running scripts using sudo

jayess gravatar image jayess  ( 2018-12-30 11:23:41 -0500 )edit

Yes, I thought so. I resolved it and made another package from scratch. Thanks much !

Vrinda gravatar image Vrinda  ( 2018-12-31 10:39:56 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2018-12-31 10:38:28 -0500

Vrinda gravatar image

updated 2018-12-31 13:29:23 -0500

jayess gravatar image

Hello everyone ! It was a silly thing. Those files did not have a

#!/usr/bin/env python

at the top. For further information, I then followed this link and placed the (a class which I was trying to import in my node) in another package in my catkin_ws.

edit flag offensive delete link more

answered 2019-10-25 04:29:37 -0500

tuman3515 gravatar image

updated 2019-10-25 05:49:18 -0500

gvdhoorn gravatar image

i have the same problem to with arduino and ros commmunication.when i use hx711 library and ros library together i get this msg."Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino"

this is my code on arduino

#include <ros.h>
#include <std_msgs/Float64.h>
#include "HX711.h"
#define DOUT  3//
#define CLK  2//
HX711 scale;
float calibration_factor = -5880; //-7050 worked for my 440lb max scale setup
ros::NodeHandle nh;

std_msgs::Float64 test;
ros::Publisher p2("my_topic", &test);
void setup()
  scale.begin(DOUT, CLK);
  scale.tare(); //Reset the scale to 0 
  long zero_factor = scale.read_average(); //Get a baseline reading

void loop()
  scale.set_scale(calibration_factor); //Adjust to this calibration factor
  float weight=(scale.get_units()); = weight;
  p2.publish( &test );

ros command is this

rosrun rosserial_python /dev/ttyUSB1

is there any way to use hx711 withouth library.

edit flag offensive delete link more



Please do not post question as answers on another question. ROS Answers works like Stack Exchange and Stack Overflow: they are not forums.

If you have the same question, post a comment or post a new question while referring to this one.

gvdhoorn gravatar image gvdhoorn  ( 2019-10-25 05:50:10 -0500 )edit

answered 2018-12-30 06:35:43 -0500

Hamid Didari gravatar image

updated 2018-12-30 06:35:59 -0500

for running python scrip you must use "rosrun" ,somting lik this:

rosrun pkg_name

also pls see the wiki

edit flag offensive delete link more


Hello ! I tried that. It works with other nodes, however I cannot make it to work with the library I have.

Vrinda gravatar image Vrinda  ( 2018-12-30 09:42:12 -0500 )edit

could you share your code?

Hamid Didari gravatar image Hamid Didari  ( 2018-12-31 00:30:46 -0500 )edit

It is the library I was trying to use (link in my question). I was trying to use the as my script for the ROS node.

Vrinda gravatar image Vrinda  ( 2018-12-31 10:42:41 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2018-12-29 17:09:29 -0500

Seen: 1,013 times

Last updated: Oct 25 '19