WowWee Rovio API for ROS Groovy

Source: Internet
Author: User
Document directory
  • 1. Download rovi_base package into your catkin workspace (here is ros_ws)

Posted @ from [FreedomShe]

I 've been playing the WowWee Rovio car for a while. I sorted out the code I wrote earlier. In ROS Groovy, I encapsulated the CGI interface of WowWee Rovio, the main encapsulation is the control interface (three full wheels, camera) and image interface (in order to save traffic, the video stream is not used to obtain the image, but the request is used to response the real-time image ), MCU Report interface (Including Infrared sensing, encoding disk information, and battery information ).

Environment: Ubuntu 12.10 + Ros groovy (catkin workspace)

Popular Science

WowWee Rovio is a Wi-Fi car of WowWee in earlier years. For robot enthusiasts, its power lies in good hardware configuration:

  1. Three full wheels with three encoding Sensors
  2. WIFI + camera
  3. Bidirectional speech
  4. One infrared obstacle Sensor

For general players, its highlight is the Polaris navigation system. the built-in WEB Control page is easy to access control and has a high appearance. Unfortunately, foreign garbage is popular in China, the battery is aging, the quality of the built-in components is poor, the circuit design is outdated, and the unreasonable efficiency is low, so that most products may crash at any time, it has no practical value for ordinary players. However, for Robot enthusiasts, some modifications can also become useless.
ROS (Robot Operating System) does not need to talk about it. It will always be one step behind other people in Robot Research.

How to use rovi_base package to develop with Rovio API1. Download rovi_base package into your catkin workspace (here is ros_ws)
$ cd ~/ros_ws/src$ git clone https://github.com/yuanboshe/rovio_base.git
2. Edit roviserver. launch
$ roscd rovio_base$ gedit launch/rovioServer.launch

Change the parameter values to yours

<param name="/rovio_base/host" type="string" value="192.168.10.18" />  <param name="/rovio_base/port" type="string" value="80" />  <param name="/rovio_base/user" type="string" value="admin" />  <param name="/rovio_base/pw" type="string" value="admin" />
3. Create rovi_test package
$ cd ~/ros_ws/src$ catkin_create_pkg rovio_test std_msgs roscpp cv_bridge
4. Create rovitest. cpp
$ roscd rovio_test$ gedit src/rovioTest.cpp

Paste the following code in to rovitest. cpp and save.

#include "ros/ros.h"#include "rovio_base/manDrv.h"#include "rovio_base/image.h"#include "rovio_base/report.h"#include <cv_bridge/cv_bridge.h>#include <sensor_msgs/image_encodings.h>#include <opencv2/opencv.hpp>int main(int argc, char **argv){  ros::init(argc, argv, "rovioTest");  ros::NodeHandle n;  ros::ServiceClient imageClient = n.serviceClient<rovio_base::image>("rovioImage");  ros::ServiceClient controlClient = n.serviceClient<rovio_base::manDrv>("rovioControl");  ros::ServiceClient reportClient = n.serviceClient<rovio_base::report>("rovioReport");  rovio_base::image imageSrv;  rovio_base::manDrv controlSrv;  rovio_base::report reportSrv;  // Head middle control  controlSrv.request.drive = 13;  controlSrv.request.speed = 9;  if (controlClient.call(controlSrv))  {    ROS_INFO("Control response code: %d", (int )controlSrv.response.code);  }  else  {    ROS_ERROR("Failed to call service rovioControl");    return 1;  }  // Get report info  if (reportClient.call(reportSrv))  {    int length = reportSrv.response.length;    int lDirection = reportSrv.response.lDirection;    int lNum = reportSrv.response.lNum;    int rDirection = reportSrv.response.rDirection;    int rNum = reportSrv.response.rNum;    int rearDirection = reportSrv.response.rearDirection;    int rearNum = reportSrv.response.rearNum;    int headPosition = reportSrv.response.headPosition;    bool isLedOn = reportSrv.response.isLedOn;    bool isIrOn = reportSrv.response.isIrOn;    bool isDetectedBarrier = reportSrv.response.isDetectedBarrier;    ROS_INFO("MCU Report:\nlength=%d", length);    ROS_INFO("Left direction:num=%d:%d", lDirection, lNum);    ROS_INFO("Right direction:num=%d:%d", rDirection, rNum);    ROS_INFO("Rear direction:num=%d:%d", rearDirection, rearNum);    ROS_INFO("headPosition=%d", headPosition);    ROS_INFO("isLedOn=%d,isIrOn=%d,isDetectedBarrier=%d", isLedOn, isIrOn, isDetectedBarrier);  }  else  {    ROS_ERROR("Failed to call service rovioReport");    return 1;  }  // Show images from camera  for (int i = 0; i < 20; i++)  {    if (imageClient.call(imageSrv))    {      ROS_INFO("Image size: %dx%d", (int )imageSrv.response.img.width, (int )imageSrv.response.img.height);      cv_bridge::CvImagePtr cvImgPtr;      try      {        cvImgPtr = cv_bridge::toCvCopy(imageSrv.response.img, sensor_msgs::image_encodings::BGR8);        cv::imshow("", cvImgPtr->image);        cv::waitKey(100);      }      catch (cv_bridge::Exception& e)      {        ROS_ERROR("cv_bridge exception: %s", e.what());        return 1;      }    }    else    {      ROS_ERROR("Failed to call service rovioImage");      return 1;    }  }  // Head down control  controlSrv.request.drive = 12;  controlSrv.request.speed = 9;  if (controlClient.call(controlSrv))  {    ROS_INFO("Control response code: %d", (int )controlSrv.response.code);  }  else  {    ROS_ERROR("Failed to call service rovioControl");    return 1;  }  return 0;}

About how to use the API, you can refer to Rovio API document. the above test program shows that three services you can use: "rovicontrol", "roviimage" and "rovioReport ". you can find them as ManualDrive (), GetImage, GetMCUReport () in the above document.

Also, you may prefer to use the rovioParser class directly, that avoids using ROS's service and client frame.

5. Edit the rovi_test CMakeLists.txt located ~ /Row_ws/src/rovi_test/CMakeLists.txt and change the related regions as follows (or just add at the end)
add_executable(rovioTest src/rovioTest.cpp)  target_link_libraries(rovioTest ${catkin_LIBRARIES})
6. Build the packages
$ cd ~/ros_ws/$ catkin_make
7. Run them to test

Run the follow commands in three terminals respectively

$ roscore$ roslaunch rovio_base rovioServer.launch$ rosrun rovio_test rovioTest

After you executed the last command, your WowWee Rovio wowould head middle and head down, and you wowould view the images from camera 2 seconds.

In the terminal of the test program rovitest node, the Control response code is 0, the MCU Report length is> 0, and the Image size shows the correct value. Then, the three services calls return the correct data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.