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
Attach Voltage Regulator
Attach Xbox Receiver and Cleanup
Programming the FPGA
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
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.