Go to Post We had an autonomous bug last year . . . Funnily enough, this worked real well and other teams were asking us for this "feature." - dragoonex [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-02-2010, 21:24
tbinns tbinns is offline
Registered User
FRC #0131 (CHAOS)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Manchester, NH
Posts: 4
tbinns is an unknown quantity at this point
Error creating tasks that use encoders

The students are looking to create a couple classes that run as tasks during the life of the robot. They have used the compressor as the model of the classes. The compressor uses digital I/O directly but not the encoder class. The code compiles and we can download the image. The robot starts and the class in created without errors. When we start the class we get this error:

DisabledContinuou
DisableDribbler -> Access Dribbler State Machine1

data access
Exception current instruction address: 0x0232125c
Machine Status Register: 0x0000b032
Data Access Register: 0xfeffebff
Condition Register: 0x20000044
Data storage interrupt Register: 0x40000000
Task: 0x1d85ff8 "FRC_Dribbler"
0x1d85ff8 (FRC_Dribbler): task 0x1d85ff8 has had a failure and has been stopped.
0x1d85ff8 (FRC_Dribbler): fatal kernel task-level exception!

The victors and the encoders are not referenced in any other part of the code. From the error you see that it gets to the first print statement and errors when it tries to access the encoder.

Here are some parts of the source:

//A File Scope Function out side of the class
static void AccessDribblerStateMachine(Dribbler *d)
{
printf("Dribbler -> Access Dribbler State Machine1\n");
//d->DribblerStateMachine();
double LeftDriveRate = d->LeftEncoder->GetRate();
printf("Dribbler -> Access Dribbler State Machine2<%f>\n", LeftDriveRate);
}

Here is the construct of the class with the task and the creation of a couple victors and encoders.
Dribbler:ribbler(DashSharing *DashDataPass)
: DribblerTask("Dribbler", (FUNCPTR) AccessDribblerStateMachine)
{
LeftDribbler = new Victor(DIO_MODULE1, LEFT_DRIBBLING_MOTOR_CHANNEL);
RightDribbler = new Victor(DIO_MODULE1, RIGHT_DRIBBLING_MOTOR_CHANNEL);

DashData = DashDataPass;

LeftEncoder = new Encoder(DIO_MODULE1, LEFT_MOTOR_ENCODER_CHANNEL_A, DIO_MODULE1, LEFT_MOTOR_ENCODER_CHANNEL_B, ENCODER_DISTANCEPERPULSE);
RightEncoder = new Encoder(DIO_MODULE1, RIGHT_MOTOR_ENCODER_CHANNEL_A, DIO_MODULE1, RIGHT_MOTOR_ENCODER_CHANNEL_B, ENCODER_DISTANCEPERPULSE);

Thanks in advance,
Todd Binns
Software Mentor
Reply With Quote
  #2   Spotlight this post!  
Unread 07-02-2010, 03:33
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: Error creating tasks that use encoders

Looks like an uninitilized pointer is being dereferenced, but I can't tell for sure unless you post the whole source file to show how things are called and when.

-Joe
Reply With Quote
  #3   Spotlight this post!  
Unread 07-02-2010, 09:36
tbinns tbinns is offline
Registered User
FRC #0131 (CHAOS)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Manchester, NH
Posts: 4
tbinns is an unknown quantity at this point
Re: Error creating tasks that use encoders

Joe, Thanks

I have uploaded the files for the dribbler. It is created in the dribbler class is created in the main Iterative robot and defined in its .h file. Segments of the main robot included at the end to show order of creation.

The Dashboard is past in from to the constructor and appears to have the same issues.

AccessDribblerStateMachine(Dribbler *d) (a file scoped function) called the dribbler class statemachine, but during testing we moved the encoder to see if there was different results and there was no change in the error. In the statemachine we commented out // DashData-> to work on one issue at the time, this also goes for the victors at the end of the function that result in the same error.

Parts from our Main robot:
Breakaway10::Breakaway10(void) : camera(AxisCamera::GetInstance())
{
//Robot Base Drive Initializers:
//Gamepad Initializers:
//Gyro Initializers:
//PID Output Initializers:
//TurnController Initializers USES PID OUTPUT, USES GYRO
//Dashboard Initializers:
dds = new DashboardDataSender();
//Compressor Initializers:
compressor = new Compressor(COMPRESS_PRESSURE_SWITCH_CHANNEL, COMPRESS_RELAY_CHANNEL);
//Encoder Initializers: (were passed to dribbler but now created within dribbler
// leftEncoder = new Encoder(DIO_MODULE1, LEFT_MOTOR_ENCODER_CHANNEL_A, DIO_MODULE1, LEFT_MOTOR_ENCODER_CHANNEL_B, ENCODER_DISTANCEPERPULSE);
// rightEncoder = new Encoder(DIO_MODULE1, RIGHT_MOTOR_ENCODER_CHANNEL_A, DIO_MODULE1, RIGHT_MOTOR_ENCODER_CHANNEL_B, ENCODER_DISTANCEPERPULSE);
//Dash Sharing Initializers:
DashData = new DashSharing();
//Dribbler Initializers: USES DASH DATA
dribbler = new Dribbler(DashData);
......

void Breakaway10::TeleopContinuous(void)
{

//We need to start these tasks before we begin the loop, to use the enable function
//ChaosKicker->Start();
//Wait(0.5);
dribbler->Start();

// ->->-> MAIN LOOP BEGINS HERE <-<-<-
...........

Thanks,
Todd Binns
Software Mentor
Attached Files
File Type: cpp Dribbler.cpp (3.9 KB, 9 views)
File Type: h Dribbler.h (1.4 KB, 9 views)
Reply With Quote
  #4   Spotlight this post!  
Unread 07-02-2010, 10:00
tbinns tbinns is offline
Registered User
FRC #0131 (CHAOS)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Manchester, NH
Posts: 4
tbinns is an unknown quantity at this point
Re: Error creating tasks that use encoders

In the original version we passed in the encoders and we ran the Keep code in the Iterative robot without issue. The students wanted it to run all the time since it was needed as long as the robot was enabled.

Todd
Reply With Quote
  #5   Spotlight this post!  
Unread 14-02-2010, 10:17
tbinns tbinns is offline
Registered User
FRC #0131 (CHAOS)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Manchester, NH
Posts: 4
tbinns is an unknown quantity at this point
Re: Error creating tasks that use encoders

Hi,
We have done some more work with this and it appears that some classes like encoder, dashboard are not thread safe. We are able to include joystick, digital I/O and analog, without an error. Has anyone else try including encoders in a task and if so did they have errors while the oRICO ran?

Todd
Reply With Quote
  #6   Spotlight this post!  
Unread 14-02-2010, 10:28
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Error creating tasks that use encoders

we use tasks, but have only one task access the sensors, the other must ask the first for the value. You could also use semaphores: http://www.chiefdelphi.com/forums/sh...ad.php?t=82398
also, could you use [CODE ] Tags on your posts? It helps a lot. (the # button in the editor)
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
Reply


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Periodic Tasks Luke Pike NI LabVIEW 1 04-02-2009 01:14
Need help in creating program to use servo's to shift drive archiver 2001 19 24-06-2002 00:35


All times are GMT -5. The time now is 14:01.

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