Skip to content

Basic Packages (AutoNOMOS Model v2)

AutoModelCar edited this page Mar 29, 2018 · 3 revisions

The catkin_ws folder in the model car contains preinstalled packages which can help you to develop your own code. They consist of sensor- and actuator nodes.

Figure 9: Basic ROS Packages preinstalled in the car.

The purpose of the packages should be apparent from their names. In the next sections we review each one of them.

Rplidar_ros

rplidarNode is a driver for RPLIDAR. It reads RPLIDAR raw scan result using RPLIDAR's SDK and converts them to ROSLaserScan messages.

Published Topics

scan (sensor_msgs/LaserScan)                it publishes scan topic from the laser

Services

stop_motor(std_srvs/Empty)
start_motor (std_srvs/Empty)

Parameters

serial_port (string,default: /dev/ttyLidar)  serial port name used in your system.
serial_baudrate (int, default: 115200)      serial port baud rate.
frame_id (string, default: laser)           frame ID for the device
inverted (bool, default: false)             indicates if the LIDAR is mounted inverted.
angle_compensate (bool, default: true)      indicates if the driver needs to do angle compensation.

Launch File Examples

Start a rplidarNode and view the scan result in using “rostopic echo scan”.

$ roslaunch rplidar_ros rplidar.launch

Serial

Serial is a cross-platform, simple to use library for using serial ports on computers. This library provides a C++, object oriented interface for interacting with RS-232 like devices on Linux and Windows.

send_steering_light (NOT IMPLEMENTED YET)

send_steering_light Node sends desired steering angle and light command through serial port to Arduino. It reads the desired steering angle in integer and convert to string message.

It sends also specified strings over the led_controller node through the control board in order to turn the lights on/off.

 string    Light
 ____________________________________________
 le        Blinking yellow left
 ri        Blinking yellow right
 stop      Turn on the three red tail lights (braking)
 pa        Turn on the two red back lights, and two white front lights
 ta        Turn on the two red back lights, and two white front lights
 re        Turn on the white lights at the back for going backwards.
 fr        Turn on the two white headlights for driving at night
 diL       Turnoff the lights

Subscribed Topics

 manual_control/steering  (std_msgs/Int16)    .
 manual_control/lights  (std_msgs/String) 

Launch File Examples

Start a steering node and change the car’s steering angle.

    $ roslaunch send_steering_light servo_light_odroid.launch
    $ rostopic pub -r 1 /manual_control/steering std_msgs/Int16  '{data: 90}'
    $ rostopic pub -r 1 /manual_control/lights std_msgs/String  '{data: le}'

motor_communication

motor_communication Node sends desired velocity and steering via the bldc_controller node through the control board to engine/servo motor. It reads desired velocity in integer and convert to string message.

Subscribed Topics

    manual_control/speed     (std_msgs/Int16)        desired velocity (in rpm).
    manual_control/steering  (std_msgs/Int16)        desired steering (in degree from 0 to 180).

Launch File Examples

Start a motor_communication node and change motor speed.

   $ roslaunch bldc_board_communication bldc_board_communication.launch
   $ roslaunch motor_communication motor_odroid.launch
   $ rostopic pub -r 1 manual_control/stop_start std_msgs/Int16  '{data: 0}'   # press control+c after 2 seconds
   $ rostopic pub -r 1 manual_control/speed std_msgs/Int32  '{data: -200}'     # press control+c after 2 seconds
   $ rostopic pub -r 1 manual_control/steering std_msgs/Int16  '{data: 85}'    # press control+c after 2 seconds

Maximum rpm is about 100000, but 1000 rpm is also fast enough for the model car. With a new car, be careful when sending values to manual_control/steering for the first time! The range of the pwm values which are sent to the servo motor can vary for each car. It should be in the range approximately 900-2000, but you should test the steering and find the minimum/maximum values, where the wheels are no longer changing their angles as well as the servo motor keeps quiet. You can then change steering_min and steering_max in the motor_odroid.launch file of the motor_communication package.

The usb_cam_node interfaces with standard USB cameras (e.g. the fish-eye camera) using libusb_cam and publishes images as sensor_msgs::Image. Uses the image_transport library to allow compressed image transport.

Publisher Topics

 usb_cam/image_raw 

Parameters

The camera name. This must match the name in the camera calibration

~camera_name (string, default: head_camera)

You should use camera_calibration package of ROS to calibrate the camera for further use.

Launch File Examples

