Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all 314 articles
Browse latest View live

rosserial_windows packet loss while sending data to service server on ROS

$
0
0
Hi, I have a question about rosserial windows. I made a Windows application which has two buttons as below. 1. Open connection 2. Send data to Service Server - which is Service client In constructor of the dialog, I assigned ServiceClient pointer to node handle.
When I click Button #1, it should init node handle by calling initNode function and call spinOnce function.
When I click Button #2, it should call Call function to send data to ServiceServer and receive response.
My test was as shown below. 1. Compile 2. Click Button #1 3. Click Button #2 4. Wait for a while (longer than 30 sec) 5. Click Button #2 I put simplified version of my code.
// ROSHandler class
class ROSHandler {
    protected:
        ros::NodeHandle node_handle_;
    private:
       ros::ServiceClient* client_;
    public:
        ROSHandler() {
            client_ = new ros::ServiceClient("TOPIC_NAME");
            node_handle_.serviceClient(*client_);
        }
        ~ROSHandler();
        bool Connect() {
            node_handle_.initNode(MASTER_IP);
            while (!node_handle_.connected())
            {
                node_handle_.spinOnce();
            }
            return (node_handle_.spinOnce() == 0);
        }
        bool Send() {
            Request req;
            Response res;
            // set values in req

            if (!node_handle_.connected()) {
                Connect();
            }

            client_->call(request, response);
            node_handle_.spinOnce();
            return response_.result; // return boolean
        }
};
void OnClickButton1 {
    Connect(); // connect function above
}

void OnClickButton2 {
    Send(); // send function above
}
Thanks! :D

Multiple TCP connections using rosserial_server with WiFi Arduino

$
0
0
Dear all, I am currently running an Arduino Uno* with an [ATWINC1500 WiFi ](https://www.adafruit.com/product/2999) breakout from Adafruit and can successfully publish topics over WiFi to a master using `rosrun rosserial_python serial_node.py tcp`. This has been achieved using code modified from [this previous ROS answer](https://answers.ros.org/question/232774/launch-a-ros-node-over-wifi/) supplied by [@ahendrix](https://answers.ros.org/users/1034/ahendrix/). The trouble I run into is running two of these devices at the same time. They both have unique IP addresses and are connected to the network, running differently named topics, and individually can be successfully connected and publish topics. The first device can be connected using `rosrun rosserial_python serial_node.py tcp`. Simply starting a second device does not lead to be being connected. If I run a second serial_node.py with a different node name to avoid conflicts (by using `rosrun rosserial_python serial_node.py tcp __name:=OtherNodeName`), I get an error `"socket.error: [Errno 98] Address already in use"`. As the socket can't be given as an argument to serial_node.py, I tried using `rosrun rosserial_server socket_node` as rosserial_server in theory can handle multiple connections. Using default port 11411, I find the node displays: `Listening for rosserial TCP connection on port 11411` but never finds any devices, unlike rosserial_python serial_node.py which was successful. Am I missing something for rosserial_server to be able to identify and connect to these devices? Is there another way of connecting multiple TCP devices such as these arduinos with wifi simultaneously? Thank you for your time, Andy Below is the code on the arduino for anyone who is interested: #include #include #include #include ////////////////////// // WiFi Definitions // ////////////////////// const char* ssid = SECRET_SSID; const char* password = SECRET_PASS; IPAddress server(192, 168, 0, 100); // ip of your ROS server IPAddress ip; //Storage local IP address int status = WL_IDLE_STATUS; WiFiClient client; class WiFiHardware { public: WiFiHardware() {}; void init() { // do your initialization here. this probably includes TCP server/client setup client.connect(server, 11411); } // read a byte from the serial port. -1 = failure int read() { // implement this method so that it reads a byte from the TCP connection and returns it // you may return -1 is there is an error; for example if the TCP connection is not open return client.read(); //will return -1 when it will works } // write data to the connection to ROS void write(uint8_t* data, int length) { // implement this so that it takes the arguments and writes or prints them to the TCP connection for(int i=0; i nh; std_msgs::String msg; ros::Publisher string("outString", &msg); char hello[13] = "Hello World!"; void setupWiFi() { WiFi.begin(ssid, password); //Print to serial to find out IP address and debugging Serial.print("\nConnecting to "); Serial.println(ssid); uint8_t i = 0; while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500); if(i == 21){ Serial.print("Could not connect to"); Serial.println(ssid); while(1) delay(500); } Serial.print("Ready! Use "); ip = WiFi.localIP(); Serial.print(ip); Serial.println(" to access client"); } void setup() { //Configure pins for adafruit ATWINC1500 breakout WiFi.setPins(8,7,4); Serial.begin(9600); setupWiFi(); delay(2000); nh.initNode(); nh.advertise(string); } void loop() { msg.data = hello; string.publish(&msg); nh.spinOnce(); delay(1000); } **Actually a Teensy 3.2 because the Uno does not have enough memory, however it emulates and behaves like an Uno*

Advertising new publisher after first spin in rosserial_windows

$
0
0
Apologies for the stupid question, but I'm still trying to grasp the basic concepts of rosnodes. Is it possible to advertise a new publisher after the first spin? I'm currently using rosserial_windows and advertising a "late" publisher/topic results in a "Received message with unrecognized topic" warning and the new topic does not show in rostopic list. Is this a built-in limitation of ros nodes? Just to be clear here's the order of execution: 1. Initialize connection 2. Advertise publishers/services 3. spinOnce 4. Publish a message + spinOnce (x 100) 5. Advertise new publisher + spinOnce 6. New topic does not show up, throws warning: "Received message with unrecognized topic" Thank you!

error Mismatched protocol version in packet

$
0
0
error message: [ERROR] [1509977915.822895]: Mismatched protocol version in packet: lost sync or rosserial_python is from different ros release than the rosserial client

Unable to publish sensor_msgs/IMU message properly

$
0
0
I am using rosserial to transmit gyroscope values into ROS. I am initializing the message using the format I found [here](http://answers.ros.org/question/12782/rosserial_arduino-cant-send-a-sensor_msgsimu-msg/). At first I got an error saying the buffer was too small, so I changed the ATMEGA328P field in ros.h from "25, 25, 280, 280" to "5, 5, 512, 512". This worked, but then I started getting errors like: [INFO] [WallTime: 1428333648.941214] wrong checksum for topic id and msg [WARN] [WallTime: 1428333651.605690] Serial Port read returned short (expected 1 bytes, received 0 instead). [WARN] [WallTime: 1428333651.608523] Serial Port read failure: [WARN] [WallTime: 1428333651.626828] Serial Port read returned short (expected 8 bytes, received 1 instead). [WARN] [WallTime: 1428333651.629609] Serial Port read failure: [INFO] [WallTime: 1428333651.633695] Packet Failed : Failed to read msg data [INFO] [WallTime: 1428333651.636200] msg len is 8 [INFO] [WallTime: 1428333651.646104] wrong checksum for topic id and msg [INFO] [WallTime: 1428333653.732366] wrong checksum for topic id and msg [WARN] [WallTime: 1428333657.162546] Serial Port read returned short (expected 8 bytes, received 5 instead). From google searches, the only possible explanation I could find was to change the baud rate, however I must not have implemented it correctly as it this resulted in the error (yes, its supposed to be ttyUSB1): [INFO] [WallTime: 1428335580.534810] Connecting to /dev/ttyUSB1 at 115200 baud [ERROR] [WallTime: 1428335598.989444] Lost sync with device, restarting... I am unsure of what to try next. Any suggestions are appreciated. Here is my code: #define pi 3.14159265359 #include #include ros::NodeHandle nh; sensor_msgs::Imu imu_msg; ros::Publisher gyro("/imu/data", &imu_msg); int gyroPin = 0; //Gyro is connected to analog pin 0 float gyroVoltage = 5; //Gyro is running at 5V float gyroZeroVoltage = 2.5; //Gyro is zeroed at 2.5V float gyroSensitivity = .0125; //Our example gyro is 12.5mV/deg/sec float rotationThreshold = 1; //Minimum deg/sec to keep track of - helps with gyro drifting float currentAngle = 0; //Keep track of our current angle void setup() { //nh.getHardware()->setBaud(115200); //or what ever baud you want nh.initNode(); nh.advertise(gyro); imu_msg.header.frame_id = 0; imu_msg.orientation.x = 0.0; imu_msg.orientation.y = 0.0; imu_msg.orientation.z = 0.0; imu_msg.orientation.w = 0.0; } void loop() { //This line converts the 0-1023 signal to 0-5V float gyroRate = (analogRead(gyroPin) * gyroVoltage) / 1023; //This line finds the voltage offset from sitting still gyroRate -= gyroZeroVoltage; //This line divides the voltage we found by the gyro's sensitivity gyroRate /= gyroSensitivity; //Ignore the gyro if our angular velocity does not meet our threshold if (gyroRate >= rotationThreshold || gyroRate <= -rotationThreshold) { //This line divides the value by 100 since we are running in a 10ms loop (1000ms/10ms) gyroRate /= 100; currentAngle += gyroRate; } //Keep our angle between 0-359 degrees if (currentAngle < 0) currentAngle += 360; else if (currentAngle > 359) currentAngle -= 360; currentAngle = currentAngle * (pi/180); //convert degrees/s to radians/s imu_msg.orientation.z = currentAngle; imu_msg.header.stamp = nh.now(); gyro.publish( &imu_msg ); nh.spinOnce(); delay(1000); }

Any work underway for a rosserial_embeddedlinux python Publisher?

$
0
0
I'm planning an application on a Raspberry Pi3 (Raspbian/Linux Jessie) Google AI Kit, with a python application generating character data. The rosserial wiki embeddedlinux rosserial client "Hello Ros" (example Publisher) for a target embedded linux is cpp: http://wiki.ros.org/rosserial_embeddedlinux/Tutorials/Example%20Publisher. I understand this Client is intended to talk over a serial connection to a rosserial server node on a Linux workstation, for which there are python examples. I would add code to that example that generates /cmd_vel/twist msgs to drive a Turtlebot3. Perhaps a better question is anyone working to add a ROS interface to this Google AI Kit that provides a Raspberry Pi based interface to the Google cloud voice recognition system?

how to publish linear velocity and angular velocity rosserial arduino?

$
0
0
how to publish linear velocity and angular velocity rosserial arduino with Twist.h ? I tried geometry_msgs::TransformStamped t; t.transform.translation.x = x; t.transform.translation.y = y; t.transform.translation.z = 0; t.transform.rotation = tf::createQuaternionFromYaw(th); t.Twist.Twist.linear.x=dx/dt; t.Twist.Twist.linear.z=dth/dt; but last two lines error I need your help plz thank you.

STM32 with ROS , rosserial in Eclipse how?

$
0
0
I intend to use STM32 for communicating with ROS , rosserial look promising. Since arduino, raspberrypi can do. Other should work also. I've seen [Adding Support for New Hardware](http://wiki.ros.org/rosserial_client/Tutorials/Adding%20Support%20for%20New%20Hardware) , [IDEs](http://wiki.ros.org/IDEs) , [STM32 Microcontroller for communication with ROS](https://answers.ros.org/question/250667/stm32-microcontroller-for-communication-with-ros/) I can read/write function uart to STM32 which use GNU ARM toolchain compiler and library from ST with Eclipse. Also I can import package that publish and subscribe message into Eclipse. Those import package in Eclipse can RUN, DEBUG no problem so far.. But NO IDEA how to somehow mix 2 together , ros packge and stm32 source , (#include "ros/ros.h" and stuff into STM32 source) and build them to flash into STM32 microcontroller. I intend to create node in STM32 and subscribe sensor to PC or SBC run ROS or Subscribe some motor control or other control. Since it has more more memory and horse power than arduino. Also benefit of RTOS Any help please?

ros.h no such file or directory

$
0
0
Im using ROS Kinetic I tried every related post but no positive ouput. Im trying to compile simple HelloRoS.cpp using Raspberry Pi. I have no idea whats wrong. I included all possible packages still getting this error while cmake. I have put all the rosserial files inside my ros workspace. please could anyone send me their cmakelist.txt and package.xml so that i can see which line Im missing. Why ros.h isnt being found. Also, I have sourced my workspace and did catkin_make from the workspace and again for compilation i did cmake outside rosserial_embeddedlinux src, is that the way to compile ? What are the steps to compile a cpp file and to generate proper makefile.

Rosserial arduino connection error

$
0
0
Hello everyone, I am currently trying to connect my arduino due to my pc in order to run my ROS package I wrote, which shall communicate with the arduino. I can compile and upload my program via the GUI. To start the serial connection, I run: rosrun rosserial_python serial_node.py /dev/ttyACM0 Which produces the output: [INFO] [1499369503.299387]: ROS Serial Python Node [INFO] [1499369503.305172]: Connecting to /dev/ttyACM0 at 57600 baud [ERROR] [1499369520.430946]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino I don't really understand the message. I wrote all my nodes in ROS kinetic and also installed rosserial via: sudo apt-get install ros-kinetic-rosserial-arduino sudo apt-get install ros-kinetic-rosserial just like it was done in the tutorial. Why is the arduino assigned to a particular ROS version anyway? How can I set this to kinetic? I am working on a virtual box with Ubuntu 16.04 Does somebody know how to solve that problem? Thanks in advance, Felix

cant assign the value to 'cmd_msg.data' in runtime.

$
0
0
I am doing a stepper motor programming.*what i want is "when i enter an angle on command line,then stepper should rotate that angle"*. but i cant assign the value in runtime. help me please. #include #include #include signed int angle; int enable2 = 13; const int stepPin = 9; const int dirPin = 8; int x; ros::NodeHandle nh; void pwm( const std_msgs::UInt16& cmd_msg) { analogWrite(enable2, cmd_msg.data); angle=analogRead(enable2); } ros::Subscriber sub("servo", pwm); void setup(){ // pinMode(angle, OUTPUT); pinMode(enable2, OUTPUT); pinMode(stepPin,OUTPUT); pinMode(dirPin,OUTPUT); nh.initNode(); nh.subscribe(sub); // servo.attach(9); //attach it to pin 9 } void loop() { if (angle<0) { cw(); delay(100); } else { ccw(); delay(100); } delay(10000); nh.spinOnce(); delay(1); } void cw() { digitalWrite(dirPin,LOW); for(x = 0; x < 17.77*(angle*-1); x++) { digitalWrite(stepPin,HIGH); delayMicroseconds(500); digitalWrite(stepPin,LOW); delayMicroseconds(500); }} void ccw() { digitalWrite(dirPin,HIGH); for(x = 0; x < 17.77*angle; x++) { digitalWrite(stepPin,HIGH); delayMicroseconds(500); digitalWrite(stepPin,LOW); delayMicroseconds(500); }}

How to publish negative values from command line ?

$
0
0
When i try this command.i got an error like this.How can i publish negative values from command line ? rostopic pub servo std_msgs/UInt16 -180 Usage: rostopic pub /topic type [args...] rostopic: error: no such option: -8

Arduino rosserial - Unable to sync with device

$
0
0
When I try to use the 'Hello World' program with rosserial and arduino after restarting my pc. The code works fine, however once i stop the serial communication and try to rerun the same code. I get the following error. [INFO] [WallTime: 1399983521.604184] ROS Serial Python Node [INFO] [WallTime: 1399983521.617853] Connecting to /dev/ttyACM0 at 57600 baud [ERROR] [WallTime: 1399983538.726124] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino I am facing the same issue using both arduino UNO and arduino Nano. I have tried increasing the buffer size in ros.h, setting the baud rate in arduino code with Serial.begin(57600) and all the solutions mentioned in [link](https://answers.ros.org/question/210875/arduino-rosserial-unable-to-sync-with-device/). What else can i do to fix the problem ?

unable to integrate MPU6050 with ros

$
0
0
I am trying to get yaw pitch roll from an MPU6050 imu using the following code(some parts of code removed for clarity). Its getting uploaded #include #include #include #include #include ros::NodeHandle nh; geometry_msgs::Vector3 yaw_pitch_roll; ros::Publisher pubyaw_pitch_roll("yaw_pitch_roll", &yaw_pitch_roll); MPU6050 mpu; // Timers unsigned long timer = 0; float timeStep = 0.01; // Pitch, Roll and Yaw values float pitch = 0; float roll = 0; float yaw = 0; void setup() { nh.initNode(); nh.advertise(pubyaw_pitch_roll); //main problem here mpu.calibrateGyro(); } void loop() { timer = millis(); yaw_pitch_roll.x = yaw; yaw_pitch_roll.y = pitch; yaw_pitch_roll.z = roll; pubyaw_pitch_roll.publish( &yaw_pitch_roll ); nh.spinOnce(); delay(100); } But when i try to run the following command in terminal after uploading: `rosrun rosserial_python serial_node.py /dev/ttyACM0 _baud:=57600` I get the following error: `[ERROR] [1517073128.320418]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino ` Now, I have run many arduino programs using same configurations( baud_rate) and commands. But this is the only program thats giving me a tough time. Also when i remove the following line: ` mpu.calibrateGyro();` the program runs fine. Can anyone suggest me any workaround for this? NOTE: I have tried to change the baudrate to `115200` and serial port is also right(other programs run fine) and message is not too big( i have sent the same message in other programs)

Data loss in rosserial for arduino to pc

$
0
0
Hi there. I using rosserial to communicate pc to arduino. I use timer interruptions for publishing. But, when I use timer interruptions, rosserial said "wrong checksum for topic id and msg". This error occurs in almost same timing, such as one in 20 seconds. Is there anyone who understands the cause? Thanks in advance. My codes here. #include #include #include ros::NodeHandle nh; std_msgs::UInt64 msgs; ros::Publisher unnamed_publisher("empty_topic", &msgs); void intFunc() { msgs.data = millis(); unnamed_publisher.publish(&msgs); } void setup() { nh.initNode(); nh.advertise(unnamed_publisher); // Interrupt 50 hz int secToMicro = 1e6; int Hz = 100; CurieTimerOne.start(secToMicro / Hz, intFunc); } void loop() { delay(100); nh.spinOnce(); }

Prefix transformations from OpenCR

$
0
0
I am trying to run rrt_exploration on my turtlebot3. I need to prefix all per-robot nodes, topics, and transforms with a per-robot name such as "robot_1". I can do this the usual way for all nodes and topics with `` in my launch file and for almost all transforms with `` in the node that provides the transform. However, this does not work for transforms that are published by the OpenCR via rosserial_python such as `odom`. How can I change the name of the transforms published by the rosserial_python node? Re-flashing the openCR is not an option, as this must be extensible to multi-robot systems.

Arduino Publisher publish() is sometimes very slow.

$
0
0
Hi! I'm currently trying to use a NodeMCU ESP8266-12E and a GY-521 breakout board (MPU6050 IMU) to send data to my computer via WiFi. I've set up the connection via rosrun rosserial_python serial_node tcp It connects just fine and sends data at around 400Hz, which is fine. But sometimes the the publish() method in my code (see below) takes upwards of 2 seconds to complete. I've made sure that there's always data to transmit and all that. Is this due to it never timing out and requiring that someone is actually receiving the message? (tcp) or am I doing something weird. Any help is appreciated. I'm using the ros_lib library aswell as the ESP8266 library for Arduino. #include #include #include #include #define LED D0 #define BRIGHT 250 //max led intensity (1-500) #define INHALE 750 //Inhalation time in milliseconds. #define PULSE INHALE*1000/BRIGHT // Select SDA and SCL pins for I2C communication const uint8_t scl = D1; const uint8_t sda = D2; // Sensitivity scaling according to documentation const uint16_t AccelScaleFactor = 16384; const uint16_t GyroScaleFactor = 131; //Calibration ting float offsetAccelX = 0; float offsetAccelY = 0; float offsetGyroZ = 0; // MPU6050 Slave Device Address const uint8_t MPU6050SlaveAddress = 0x68; // MPU6050 few configuration register addresses const uint8_t MPU6050_REGISTER_SMPLRT_DIV = 0x19; const uint8_t MPU6050_REGISTER_USER_CTRL = 0x6A; const uint8_t MPU6050_REGISTER_PWR_MGMT_1 = 0x6B; const uint8_t MPU6050_REGISTER_PWR_MGMT_2 = 0x6C; const uint8_t MPU6050_REGISTER_CONFIG = 0x1A; const uint8_t MPU6050_REGISTER_GYRO_CONFIG = 0x1B; const uint8_t MPU6050_REGISTER_ACCEL_CONFIG = 0x1C; const uint8_t MPU6050_REGISTER_FIFO_EN = 0x23; const uint8_t MPU6050_REGISTER_INT_ENABLE = 0x38; const uint8_t MPU6050_REGISTER_ACCEL_XOUT_H = 0x3B; const uint8_t MPU6050_REGISTER_SIGNAL_PATH_RESET = 0x68; int16_t AccelX, AccelY, AccelZ, Temperature, GyroX, GyroY, GyroZ; const char* ssid = "RobustRC"; const char* password = "superspeedveryfastwow"; bool runOnce = true; // Set the rosserial socket server IP address (Simply the IP of the host computer running roscore) IPAddress server(192, 168, 1, 11); // Set the rosserial socket server port (Standard communication port for rosserial) const uint16_t serverPort = 11411; ros::NodeHandle nh; geometry_msgs::Vector3Stamped vec3_msg; ros::Publisher imuPublisher("imuData0", &vec3_msg); void setup() { pinMode(LED, OUTPUT); // LED pin as output. //Serial.begin(115200); Wire.begin(); MPU6050_Init(); calibrateMPU6050(); // Connect the ESP8266 the the wifi AP using the information provided above. WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { for (int i = 1; i < BRIGHT; i++) { digitalWrite(LED, LOW); // turn the LED on. delayMicroseconds(i * 10); // wait digitalWrite(LED, HIGH); // turn the LED off. delayMicroseconds(PULSE - i * 10); // wait delay(0); //to prevent watchdog firing. } //ramp decreasing intensity, Exhalation (half time): for (int i = BRIGHT - 1; i > 0; i--) { digitalWrite(LED, LOW); // turn the LED on. delayMicroseconds(i * 10); // wait digitalWrite(LED, HIGH); // turn the LED off. delayMicroseconds(PULSE - i * 10); // wait i--; delay(0); //to prevent watchdog firing. } } // Set the connection to rosserial socket server and start the node. nh.getHardware()->setConnection(server, serverPort); nh.initNode(); // Start publisher nh.advertise(imuPublisher); } void loop() { if (!nh.connected()) { digitalWrite(LED, LOW); } Read_RawValue(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_XOUT_H); vec3_msg.vector.x = (float)AccelX / AccelScaleFactor - offsetAccelX; // Accelerometer x vec3_msg.vector.y = (float)AccelY / AccelScaleFactor - offsetAccelY; // Accelerometer y vec3_msg.vector.z = (float)GyroZ / GyroScaleFactor - offsetGyroZ; // Yaw rate vec3_msg.header.stamp = nh.now(); vec3_msg.header.frame_id = "0"; if (nh.connected()) { // Send the content // This part sometimes freezes the whole thing over for anywhere from 50 to 1800 ms. imuPublisher.publish(&vec3_msg); digitalWrite(LED, HIGH); } nh.spinOnce(); // No delay just run as fast as possible. Adding one does not solve the issue of freezing. } // read all 14 register void Read_RawValue(uint8_t deviceAddress, uint8_t regAddress) { Wire.beginTransmission(deviceAddress); Wire.write(regAddress); Wire.endTransmission(); Wire.requestFrom(deviceAddress, (uint8_t)14); AccelX = (((int16_t)Wire.read() << 8) | Wire.read()); AccelY = (((int16_t)Wire.read() << 8) | Wire.read()); AccelZ = (((int16_t)Wire.read() << 8) | Wire.read()); Temperature = (((int16_t)Wire.read() << 8) | Wire.read()); GyroX = (((int16_t)Wire.read() << 8) | Wire.read()); GyroY = (((int16_t)Wire.read() << 8) | Wire.read()); GyroZ = (((int16_t)Wire.read() << 8) | Wire.read()); } void I2C_Write(uint8_t deviceAddress, uint8_t regAddress, uint8_t data) { Wire.beginTransmission(deviceAddress); Wire.write(regAddress); Wire.write(data); Wire.endTransmission(); } //configure MPU6050 void MPU6050_Init() { delay(200); I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SMPLRT_DIV, 0x07); I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_1, 0x01); I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_2, 0x00); I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_CONFIG, 0x00); I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_GYRO_CONFIG, 0x00);//set +/-250 degree/second full scale I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_CONFIG, 0x00);// set +/- 2g full scale I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_FIFO_EN, 0x00); I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_INT_ENABLE, 0x01); I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SIGNAL_PATH_RESET, 0x00); I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_USER_CTRL, 0x00); delay(200); } //Calibrate MPU6050 (Remove small offsets) void calibrateMPU6050() { for (size_t i = 0; i < 500; i++) { Read_RawValue(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_XOUT_H); offsetAccelX += (float)AccelX / AccelScaleFactor; // Accelerometer x offsetAccelY += (float)AccelY / AccelScaleFactor; // Accelerometer y offsetGyroZ += (float)GyroZ / GyroScaleFactor; } offsetAccelX = offsetAccelX / 500; offsetAccelY = offsetAccelY / 500; offsetGyroZ = offsetGyroZ / 500; }

Rosserial mbed comunication does not work

$
0
0
Hello, I am working on Ubuntu 16.04 and ROS Kinetic. I downloaded rosserial jade-devel since there is no branch for Kinetic. I have read that some people used it and it worked. When I am trying to connect to my STM using "rosrun rosserial_python serial_node.py _port:=/dev/ttyUSB0 _baud:=115200" there is an allert: "[ERROR] [1518733110.399872]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino". I am using mbed online compiler, I tried to change baud rate and library on compiler to both kinetic and jade mbed. My USB-UART device is connected to ttyUSB0. Is there an official Kinetic rosserial version? Do You have any idea what should I do to fix it and make it run? Thank You for answers.

nh.spinOnce() always returning either -1 or -2

$
0
0
Hi, i am using rosserial on a ESP32 with rosserial_python via tcp on the ROS master. I can send data (publish) incredibly fast, but i cannot sync with the rosserial_python server, spinOnce() either blocks my program or returns -1 or -2 everytime (which means SPIN_ERR and SPIN_TIMEOUT) and happens in this part of code from ros_lib: file node_handle.h, in function spinOnce() : if (topic_ == TopicInfo::ID_PUBLISHER) { requestSyncTime(); negotiateTopics(); last_sync_time = c_time; last_sync_receive_time = c_time; return SPIN_ERR; } Do you know why theres an error here ? Or what does the IF do? Regards, ogensyts

can you install rosserial in raspbian with ros indigo

$
0
0
I need to install rosserial in raspbian OS with ROS Indigo
Viewing all 314 articles
Browse latest View live