Go to Post The goal isn't to keep the "bad" kids out. The goal is to take the "bad" out of kids, thereby transforming OUR culture. - Michael Corsetto [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 28-01-2014, 00:21
TheVoid's Avatar
TheVoid TheVoid is offline
C++ programmer
AKA: Liam Taylor
FRC #2605 (Sehome Seamonsters)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Bellingham
Posts: 8
TheVoid is an unknown quantity at this point
CANJaguar "Server" - Open Source.

About a week ago, I was toying around with the idea of running our autonomous code in another task. I quickly had the thread itself up and running, and looked up synchronization in VxWorks, so as to properly control our own motion code from the task, resolving to a Mutex Semaphore. When it compiled and ran without instantly dying, i was elated.

I set about adding in some simple drive code, intending for the robot to move forward for a second, rotate, then move forward again. Simple enough, right? Well, not really as it turns out! When you're using CANJaguars, there's always something to trip you up, or so it seems. On her maiden voyage, Serenity (My Team's Ultimate Ascent robot) lurched to life, and things seemed to work. So i disabled Serenity, dragged her back to the starting position, and enabled into Autonomous again. To my dismay, nothing happened. The Autonomous Task did indeed start, and the printfs were accurately timed, but no movement. (Despite synchronization being wrapped around every possible CAN message.)

For about three days, i tried to figure it out, each attempt yielding the same sketchy it-works-about-one-tenth-of-the-time result. Then, it struck me! What if the CANJaguar class is Task-initialization sensitive? (As in, you have to control it from the same task-context you're going to use it in)

I moved the initialization code of our CANJaguar objects to the Autonomous Task main routine, just before drive code, and VOILA! It worked. SO, from what I can tell, You can only (consistently) use CANJaguars from the task you initialized the object in. As a result, i present to you, the CANJaguarServer class. It's a handy little bit of code that runs a command loop for controlling CANJaguars, as well as offering nice things like CANBus bandwidth limiting and brown-out detection.

It's currently in my team's 2014 Test Code Repository. The relevant code is in the CANJagServer directory, and a usage example with our MecanumDrive class is shown in RobotMainTask.cpp. (There's also plenty of other stuff you can ignore/peruse to your liking in there.)

The easiest way to use the CANJaguarServer is through the AsynchCANJaguar class, which inherits from SpeedController for ease of use.

EDIT: I'm finding plenty of bugs as i go, so if you're using it please try updating to the current version before sending me a bug! Thanks. I'll try to only push functioning commits once i have a robot to test them on.

Last edited by TheVoid : 28-01-2014 at 12:47.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi