Robot tuning - tilt data

If you need technical help with anything you've bought from Dawn Robotics, please post here.

Robot tuning - tilt data

Postby laserdance » Sun Nov 01, 2015 8:41 am

Hi all,
I have finally fully functional robot, thanks for awesome kit!

Now I'd like to add some improvements. First of all, I'd like to put somwhere on the page where I control robot's movement information about camera tilt. Because I struggle with remote control when camera is somehow tilted.

Is there any change how to add (some numeric) value how much is camera tilted? So I would know, how to straigthen camera when moving forward.

I'm advanced (linux) user, but I'm not familiar with Python - I don't know where to read those values and where is template for html page..

Anyway, thanks for great job!
laserdance
 
Posts: 5
Joined: Thu Apr 02, 2015 7:24 pm

Re: Robot tuning - tilt data

Postby Alan » Tue Nov 03, 2015 5:07 pm

Hi there,

Your robot looks great. Glad to hear that you got it working. :)

Your goal of displaying the current pan/tilt angle of the robot's neck could be a little bit tricky, because currently the web front end sends over just a joystick command asking for a 'relative' change. There are 2 possible ways I can think of to acheive what you want though.

The first option would just involve javascript programming and involves modifying index.html in the www folder. What you'd need to do is to maintain status variables for the absolute pan/tilt angles in javascript and then you would replace line 153 in index.html with something like

Code: Select all
socket.send( "SetNeckAngles " + panAngle + " " + tiltAngle );


Basically 'SetNeckAngles' is another command that the web server running on the robot understands, but which accepts absolute angles.

The other option involves editing some Python code, but I think that it may actually be an easier change, and will give a more flexible result. What you'd need to do is change line 97 of robot_controller.py to the following

Code: Select all
statusDict = {
        "batteryVoltage" : self.miniDriver.getBatteryVoltageReading().data,
        "presetMaxAbsMotorSpeed" : presetMaxAbsMotorSpeed,
        "presetMaxAbsTurnSpeed" : presetMaxAbsTurnSpeed,
        "neckPanAngle" : self.panAngle,        # Add these
        "neckTiltAngle" : self.tiltAngle,           # 2 lines...
        "sensors" : self.getSensorDict()
}


Now, with any luck, this should mean that the values neckPanAngle and neckTiltAngle are returned automagically in a status dictionary. The file config.html shows how this works, with a periodic callback (line 63) polling for the robot status, and a socket onmessage function processing the status dictionary. There is a possiblity that repeatedly polling for, and receiving the status dictionary may slow the web interface down a bit, but if that is a problem, then you should be able to deal with it by reducing the frequency at which you poll for the status i.e. I think asking for the robot status just 1 or 2 times a second will keep the interface running quickly, and would probably keep the display of the neck angle updated frequently enough.

Anyway, I hope that helps. If you need any further explanation or pointers when modifying the code, please let me know.

Regards

Alan
Alan
Site Admin
 
Posts: 311
Joined: Fri Jun 14, 2013 10:09 am


Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests