Go to Post the Robotics team isn't just a club, it's a family. - 1086Programmer [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 17-01-2016, 13:22
rod@3711 rod@3711 is offline
Registered User
AKA: rod nelson
FRC #3711 (Iron Mustangs)
Team Role: Mentor
 
Join Date: May 2014
Rookie Year: 2014
Location: Trout Lake, WA
Posts: 64
rod@3711 is an unknown quantity at this point
Robotbuilder c++ code dies in Test Mode

Finally got example robot programs to run after Plugin update. Thanx.

Now I tried the most simple RobotBuilder C++ code (one subsystem with one speed controller). exported, imported, built and deployed OK. When I select Test Mode then enable. The Drivers Station indicates Test Enabled for 1/2 second, then Test Disabled. The roborio Mode indicator goes Red, then Comm indicator Red, then Mode goes off and Comm goes back to green.
Reply With Quote
  #2   Spotlight this post!  
Unread 17-01-2016, 15:23
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Robotbuilder c++ code dies in Test Mode

I've duplicated this. It has to do with the way the SpeedController object is cast to the

Here's the code that causes the crash:

Code:
lw->AddActuator("Subsystem 1", "Speed Controller 1", (Talon&)subsystem1SpeedController1);
Here's code that works:
Code:
lw->AddActuator("Subsystem 1", "Speed Controller 1", std::static_pointer_cast<Talon>(subsystem1SpeedController1));
I'm not a C++ guru, so I'm not sure if that's the right method to cast the shared_pointer from a SpeedController to Talon or other class that implements a SpeedController.
Reply With Quote
  #3   Spotlight this post!  
Unread 17-01-2016, 15:54
calcmogul's Avatar
calcmogul calcmogul is offline
WPILib Developer
AKA: Tyler Veness
FRC #3512 (Spartatroniks)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Santa Maria, CA
Posts: 52
calcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nice
Re: Robotbuilder c++ code dies in Test Mode

Quote:
Originally Posted by Joe Ross View Post
Here's code that works:
Code:
lw->AddActuator("Subsystem 1", "Speed Controller 1",  std::static_pointer_cast<Talon>(subsystem1SpeedController1));
I'm not a C++ guru, so I'm not sure if that's the right method to cast the shared_pointer from a SpeedController to Talon or other class that implements a SpeedController.
I think std::static_pointer_cast will work here. The type is definitely a Talon, so std::dynamic_pointer_cast isn't necessary. Note that the pointer passed in can't be that of a stack allocated object or a double-free would occur later.

Quote:
Originally Posted by Joe Ross View Post
Here's the code that causes the crash:

Code:
lw->AddActuator("Subsystem 1", "Speed Controller 1",  (Talon&)subsystem1SpeedController1);
Is subsystem1SpeedController1 an object or pointer to an object? If the suggested code is correct, then subsystem1SpeedController1 is a pointer and casting to Talon& seems strange to me anyway.
Reply With Quote
  #4   Spotlight this post!  
Unread 17-01-2016, 16:09
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Robotbuilder c++ code dies in Test Mode

Quote:
Originally Posted by mathmogul View Post
Is subsystem1SpeedController1 an object or pointer to an object? If the suggested code is correct, then subsystem1SpeedController1 is a pointer and casting to Talon& seems strange to me anyway.
Here's the full code as RobotBuilder generated (minus the comments)

Code:
#include "RobotMap.h"
#include "LiveWindow/LiveWindow.h"

std::shared_ptr<SpeedController> RobotMap::subsystem1SpeedController1;
void RobotMap::init() {

    LiveWindow *lw = LiveWindow::GetInstance();

    subsystem1SpeedController1.reset(new Talon(0));
    lw->AddActuator("Subsystem 1", "Speed Controller 1", (Talon&) subsystem1SpeedController1);
}

Last edited by Joe Ross : 18-01-2016 at 00:10.
Reply With Quote
  #5   Spotlight this post!  
Unread 17-01-2016, 17:09
rod@3711 rod@3711 is offline
Registered User
AKA: rod nelson
FRC #3711 (Iron Mustangs)
Team Role: Mentor
 
Join Date: May 2014
Rookie Year: 2014
Location: Trout Lake, WA
Posts: 64
rod@3711 is an unknown quantity at this point
Re: Robotbuilder c++ code dies in Test Mode

Thanks, that worked for me.
Reply With Quote
  #6   Spotlight this post!  
Unread 18-01-2016, 10:38
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
I submitted a patch for review for this for Robot Builder.
Reply With Quote
  #7   Spotlight this post!  
Unread 20-01-2016, 15:49
rod@3711 rod@3711 is offline
Registered User
AKA: rod nelson
FRC #3711 (Iron Mustangs)
Team Role: Mentor
 
Join Date: May 2014
Rookie Year: 2014
Location: Trout Lake, WA
Posts: 64
rod@3711 is an unknown quantity at this point
Re: Robotbuilder c++ code dies in Test Mode

How do I find out when or if Robot Builder gets revised?
Reply With Quote
  #8   Spotlight this post!  
Unread 20-01-2016, 20:59
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Robotbuilder c++ code dies in Test Mode

New software releases are mentioned in team updates, or you can watch one of these pages on screensteps: http://wpilib.screenstepslive.com/s/...ware-revisions or http://wpilib.screenstepslive.com/s/...ugin-changelog
Reply With Quote
  #9   Spotlight this post!  
Unread 24-01-2016, 22:03
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Robotbuilder c++ code dies in Test Mode

I think there's an eminent release of the eclipse plugins including robot builder with this fix. However, in the meantime, here's a version with the fix.

Edit: see version below.

Last edited by Joe Ross : 25-01-2016 at 00:49.
Reply With Quote
  #10   Spotlight this post!  
Unread 24-01-2016, 23:05
rod@3711 rod@3711 is offline
Registered User
AKA: rod nelson
FRC #3711 (Iron Mustangs)
Team Role: Mentor
 
Join Date: May 2014
Rookie Year: 2014
Location: Trout Lake, WA
Posts: 64
rod@3711 is an unknown quantity at this point
Re: Robotbuilder c++ code dies in Test Mode

Did a quick test and it works. Thanx a lot...
Reply With Quote
  #11   Spotlight this post!  
Unread 25-01-2016, 00:10
rod@3711 rod@3711 is offline
Registered User
AKA: rod nelson
FRC #3711 (Iron Mustangs)
Team Role: Mentor
 
Join Date: May 2014
Rookie Year: 2014
Location: Trout Lake, WA
Posts: 64
rod@3711 is an unknown quantity at this point
Re: Robotbuilder c++ code dies in Test Mode

Still have problem with the most simple c++ program built with new Robot Builder (one generic subsystem with one motor actuator).

old robot builder

std::shared_ptr<SpeedController> RobotMap::subsystem1SpeedController1; // <<< this is ok

lw->AddActuator("Subsystem 1", "Speed Controller 1", (Talon&) subsystem1SpeedController1); // <<< this caused Test Mode to abort

new robot builder

static std::shared_ptr<SpeedController> subsystem1SpeedController1; // <<< this causes a build error

lw->AddActuator("Subsystem 1", "Speed Controller 1", std::static_pointer_cast<Talon>(subsystem1SpeedCon troller1)); // <<< this is OK
Reply With Quote
  #12   Spotlight this post!  
Unread 25-01-2016, 00:49
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Robotbuilder c++ code dies in Test Mode

Try this version
Attached Files
File Type: zip robotbuilder-all.zip (4.43 MB, 4 views)
Reply With Quote
  #13   Spotlight this post!  
Unread 25-01-2016, 10:15
rod@3711 rod@3711 is offline
Registered User
AKA: rod nelson
FRC #3711 (Iron Mustangs)
Team Role: Mentor
 
Join Date: May 2014
Rookie Year: 2014
Location: Trout Lake, WA
Posts: 64
rod@3711 is an unknown quantity at this point
Re: Robotbuilder c++ code dies in Test Mode

Quote:
Originally Posted by Joe Ross View Post
Try this version
Looks right. I will test on robot this afternoon.

Thanx
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


All times are GMT -5. The time now is 06:11.

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