ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

zyb1777's profile - activity

2022-06-17 14:43:16 -0500 received badge  Famous Question (source)
2022-05-01 13:40:53 -0500 received badge  Notable Question (source)
2022-03-20 00:01:12 -0500 received badge  Popular Question (source)
2022-03-05 12:49:21 -0500 asked a question How to subscribe sensor_msg/Imu via rosserial_arduino

How to subscribe sensor_msg/Imu via rosserial_arduino I am very new to ROS, please help. My system is ubuntu 18.04 and u

2022-03-05 12:45:51 -0500 asked a question How to subscribe sensor_msg/IMU from rosserial arduino

How to subscribe sensor_msg/IMU from rosserial arduino I am very new to ROS, please help. My system is ubuntu 18.04 and

2020-06-08 17:59:13 -0500 received badge  Popular Question (source)
2020-06-08 17:59:13 -0500 received badge  Famous Question (source)
2020-06-08 17:59:13 -0500 received badge  Notable Question (source)
2018-03-26 11:07:16 -0500 received badge  Famous Question (source)
2018-03-26 09:58:07 -0500 received badge  Notable Question (source)
2017-03-01 07:35:52 -0500 received badge  Popular Question (source)
2016-12-23 01:25:00 -0500 received badge  Enthusiast
2016-11-11 02:32:59 -0500 asked a question How to use rospublisher to publish a byte value

I did a s.bus reading on ardiuno, it can work perfectly when i link to ROS, but there is problem with my code:

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

#include <FUTABA_SBUS.h>
#include <Streaming.h>


int maximumRange = 400; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance
byte localdata[25] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
double Kp=0, Ki=0, Kd=1;
double Setpoint, Input, Output;
int i=0;

FUTABA_SBUS sBus;

ros::NodeHandle nh;
std_msgs::String str_msg;
ros::Publisher chatter("sbusdata", &str_msg);

void sbus_encoder()
{
   localdata[0] = sBus.sbusData[0];
   localdata[1] = (sBus.channels[0]  );
   localdata[2] = (sBus.channels[0]>>8 | sBus.channels[1]<<3);
   localdata[3] = (sBus.channels[1]>>5 | sBus.channels[2]<<6);
   localdata[4] = (sBus.channels[2]>>2);
   localdata[5] = (sBus.channels[2]>>10 | sBus.channels[3]<<1);
   localdata[6] = (sBus.channels[3]>>7 | sBus.channels[4]<<4);
   localdata[7] = (sBus.channels[4]>>4 | sBus.channels[5]<<7);
   localdata[8] = (sBus.channels[5]>>1);
   localdata[9] = (sBus.channels[5]>>9 | sBus.channels[6]<<2);
   localdata[10] = (sBus.channels[6]>>6 | sBus.channels[7]<<5);
   localdata[11] = (sBus.channels[7]>>3);
   localdata[12] = (sBus.channels[8]  );
   localdata[13] = (sBus.channels[8]>>8 | sBus.channels[9]<<3);
   localdata[14] = (sBus.channels[9]>>5 | sBus.channels[10]<<6);
   localdata[15] = (sBus.channels[10]>>2);
   localdata[16] = (sBus.channels[10]>>10 | sBus.channels[11]<<1);
   localdata[17] = (sBus.channels[11]>>7 | sBus.channels[12]<<4);
   localdata[18] = (sBus.channels[12]>>4 | sBus.channels[13]<<7);
   localdata[19] = (sBus.channels[13]>>1);
   localdata[20] = (sBus.channels[13]>>9 | sBus.channels[14]<<2);
   localdata[21] = (sBus.channels[14]>>6 | sBus.channels[15]<<5);
   localdata[22] = (sBus.channels[15]>>3);
   localdata[23] = sBus.sbusData[23]; //flag
   localdata[24] = 0x00;

   for(int i=0;i<25;i++)
      {
        //Serial1.write(localdata[i]);
          str_msg.data = localdata[i];
          chatter.publish(&str_msg);
      }
}



void setup(){
  sBus.begin();
  Serial.begin(115200);


   nh.initNode();
   nh.advertise(chatter);


   // sBus.channels[0]=990;
}

void loop(){

  sBus.FeedLine();
  sBus.PassthroughSet(0);
  if (sBus.toChannels == 1){
   //sBus.UpdateServos();
    sBus.UpdateChannels();
    sBus.toChannels = 0;
    if(sBus.channels[5]>1500)//limit
{
     if(sBus.channels[0]>1000)//throttle limit
     { sBus.channels[0]=1000;}
     if(sBus.channels[1]<940)//left yaw limit
     {sBus.channels[1]=940;}
      if(sBus.channels[1]>1040)//right yaw limit 
     {sBus.channels[1]=1040;}
     if(sBus.channels[2]<940)//pitch infront limit
     {sBus.channels[2]=940;}
      if(sBus.channels[2]>1040)//pitch backwards limit
     {sBus.channels[2]=1040;}
     if(sBus.channels[3]<940)//roll left limit
     {sBus.channels[3]=940;}
      if(sBus.channels[3]>1040)//roll right limit
     {sBus.channels[3]=1040;}     
    }



sbus_encoder();




  }

}

This is the error shown:

sbus_example.pde: In function ‘void sbus_encoder()’:
 sbus_example.pde:56:35: error: invalid conversion from ‘byte {aka unsigned char}’ to ‘std_msgs::String::_data_type {aka const char*}’ [-fpermissive]

How can i convert this code so that the publisher ... (more)

2016-11-10 03:35:42 -0500 asked a question How can i read futaba sbus signal(serial bus) through usb adapter

Hi there I have a ongoing project regarding an indoor autonomous drone. My idea was to use a rp lidar to sense the surrounding and obstacles given. The transmitter's receiver will be connected a USB adapter to a NUC through ROS, this is to allow me to edit the sbus signal to the flight controller. However the problem i faced right now is that the signal from the receiver shown in the ROS is gabled.

The result shown is attached below.

papapa@papapa-desktop:~/catkin_ws$ ls /dev/ttyUSB*
/dev/ttyUSB0
papapa@papapa-desktop:~/catkin_ws$ rosrun serial serial_example /dev/ttyUSB0 115200 
9, String read: ���`���
9, String read: �`���s^�
9, String read: �P���o��
9, String read: �`���s^
9, String read: �`���s^
9, String read: ��?s�s
9, String read: �P���o
9, String read: �P���o��
9, String read: �`���s^
9, String read: �`���o��
9, String read: �`���s^�
9, String read: �P���s\

The installed serial package http://github.com/wjwwood/serial.git

and the edited example http://www.jianshu.com/p/c30f390427e7

Thank you for your help.

My USB adapter is baite13-009a and receiver is frsky x4r

however the result was garbled. Can you help me with this issue?