Close

Complete Rover Build

A project log for Redtree Hydra: A modular platform for robotics

The Redtree Hydra is the 1st computer for robotics designed to easily add components, communicate with groups of other robots and share data

Redtree RoboticsRedtree Robotics 07/29/2015 at 13:070 Comments

Assemble the Rover Frame

We used a rover kit from Robotshop: http://www.robotshop.com/ca/en/lynxmotion-tri-track-chassis-kit.html. Assemble it according to their instructions to build the frame and attach the motors. You can also use other kits, but you may need to make adjustments to the current outputted to the motors if you use something else. It should look something like this when you are done.

Attach the motor controller

We used a motor driver from Robotshop: http://www.robotshop.com/ca/en/sabertooth-dual-regenerative-motor-driver.html - wire up the motors to each channel, wire up power and ground from the battery and attach the wires to the motors. It should look like this when you are done:

Insert the Redtree I/O card into the Redtree Hydra

Insert the ribbon cable from the Redtree Hydra into the I/O card. Attach the I/O card wiring harness to the card and then wire the wires into the motor driver. You can configure which wires / pins control the signals with the FPGA configuration tool. We attach the appropriate wires from the configuration tool to the signal wires on the motor driver. Our I/O card also provides power and ground so we attach these to the motor driver as well. The yellow wires are the signal wires and the black is the ground wire on the motor controller.


Attach Voltage Regulator

The Voltage regulator converts the battery from around 11 volts to 5 volts which is what the Redtree Hydra requires. We also added a switch here so we can turn the whole robot on and off. We have this wrapped in this black styrofoam / electrical tape to give it a bit of a cleaner look.

Attach Xbox Receiver and Cleanup

The last hardware step is attaching the Xbox receiver: http://www.amazon.ca/HDE-Wireless-compatible-Controllers-Platforms/dp/B0096PLB9O since we are using an Xbox 360 controller to drive the robot around, and cleaning everything up. We basically just cable tie the wires and hot glue everything down so that it stays in place.

Programming the FPGA

For more detailed information, see FPGA configuration tool. In this step, we use the web tool which will be available at http://www.redtreerobotics.com/fpga to program the fpga. This tells the Hydra what pins on the I/O card are attached to the motor controllers. In this case, we are using two digital I/O, so we click "digital out" twice to add this to the pinout, and click finish.
When you click finish, the tool will automatically generate the files to program the FPGA when the Redtree Hydra is booted. Take the SDcard out of the Redtree Hydra and insert it into your computer. The two files 'boot.bin' and 'system_wrapper.bit' should be moved to the SDcard. The SDcard can then be ejected and re-inserted into the Redtree Hydra.

Programming the Robot

Next, turn on the robot, connect to its Wi-Fi network (default is rtr), and ssh to the robot. Default IP is 192.168.8.1. The username and password is "redtree" and "robotics".

Check out the "hello rover" example from the Redtree Apps repository:

svn co http://www.redtreerobotics.com/svn/redtree-apps/trunk/ redtree-apps
cd redtree-apps/hello_rover

or if you prefer git:

git clone https://github.com/redtreerobotics/redtree-apps.git
cd redtree-apps/hello_rover

You'll notice a makefile, a header file, and a .cpp file file. The Makefile has been setup to download the Redtree libraries automatically. It is also set up to automatically compile together any .cpp that exist within the folder, so feel free to add your own .cpp files as your projects become more complicated.

Compared with the previous two examples, we have spit this one into a header and source files. This shows a slightly different way to organize the files instead of doing everything in the source file. Let's start with the header file. There are a few key things here.

First is including the "rt_input_user" file. This brings in all the code for handling user input from Joysticks, Xbox controllers etc.

Second is "XBOX_Joystick Joystick{"Joystick"};" - this defines the xbox controller module within our rover module. It has it's own initialization, configuration etc. that occurs without the programmer having to worry about it.

The last thing is the line that defines the control routine as an m_worker. This means it is a real-time task that we can run on specific intervals. There are more details on this in the source file.

#ifndef HELLO_ROVER_H
#define HELLO_ROVER_H
 
/*
 * Basic code that makes a driveable rover with
 * a controller
 * 
 * Jason Ernst, 2015
 * Redtree Robotics
 */
 
#include <rtr.h>
#include <rt_input_user.h>
 
void configure(void) {}
void initialize(void) {}
void setup(void) {}
void start(void) {}
 
class redtree_rover : public m_device
{
	public:
		using m_device::m_device;
 
		XBOX_Joystick Joystick{"Joystick"};
		m_worker<void, void> Control_Routine{this, "Control_Routine", std::bind(&redtree_rover::control, this)};
 
		void configure(void);
		void start(void);
		void control(void);
};
 
#endif

Let's look in more detail at what is inside the hello_rover.cpp file. This file contains the code that will run on the robot. You can open this with your favourite editor and work on the code in here. Again there are a few key things to notice. First is that the Control Routine does not start running until the Joystick has started. When it does start running, it runs every 1/10 of a second. When our rover module starts, the first thing it does it start the Joystick module. Lastly, the Control Routine checks to see if the FPGA is present and then writes the Joystick values to it (after scaling and deadbanding to ensure it is in a correct range). Note: if this code is run on a computer instead of the robot it will just output the message "NO FPGA FOUND" instead of actually writing to the motors.

One final thing to note is the addresses to write to - these addresses are generated by the FGPA programming tool, but in a future release we will automate this part so that instead of addresses a textual define is used instead. For instance MOTOR_1 and MOTOR_2 (which the developer would specify in the FPGA tool).

When you open the file you should see something like this:

#include "hello_rover.h"
#include <iostream>
 
/*
 * Basic code that makes a driveable rover with
 * a controller
 * 
 * Jason Ernst, 2015
 * Redtree Robotics
 */
 
redtree_rover rover{"rover"};
 
void redtree_rover::configure(void)
{
	Control_Routine.run_every_when(100000, Joystick.Started);
}
 
void redtree_rover::start(void)
{
	Joystick.StartCommand();
}
 
void redtree_rover::control(void)
{
	if(m_fpga::isFound())
	{
		m_fpga::write(0xC00,1500 + (int32_t)scale_deadband(0.01, 3200, Joystick.Left_Joystick_Y()));
		m_fpga::write(0x800, 1500 + (int32_t)scale_deadband(0.01, 3200, -1*Joystick.Right_Joystick_Y()));
	}
	else
		std::cout << "NO FPGA FOUND" << std::endl;
}

This file is a bit more complicated than the simple "hello robot" example from earlier, but still pretty simple. Our toolchain and libraries take care of all of the rest of the work for you. To compile, just type make in the terminal where you checked out the code with subversion.

make

Restart and Test the Robot

For now we require the robot is completely reset when it is reprogrammed (otherwise we can't guarantee the state of the system when new user code is loaded. So turn it off and turn it on again and it will automatically load the code you just compiled. It will take up to 30 seconds but once everything loads everything the robot should be drivable with the controller.


Discussions