Start usb_cam node to publish the image_raw topic.

 $ roslaunch usb_cam usb_cam-test.launch

Realsense_camera

This package contains launch files for using the Intel RealSense camera device.

Launch File Examples

Start the realsense_camera node to start the intel sr300 camera.

  $ roslaunch realsense_camera sr300_nodelet_rgbd.launch

visual_gps

This node is used to localize the car using at least two colored markers attached to the ceiling. The fisheye camera on top of the car provides an angle of view of 170 degrees. It can be used to detect, for example, color lamps mounted from the ceiling. To use the package, follow the calibration and running steps described below. Calibration Steps First connect the camera to your computer and find the camera matrix and calibrate camera with the calibrate_camera package in ROS1. To calibrate the camera, you need a chess board. Make sure that you fasten the chess paper to a smooth and firm (inelastic) surface, such as a piece of wood. Save the .ros/camera_info/head_camera.yaml file which contains intrinsic and extrinsic camera parameters, and copy the file to the Odroid.

 $ roslaunch usb_cam usb_cam-test.launch
 $ rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.108 image:=/usb_cam/image_raw camera:=/usb_cam

Figure 10: Calibrate the camera with a chess board

Figure 11: camera picture before and after calibration

 image_width: 640
 image_height: 480
 camera_name: head_camera
 camera_matrix:
      rows: 3
      cols: 3
      data: [373.4585526709734, 0, 344.7922479586828, 0, 374.208011913253, 207.9995810706301, 0, 0, 1]
 distortion_model: plumb_bob
 distortion_coefficients:
     rows: 1
     cols: 5
     data: [-0.3025934119216705, 0.06682905008576441, -0.002063818675390365, 0.001507299697649222, 0]
 rectification_matrix:
     rows: 3
     cols: 3
     data: [1, 0, 0, 0, 1, 0, 0, 0, 1]
projection_matrix:
    rows: 3
    cols: 4
    data: [267.5132141113281, 0, 358.2688813130517, 0, 0, 309.1231689453125, 191.8470852238897, 0, 0, 0, 1, 0]

File 1: Camera fish-eye parameters (.ros/camera_info/head_camera.yaml)

In the second step, you should find the color range of each lamp in order to detect them. Minimizing exposure helps the color detection to be independent from environment lights. Minimize camera exposure using v4l_ctrl as shown below:

 $ v4l2-ctl --device=/dev/video0 --list-ctrls
 $ v4l2-ctl --device=/dev/video0 --set-ctrl exposure_auto=1
 $ v4l2-ctl --device=/dev/video0 --set-ctrl exposure_absolute=1

Maybe you have to change /dev/video0 to an other number when there is another camera connected to your computer.

Run colorgui node from cm_vision package, to find the range of colors of markers2.

 $roslaunch cmvision 1.launch

Figure 12: colorgui node, copy RGB and YUV number after clicking on a marker. Click on a color lamp, click several times on it to find the color range of the lamp, save RGB and YUV of each color in color.txt file. Close the node and run it for the next lamp (color). Save red, green, blue, purple colors number alternatively in the color.txt. Copy the color.txt file inside the visual_gps/config/FEATURE_FILES/ folder in the Odroid.

In the third step, find the position of the lamps respect to the known origin in the room. Save red, green, blue, purple colors lamps position alternatively in map.txt file. Copy the map.txt file inside the visual_gps /config/FEATURE_FILES folder.

run steps:

Now you can run visual_gps launch file from visual_gps package to localize the car. The launch file run following nodes:

  • usb_cam and image_proc (to read calibrated image)
  • cmvision node (to find the calibrated markers)
  • detect_roof_rectangles (to filter the blobs and find the biggest)
  • visual_gps (to find the transformation between map and position of camera which defines the location of camera/car)

For test the node, run the package in your PC, use Rviz to visualize your position.

  $roslaunch visual_gps visual_gps_2d_rviz.launch

Figure 13: The model car position respect to world frame in RViZ using visual_gps_2d node

Heading

This node used to read the yaw angle through the serial port from Arduino.

Published Topics

 model_car/yaw  (std_msgs/Float32)

Parameters

 serial_port (string,default: /dev/ttyArduino)
 serial_baudrate (int, default: 115200)

Launch File Examples

Start a heading node and subscribe to the yaw angle of the model car.

   $ roslaunch heading heading_odroid.launch
   $ rostopic echo /model_car/yaw

Clone this wiki locally