Main Page | Recent changes | Edit this page | Page history

Printable version | Disclaimers | Privacy policy

Not logged in
Log in | Help
 

Adrive

From DGC Wiki

Contents

Adrive is the overall driving software for Alice. Its main role is to take commands from trajFollower and execute them. Adrive also performs checking on the state of the actuators, brings the vehicle to a stop if it senses a problems, and attempts to recover from failures (by resetting actuators). The other function that adrive it serves is to provide feedback on actuator position. The code for adrive can be found in the folder $dgc/modules/adrive.

Adrive works by receiving commands over the network and sending them out over serial connections. Also included into the role of Adrive was to implement physical protections for the hardware to prevent the vehicle from hurting itself.

Adrive Usage

Adrive uses a configuration file (adrive.config by default) that specifies various operating parameters, including what command and status loops should be run. Command line arguments can be used to further refine the operation of adrive.

-s turn off steering
-b turn off brake
-g turn off gas (throttle)
-t turn off transmission
-o turn off OBD II
-e turn off estop

System Design and Analysis

The design of Adrive was to store data in a central location then have multiple threads selectively mutating small segments of the data. There were 2 threads for each actuator, a status thread and a command thread. In addition there were two threads for network connections. One thread listened for incoming commands while the other thread periodically broadcast the current positions of actuators over the network. The network broadcast thread also worked as a logging thread periodically writing the internal data to a file. Two other threads existed, one which was the user interface thread and the other was a supervisory thread to make sure that actuators were healthy and if necessary try to recover them. Overall the system was designed to be interrupt driven. This allows many slow tasks, especially slow speed serial communication ports, to operate in parallel. Minor challenges are that it is much harder to debug and timing is very critical.

The central data structure was called a vehicle struct which was defined globally or passed by reference. The vehicle struct contained individual structs for each of the actuators as well as some general conditions relevant to all operations such as a shutdown flag. The net result was a hierarchical structure which allowed access to data within any part of the program by calling my_vehicle.actuator_name.variable_name.

Each actuator struct contained not only the basic position feedback, but also the last commanded position, the status of the actuator, the handles of the actuators two threads, and the function pointers for the code to execute for an incoming command or how to read back position. Also each actuator has a number of timeout associated with it. The port to which the actuator is connected is also stored in the actuator struct. For flow control pthread mutex bits and a pthread conditional broadcast flag were stored in each actuator struct as well.

The functional flow within Adrive is as follows:

Skynet Actuator State Broadcast

Skynet Command Interface

To use adrive other modules must communicate via skynet. The interface types are all defined in the file adrive_skynet_interface_types.h which is installed into the $dgc/include directory automatically. If you wish to communicate with adrive add $(ADRIVELIB) to your dependancies in yourmodule.mk

General Notes

Commands to adrive

Returns from adrive

Current commands implemented

set accel


set steering

Actuator Interfacing

All of adrives interfaces with the hardware in Alice is via serial connections on leela. We have experimented with using a serial device server (SDS) to allow the actuators to be accessed over the network, but we had problems in 2005 with reliability of the SDS hardware and reverted to hardwired conections.

Serial port configuration

Two serial interface cards are installed on leela, in addition to one serial port available from the motherboard. In its present configuration (Dec 06), here is the serial port mapping:

Port Actuator Settings Comments
ttyS0 Steering 9600, 8N1, sw flow Connected to Parker motor controller
ttyS1-3 Not connected These ports are assigned by udev but don't map to anything
ttyS4 Throttle 9600, 8N1, sw flow Custom box; controls programmable resistors
ttyS5 Transmission 9600, 8N1, sw flow Custom built interface; Includes ignition
ttyS6 Not connected
ttys7 OBD II 19200, 8N1, no flow CANbus <-> serial interface; key must be in "run"
ttyS8 E-stop 9600, 8N1, sw flow Custom box; sends 'R', 'P' or 'D'
ttys9 Brake 9600, 8N2, no flow Custom box; controls pneumatic valves

Build

  1. Either:
    1. enter the directory $dgc/alice/adrive
    2. type
make; make install
  1. Or
    1. enter the directory $dgc
    2. type
make

setup

  1. in $(DGC)/bin/ edit adrive.config
    1. see README.TXT for instructions on adrive.config
    2. but the jist of it is that you add a pound sign infront of anything you want to run
    3. and set the ports to which the actuators are attached
  2. Make sure that in all your directories echo $SKYNET_KEY are the same.
    1. If not type:
source ~/.*shrc
    1. it will be stored in the above file or .bashrc
    2. Skynet functionality will not work unless the keys are all the same.

Interlocks

run

  1. enter the bin directory
cd bin
  1. execute adrive
./adrive
    1. In the sparrow interface
      1. Use the arrow keys to move the interface.
      2. enter a command for gas, steer, or brake
        1. by highlighting the field, press =, type number 0-255, enter
        2. execute brake by pressing b, steer by pressing s, gas with g, trans with t, steering velocity command with v, and steering acceleration command with c
        3. to reenable steering after using the kill switch press e
    2. if you want to input skynet commands by hand
      1. Execute sn_send_commandline
        1. Follow the prompts
        2. You can only send positional commands.
        3. To exit hit Ctrl-C

exit

  1. highlight EXIT
  2. press enter
  3. kill the skynetd process when done with it

Adrive Checkout Procedure

  1. jack up the car and set up the brake actuator
  2. enter modules/adrive
  3. type:
make
make install
  1. move to $(DGC)/bin
cd ../../bin
  1. edit the config file
emacs config/adrive/adrive.config
  1. comment out the throttle command loop
    1. Do not test the throttle commands without the car in gear it will overspeed the engine. AKA NOT IN THE SHOP!
  2. Save and exit
  3. run adrive
./adrive
  1. in a new window run sn_send_commandline found in bin
./sn_send_commandline
  1. watch as you command through sn_send_commandline the adrive fields move
  2. watch as you move the actuators as the feedback moves and the steering and brake actuator move.

Frequently Asked Questions

Additional Information

Retrieved from "http://kincora.cds.caltech.edu../../../a/d/r/Adrive.html"

This page has been accessed 555 times. This page was last modified 09:51, 19 May 2007 by Richard Murray. Based on work by Jimmy Paulos and Tichakorn Wongpiromsarn and DGC Wiki user(s) Foote.


[Main Page]
Main Page
Alice Docs
DGC07
DGC05
Categories
Recent changes
Help

Edit this page
Discuss this page
Page history
What links here
Related changes

Special pages
Bug reports