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

maoqizhen's profile - activity

2015-04-23 09:15:15 -0500 received badge  Famous Question (source)
2014-07-22 04:16:44 -0500 received badge  Famous Question (source)
2014-05-15 09:14:30 -0500 received badge  Notable Question (source)
2014-05-15 09:14:30 -0500 received badge  Popular Question (source)
2014-05-02 09:02:13 -0500 received badge  Notable Question (source)
2014-05-02 09:02:13 -0500 received badge  Famous Question (source)
2014-02-23 20:52:48 -0500 received badge  Famous Question (source)
2013-11-07 02:21:52 -0500 received badge  Notable Question (source)
2013-09-01 12:34:46 -0500 received badge  Famous Question (source)
2013-07-03 04:39:40 -0500 received badge  Notable Question (source)
2013-06-19 00:12:33 -0500 received badge  Popular Question (source)
2013-05-13 14:41:24 -0500 received badge  Popular Question (source)
2013-05-10 11:49:59 -0500 asked a question message types of topics concerning map

I am developing an android app communicating with ros, but I don't know the information about map. I have topic names but I don't know which message types should I use. I found on the Internet but failed. Here is the list of topics I need.It's better if I can know more details of those topics. 1. Move_base_simple/goal 2. nitial_pose 3. Move_base/local_costmap/inflated_obstacles 4. move_base/NavfnROS/plan 5.move_base/local_costmap/robot_footprint 6.move_base/local_costmap/obstacles Thanks a lot.

2013-05-07 11:23:50 -0500 received badge  Notable Question (source)
2013-04-07 22:00:35 -0500 asked a question ros audio_common play Problem

I want to transmit mp3 stream to a tablet running android, and play it on tablet. I have implemented an android program to receive stream and write in a receiver.mp3 file. but I cannot play it. I guess is is something about decorder problem. Confused. Here is my source code.

public class audio_receiver<T> implements NodeMain {
 private String topicName;
 private String messageType;
 private MessageCallable<byte[], audio_common_msgs.AudioData> callable;
 private File file;
 private MediaPlayer mediaPlayer;
 private String mFilePath;
 private int mSampleRate;
 private FileOutputStream output;
 private boolean isRecording;
public audio_receiver(){
    isRecording= true;
    this.mFilePath = Environment.getExternalStorageDirectory() + "/receiver.mp3";
    this.mSampleRate = 8000;
    this.file = new File(mFilePath);
    mediaPlayer = new MediaPlayer();
    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mediaPlayer.setOnCompletionListener (new OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer arg0) {
            // TODO Auto-generated method stub
            arg0.stop();
        }
    });
    try {
        mediaPlayer.setDataSource(mFilePath);
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        output = new FileOutputStream(file);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    };
}
@Override
public GraphName getDefaultNodeName() {
    // TODO Auto-generated method stub
    return GraphName.of("rosjava_tutorial_image_transport/audio_receiver");
}
public void setTopicName(String topicName) {
    this.topicName = topicName;
  }
public void setMessageType(String messageType) {
    this.messageType = messageType;
  }
public void setMessageToByteCallable(MessageCallable<byte[], audio_common_msgs.AudioData> callable) {
    this.callable = callable;
  }
@Override
public void onError(Node arg0, Throwable arg1) {
    // TODO Auto-generated method stub

}
@Override
public void onShutdown(Node arg0) {
    // TODO Auto-generated method stub

}
@Override
public void onShutdownComplete(Node arg0) {
    // TODO Auto-generated method stub

}
@Override
public void onStart(ConnectedNode connectedNode) {
    // TODO Auto-generated method stub
    Subscriber<T> subscriber = connectedNode.newSubscriber(topicName, messageType);
    subscriber.addMessageListener(new MessageListener<T>() {
      @Override
      public void onNewMessage(final T message) {
        if(isRecording){
            playAudio(callable.call((AudioData) message));
        }
      }
    });

}
public void playAudio(byte[] inputAudio){
    /*FileOutputStream output = null;
    try {
        output = new FileOutputStream(file);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    };*/
    try {
        output.write(inputAudio, 0, inputAudio.length);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    /*try {
        output.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        try {
            mediaPlayer.prepare();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 
    mediaPlayer.start();*/

}
public void stop(){
    isRecording= false;
    try {
        output.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        mediaPlayer.prepare();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    mediaPlayer.start();
}

} here is program similar to rosimageview.java

public class audioByteFromRosMsg implements MessageCallable<byte[], audio_common_msgs.AudioData> {

@Override
public byte[] call(AudioData message) {
    // TODO Auto-generated method stub
    ChannelBuffer buffer = message.getData();
    byte[] data = buffer.array();
    return data;
}

}here is program to transfer message to byte[] and I execute audioReceiver in nodeMainExecutor in mainActivity. I use audio_common but I prefer PWM format, mp3 has so many problem with codec and decode. have any idea of using other tools? my aim is just transmitting and receiving audio signal between ros and android.

2013-04-07 15:14:33 -0500 received badge  Popular Question (source)
2013-04-01 20:32:08 -0500 received badge  Popular Question (source)
2013-03-21 12:30:33 -0500 commented answer what's rosjava mechanism on android?

Thanks , I am more clear now

2013-03-21 00:13:24 -0500 asked a question what's audio type of audio_common msg

on android,I want to receive and play audio recorded on ros, but I don't know stream type of the audio, is it mp3 or PWM, and what's sample rate and bit rate, confused ?

2013-03-21 00:07:33 -0500 asked a question what's rosjava mechanism on android?

I saw on the Internet that the java library is just a reference to ros package, if on 2 PCs java program can execute corresponding ros nodes, but on android platform , there is no ros node available, how can this be executed. I mean, maybe ros nodes are in C++, and java can just run that on ros, but on android, how can java run these packages?

2013-03-19 02:33:45 -0500 answered a question Defining Custom Message Types for Rosjava Android

I saw on the Internet that the java library is just a reference to ros package, if on 2 PCs java program can execute corresponding ros nodes, but on android platform , there is no ros node available, how can this be executed. I mean, maybe ros nodes are in C++, and java can just run that on ros, but on android, how can java run these packages?

2013-03-19 02:26:10 -0500 commented answer android_tutorial_image_transport cannot receive image

I need to set ros_ip in every terminal, and need to run roscore at the same time, any idea to set ros_ip so I don't need to set it in every terminal ?

2013-03-19 02:23:50 -0500 received badge  Scholar (source)
2013-03-15 03:20:27 -0500 asked a question android_tutorial_image_transport cannot receive image

I run android_tutorial_image_transport on android, but cannot receive image from PC, image node on PC is ok,but logcat says :03-15 13:56:37.209: E/UpdatePublisherRunnable(10447): java.lang.RuntimeException: java.net.UnknownHostException: ubuntu