Daily Archives

Articles indexed Friday June 11 2010

Page 5/114 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to make my robot move in a rectangular path along the black tape?

    - by Sahat
    I am working on a robot, it's part of the summer robotics workshop in our college. We are using C-STAMP micro controllers by A-WIT. I was able to make it move, turn left, turn right, move backward. I have even managed to make it go along the black tape using a contrast sensor. I send the robot at 30-45 degrees toward the black tape on the table and it aligns itself and starts to move along the black tape. It jerks a little, probably due to my programming logic below, it's running a while loop and constantly checking if statements, so it ends up trying to turn left and right every few milliseconds, which explains the jerking part. But it's okay, it works, not as smooth as I want it to work but it works! Problem is that I can't make my robot go into a rectangular path of the black tape. As soon as it reaches the corner it just keeps going straight instead of making a left/right turn. Here's my attempt. The following code is just part of the code. My 2 sensors are located right underneath the robot, next to the front wheel, almost at the floor level. It has "index" value ranging from 0 to 8. I believe it's 8 when you have a lot of light coming into the sensor , and 0 when it's nearly pitch black. So when the robot moves into the black-tape-zone, the index value drops, and based on that I have an if-statement telling my robot to either turn left or right. To avoid confusion I didn't post the entire source code, but only the logical part responsible for the movement of my robot along the black tape. while(1) { // don't worry about these. // 10 and 9 represent Sensor's PIN location on the motherboard V = ANALOGIN(10, 1, 0, 0, 0); V2 = ANALOGIN(9, 1, 0, 0, 0); // i got this "formula" from the example in my Manual. // V stands for voltage of the sensor. // it gives me the index value of the sensor. 0 = darkest, 8 = lightest. index = ((-(V - 5) / 5) * 8 + 0.5); index2 = ((-(V2 - 5) / 5) * 8 + 0.5); // i've tweaked the position of the sensors so index > 7 is just right number. // the robot will move anywhere on the table just fine with index > 7. // as soon as it drops to or below 7 (i.e. finds black tape), the robot will // either turn left or right and then go forward. // lp & rp represent left-wheel pin and right-wheel pin, 1 means run forever. // if i change it from 1 to 100, it will go forward for 100ms. if (index > 7 && index2 > 7) goForward(lp, rp, 1); if (index <= 7) { turnLeft(lp, rp, 1); goForward(lp, rp, 1); // this is the tricky part. i've added this code last minute // trying to make my robot turn, but i didn't work. if (index > 4) { turnLeft(lp, rp, 1); goForward(lp, rp, 1); } } else if (index2 <= 7) { turnRight(lp, rp, 1); goForward(lp, rp, 1); // this is also the last minute addition. it's same code as above // but it's for the 2nd sensor. if (index2 > 4) { turnRight(lp, rp, 1); goForward(lp, rp, 1); } } I've spent the entire day trying to figure it out. I've pretty much exhausted all avenues. Asking for the solution on stackoverflow is my very last option now. Thanks in advance! If you have any questions about the code, let me know, but comments should be self-explanatory.

    Read the article

  • Drupal UC "Quoting / Estimate" error

    - by Murtez
    Hi, I was playing around with Drupal UC and installed a module called "Quoting / Estimate" (http://drupal.org/project/quoting), I tried to run it and got this error: **warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'quoting_quote_clear_page' was given in /home/ergospec/public_html/d/includes/menu.inc on line 348** Has anyone run into this problem? Second question: anyone know of a good quotation module (where customer can request a price quote, not the brackets)? It doesn't have to be in Drupal. Any help is appreciated. Murtez

    Read the article

  • Updating protected attributes using update_all

    - by Jack
    Since you cannot use the normal 'update' and 'update_attribute' methods from ActiveRecord to update a protected attribute, is the following the best way to update an attribute for a single user? User.update_all("admin = true","id = 1") I'm guessing this doesn't lie in the 'best practice' category, so I'm just curious if there is a more appropriate way.

    Read the article

  • Selecting unique records in XSLT/XPath

    - by Daniel I-S
    I have to select only unique records from an XML document, in the context of an <xsl:for-each> loop. I am limited by Visual Studio to using XSL 1.0. <availList> <item> <schDate>2010-06-24</schDate> <schFrmTime>10:00:00</schFrmTime> <schToTime>13:00:00</schToTime> <variousOtherElements></variousOtherElements> </item> <item> <schDate>2010-06-24</schDate> <schFrmTime>10:00:00</schFrmTime> <schToTime>13:00:00</schToTime> <variousOtherElements></variousOtherElements> </item> <item> <schDate>2010-06-25</schDate> <schFrmTime>10:00:00</schFrmTime> <schToTime>12:00:00</schToTime> <variousOtherElements></variousOtherElements> </item> <item> <schDate>2010-06-26</schDate> <schFrmTime>13:00:00</schFrmTime> <schToTime>14:00:00</schToTime> <variousOtherElements></variousOtherElements> </item> <item> <schDate>2010-06-26</schDate> <schFrmTime>10:00:00</schFrmTime> <schToTime>12:00:00</schToTime> <variousOtherElements></variousOtherElements> </item> </availList> The uniqueness must be based on the value of the three child elements: schDate, schFrmTime and schToTime. If two item elements have the same values for all three child elements, they are duplicates. In the above XML, items one and two are duplicates. The rest are unique. As indicated above, each item contains other elements that we do not wish to include in the comparison. 'Uniqueness' should be a factor of those three elements, and those alone. I have attempted to accomplish this through the following: availList/item[not(schDate = preceding:: schDate and schFrmTime = preceding:: schFrmTime and schToTime = preceding:: schToTime)] The idea behind this is to select records where there is no preceding element with the same schDate, schFrmTime and schToTime. However, its output is missing the last item. This is because my XPath is actually excluding items where all of the child element values are matched within the entire preceding document. No single item matches all of the last item's child elements - but because each element's value is individually present in another item, the last item gets excluded. I could get the correct result by comparing all child values as a concatenated string to the same concatenated values for each preceding item. Does anybody know of a way I could do this?

    Read the article

  • IE8 crashes on hiding table column that intersects a rowspan

    - by dk
    IE 8 crashes with the following javascript but the same code works fine in IE6, IE7, IE8(IE7mode), FF3, Chrome and Safari. Has anyone run into this? Any known workarounds? Thanks in advance, -dk <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> function HideColumn(){ document.getElementById('hide1').style.display = 'none'; } </script> </head> <body> <button onClick="HideColumn();">Hide Column</button> <table class="grid" border="1" width="300"> <tbody> <tr> <td>A1</td> <td id="hide1" rowspan="3" style='background:silver'>HIDE ME!</td> <td>C1</td> </tr> <tr> <td colspan="3">&nbsp;</td> </tr> <tr> <td>A3</td> <td>C3</td> </tr> </tbody> </table> </body> </html>

    Read the article

  • Could you share your emacs dot-files for web development

    - by Gok Demir
    Hi, could you kindly share your emacs dot-files for web development that works with CSS, HTML, JavaScript, PHP and if possible with Python Django. I really need complete setup. I looked nXhtml and its good on some parts (html code completion works but sucks on indentation and CSS code completion does not work and says tag table is empty most cases. I really need something that works: code completion works out of the box, git integration and pretty indentation and supports multi-mode for mixed HTML, CSS, JavaScript, PHP code.

    Read the article

  • Python regular expression help

    - by dlw
    Hi SO, I can't seem to create the correct regular expression to extract the correct tokens from my string. Padding the beginning of the string with a space generates the correct output, but seems less than optimal: >>> import re >>> s = '-edge_0triggered a-b | -level_Sensitive c-d | a-b-c' >>> re.findall(r'\W(-[\w_]+)',' '+s) ['-edge_0triggered', '-level_Sensitive'] # correct output Here are some of the regular expressions I've tried, does anyone have a regex suggestion that doesn't involve changing the original string and generates the correct output >>> re.findall(r'(-[\w_]+)',s) ['-edge_0triggered', '-b', '-level_Sensitive', '-d', '-b', '-c'] >>> re.findall(r'\W(-[\w_]+)',s) ['-level_Sensitive'] Thanks -- DW

    Read the article

  • Is it possible to add a attachment to a mail with the mailto function in actionscript 3?

    - by SinneR
    Is it possible to add a attachment to a mail with the mailto function in actionscript 3? Thats the thing, i want to open the default mail program compose window with some data but i also need to add a file as attachment, and that file must be a screen capture of the app. Im doing some research and cant find nothing even close to this, someone have any ideas? All help will be appreciated because im really lost here. Thanks in advance ;)

    Read the article

  • Can not access android /data folder?

    - by fonter
    try { Runtime rt = Runtime.getRuntime(); Process pcs = rt.exec("ls -l /data"); BufferedReader br = new BufferedReader(new InputStreamReader(pcs .getInputStream())); String line = null; while ((line = br.readLine()) != null) { Log.e("line","line="+line); } br.close(); pcs.waitFor(); int ret = pcs.exitValue(); Log.e("ret","ret="+ret); } catch (Exception e) { Log.e("Exception", "Exception", e); } only print "ret=0",How to print the correct path?

    Read the article

  • How can I have a serializable struct that wraps it's self as an int32 implicitly? in C#?

    - by firoso
    Long story short, I have a struct (see below) that contains exactly one field: private int value; I've also implemented implicit conversion operators: public static implicit operator int(Outlet val) { return val.value; } public static implicit operator Outlet(int val) { return new Outlet(val); } I've implemented all of the following : IComparable, IComparable<Cart>, IComparable<int>, IConvertible, IEquatable<Cart>, IEquatable<int>, IFormattable I'm at a point where I really have no clue why, but whenever I serialize this object, I get no value. For instance, with XmlSerialization: <Outlet /> Also, I'm not solely concerned about XmlSerialization, I'm concerned about ALL serialization (binary for instance) How can I ensure that this serializes properly? NOTE: I did this because mapping an int,int dictionary seemed rather poorly typed to me when explicit objects with validation behavior were desired.

    Read the article

  • Blackberry: RadioButtonFiled and EditFiled in the same line doesn't show EditField?

    - by user187532
    Hi All, I have a RadioGroup and two RadioButtonField added in a VerticalFieldManager. I want put an EditField for the first RadioButtonField horizontally. For ex: I have two RadioButtonField as "Enter number here:" otherwise user can choose "Number from existing Database:" in the second RadioButtonsField. In the first field "Enter number here:" i need provide an EditField horizontally next to first RadioButtonField, for him to type. I am trying to put an EditField horizoally but it doesn't show EditField horizonatally to the first RadioButtonField. May i know how to do that (or) any samples to do that? Thanks.

    Read the article

  • How to check the Condition?

    - by rockers
    I am new to ASP.NET how to check this condition? int Domestic = 0; int International = 0; My perticular Condition is Domestic ==1 ? DID : International ==1 ? IID : (Domestic + Internationl) this condition is only working for if My Domestic 1 and Internation 0 or Internation 1 Domestic 0 But there is chance that Domestic 1 and Internation 1 or Doemstic > 1 or Internation > 1 if both are having account I need to show them like Level... how to check both are having Counts or not? thanks

    Read the article

  • Windows Screensaver Multi Monitor Problem

    - by Bryan
    I have a simple screensaver that I've written, which has been deployed to all of our company's client PCs. As most of our PCs have dual monitors, I took care to ensure that the screensaver ran on both displays. This works fine, however on some systems, where the primary screen has been swapped (to the left monitor), the screensaver only works on the left (primary) screen. The offending code is below. Can anyone see anything I've done wrong, or a better way of handling this? For info, the context of "this", is the screensaver form itself. // Make form full screen and on top of all other forms int minY = 0; int maxY = 0; int maxX = 0; int minX = 0; foreach (Screen screen in Screen.AllScreens) { // Find the bounds of all screens attached to the system if (screen.Bounds.Left < minX) minX = screen.Bounds.Left; if (screen.Bounds.Width > maxX) maxX = screen.Bounds.Width; if (screen.Bounds.Bottom < minY) minY = screen.Bounds.Bottom; if (screen.Bounds.Height > maxY) maxY = screen.Bounds.Height; } // Set the location and size of the form, so that it // fills the bounds of all screens attached to the system Location = new Point(minX, minY); Height = maxY - minY; Width = maxX - minX; Cursor.Hide(); TopMost = true;

    Read the article

  • I still can't ask the question I want to ask! [closed]

    - by Dennis
    Possible Duplicate: Unable to post question despite having no hyperlinks I'm trying to leave a real question but I keep getting this error: We're sorry, but as a spam prevention mechanism, new users can only post a maximum of one hyperlink. Earn 10 reputation to post more hyperlinks. I have removed all the hyper links in the question but I'm still getting the error. Is there someone I can email the code to so we can figure out what the problem is? And I really didn't appreciate the smart ass comment left by whom ever close my last question.

    Read the article

  • How to set width of textbox to be same as MaxLength in ASP.NET

    - by John Galt
    Is there a way I can limit the width of a textbox to be equal to the MaxLength property? In my case right now, the textbox control is placed in a table cell as in this snippet: <td class=TDSmallerBold style="width:90%"> <asp:textbox id="txtTitle" runat="server" CausesValidation="true" Text="Type a title here..be concise but descriptive. Include price." ToolTip="Describe the item with a short pithy title (most important keywords first). Include the price. The title you provide here will be the primary text found by search engines that index Zipeee content." MaxLength="60" Width="100%"> </asp:textbox> (I know I should not use HTML tables to control layout..another subject for sure) but is there a way to constrain the actual width to the max number of characters allowed in the typed box?

    Read the article

  • Convert date to string upon saving a doctrine record

    - by takteek
    Hi, I'm trying to migrate one of my PHP projects to Doctrine. I've never used it before so there are a few things I don't understand. In my current code, I have a class similar to this: class ScheduleItem { private Date start; //A PEAR Date object. private Date end; public function getStart() { return $this-start; } public function setStart($val) { $this-start = $val; } public function getEnd() { return $this-end; } public function setEnd($val) { $this-end= $val; } } I have a ScheduleItemDAO class with methods like save(), getByID(), etc. When loading from and saving to the database, the DAO class converts the Date objects to and from strings so they can be stored in a timestamp field. In my attempt to move to Doctrine, I created a new class like this: class ScheduleItem extends Doctrine_Record { public function setTableDefinition() { $this-hasColumn('start', 'timestamp'); $this-hasColumn('end', 'timestamp'); } } I had hoped I would be able to use Date objects for the start and end times, and have them converted to strings when they are saved to the database. How can I accomplish this?

    Read the article

  • What -W values in gcc correspond to which actual warnings?

    - by SebastianK
    Preamble: I know, disabling warnings is not a good idea. Anyway, I have a technical question about this. Using GCC 3.3.6, I get the following warning: choosing ... over ... because conversion sequence for the argument is better. Now, I want to disable this warning as described in gcc warning options by providing an argument like -Wno-theNameOfTheWarning But I don't know the name of the warning. How can I find out the name of the option that disables this warning? I am not able to fix the warning, because it occurs in a header of an external library that can not be changed. It is in boost serialization (rx(s, count)): template<class Archive, class Container, class InputFunction, class R> inline void load_collection(Archive & ar, Container &s) { s.clear(); // retrieve number of elements collection_size_type count; unsigned int item_version; ar >> BOOST_SERIALIZATION_NVP(count); if(3 < ar.get_library_version()) ar >> BOOST_SERIALIZATION_NVP(item_version); else item_version = 0; R rx; rx(s, count); std::size_t c = count; InputFunction ifunc; while(c-- > 0){ ifunc(ar, s, item_version); } } I have already tried #pragma GCC system_header but this had no effect. Using -isystem instead of -I also does not work. The general question remains is: I know the text of the warning message. But I do not know the correlation to the gcc warning options.

    Read the article

  • Windows 7 Printing to a network printer

    - by JohnyV
    We have a 2008 server as our print server. Clients that use windows xp with a logon script to map have no problems printing. When I test printing to a network printer on a windows 7 machine it works fine up to a few machines as soon As i get 12-15 workstations trying to print, when they log in they get the yellow exclamation mark and needs troubleshooting against the printer name. It is being deploy by group policy. I have tried to deploy it by group policy also by group policy preferences and by using a script and i get the same error whatever i try. Does anyone have any suggestions to try and troubleshoot? Once again Windows xp clients have no issues printing at all. It is only windows 7 clients. Thanks

    Read the article

  • unstable / variating sound level (volume) within same song / clip

    - by Bastien
    Hello, I have a pretty standard Acer desktop (I guess a predecessor of the X5900 model). when playing mp3 / radio / youtube clips, the sound level is changing WITHIN the clip, highly annoying. in the case of an mp3, the same mp3 will play at a constant sound level on my iPod, so clearly an issue with the computer. problem existed under vista, I upgraded to windows 7 and have the same issue. I guess it might be soundcard-related, so updated the drivers, no luck neither. any idea ? thanks

    Read the article

  • iphone NSMutableArray loses objects at end of method

    - by Brodie4598
    Hello - in my app, an NSMutableArray is populated with an object in viewDidLoad (eventually there will be many objects but I'm just doing one til I get it working right). I also start a timer that starts a method that needs to access the NSMutableArray every few seconds. The NSMutableArray works fine in viewDidLoad, but as soon as that method is finished, it loses the object. myApp.h @interface MyApp : UIViewController { NSMutableArray *myMutableArray; NSTimer *timer; } @property (nonatomic, retain) NSMutableArray *myMutableArray; @property (nonatomic, retain) NSTimer *timer; @end myApp.m #import "MyApp.h" @implementation MyApp @synthesize myMutableArray; - (void) viewDidLoad { cycleTimer = [NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(newCycle) userInfo: nil repeats:YES]; MyObject *myCustomUIViewObject = [[MyObject alloc]init]; [myMutableArray addObject:myCustomUIViewObject]; [myCustomUIViewObject release]; NSLog(@"%i",[myMutableArray count]); /////outputs "1" } -(void) newCycle { NSLog(@"%i",[myMutableArray count]); /////outputs "0" ?? why is this?? }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >