Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

converting old code to Roboplus...

Bioloid robot kit from Korean company Robotis; CM5 controller block, AX12 servos..
14 postsPage 1 of 1
14 postsPage 1 of 1

converting old code to Roboplus...

Post by altwolf » Tue Nov 03, 2009 8:16 pm

Post by altwolf
Tue Nov 03, 2009 8:16 pm

I am trying to convert the DemoHumanoid example to roboplus and have a question about what some of the original, Behaviour Program code does.

This is the "Inititialize motor" function from the original program:

IF (1:8 = 0) THEN LOAD 1:8 <- 1023
IF (2:8 = 0) THEN LOAD 2:8 <- 1023


It goes on like that for all the motors.

When I import the file into RoboPlus, I get:

IF (ID1: ADDR[8(w)] == 0)
IF (ID2: ADDR[8(w)] == 0)

Then a bunch of code later that is obviously not right. So I need to know what the original code is trying to do in order to put it in the correct syntax for the new code.
I am trying to convert the DemoHumanoid example to roboplus and have a question about what some of the original, Behaviour Program code does.

This is the "Inititialize motor" function from the original program:

IF (1:8 = 0) THEN LOAD 1:8 <- 1023
IF (2:8 = 0) THEN LOAD 2:8 <- 1023


It goes on like that for all the motors.

When I import the file into RoboPlus, I get:

IF (ID1: ADDR[8(w)] == 0)
IF (ID2: ADDR[8(w)] == 0)

Then a bunch of code later that is obviously not right. So I need to know what the original code is trying to do in order to put it in the correct syntax for the new code.
altwolf
Savvy Roboteer
Savvy Roboteer
Posts: 50
Joined: Thu Jan 29, 2009 9:11 pm

Post by Suicidal.Banana » Wed Nov 04, 2009 3:47 pm

Post by Suicidal.Banana
Wed Nov 04, 2009 3:47 pm

hmm, servo position? servo 1 and 8 and position 1023?
hmm, servo position? servo 1 and 8 and position 1023?
Suicidal.Banana
Savvy Roboteer
Savvy Roboteer
Posts: 78
Joined: Tue Jun 16, 2009 12:54 pm

Post by billyzelsnack » Fri Nov 06, 2009 5:18 am

Post by billyzelsnack
Fri Nov 06, 2009 5:18 am

Hey altwolf. Did you get any further with this? Using the txt2tsk and tsk2txt converters I made ( posted about it in the trossen forums ) I've been screwing around trying to get the humanoid example working and I think my last issue involves the Wait_motion_done and Wait_timer_done functions not working as expected. Though it's hard to tell since I can't print anything out for debugging.
Hey altwolf. Did you get any further with this? Using the txt2tsk and tsk2txt converters I made ( posted about it in the trossen forums ) I've been screwing around trying to get the humanoid example working and I think my last issue involves the Wait_motion_done and Wait_timer_done functions not working as expected. Though it's hard to tell since I can't print anything out for debugging.
billyzelsnack
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 618
Joined: Sat Dec 30, 2006 1:00 am

Post by billyzelsnack » Fri Nov 06, 2009 6:24 am

Post by billyzelsnack
Fri Nov 06, 2009 6:24 am

From DemoHumanoid(example) or whatever it is called I have 4 of the 5 programs working. The one that is not working is program_4 which is the walking one ( down button. ) The robot just stays walking in place indefinitely and I'm not sure why.

For debugging output I made it play the little song to let me know where it was in the code. With that I was able to verify that waiting for the buzzer and waiting for the timer were working though not so much with waiting for motion done. It seems like the walking animation just is not changing the motion status. I can't even play another motion after I have started the walking motion. I wonder if the motion files need some modification too. I tried loading them into the new motion editor and then uploading back to the CM-5, but it works just the same. I don't really have a clue how the motion editor works so I've not looked into debugging the motion itself yet.

Here's the tsk so far..
http://www.mediafire.com/file/vw2nnztomgj/out.tsk

btw. I'm running 1.0.2.7 roboplus. I'm downloading the newest version now, but it always takes forever to download stuff from Robotis.
From DemoHumanoid(example) or whatever it is called I have 4 of the 5 programs working. The one that is not working is program_4 which is the walking one ( down button. ) The robot just stays walking in place indefinitely and I'm not sure why.

For debugging output I made it play the little song to let me know where it was in the code. With that I was able to verify that waiting for the buzzer and waiting for the timer were working though not so much with waiting for motion done. It seems like the walking animation just is not changing the motion status. I can't even play another motion after I have started the walking motion. I wonder if the motion files need some modification too. I tried loading them into the new motion editor and then uploading back to the CM-5, but it works just the same. I don't really have a clue how the motion editor works so I've not looked into debugging the motion itself yet.

Here's the tsk so far..
http://www.mediafire.com/file/vw2nnztomgj/out.tsk

btw. I'm running 1.0.2.7 roboplus. I'm downloading the newest version now, but it always takes forever to download stuff from Robotis.
billyzelsnack
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 618
Joined: Sat Dec 30, 2006 1:00 am

Post by PedroR » Fri Nov 06, 2009 12:37 pm

Post by PedroR
Fri Nov 06, 2009 12:37 pm

hi

I had a look at your code and I couldn't quite figure everything out.

However one suggestion that I would like to give you is that you replace all the calls of WAIT_FOR something with a simpler instruction:

It's the "CONDTIONAL STAND" and you can find it under the Loop in the instruction list.
This will make the program halt while the condition is ture
So something like a STAND WHILE(MotionPage != 0) will halt the program while the motion is playing.

In addition, I can really understand why it's not trivial porting programs from BCP to R+.
R+ is a functional language based in C like constructs like functions and loops (while/for). BCP on its turn is much more basic working only off GOTOs/JUMPs so it's really not trivial to port a program from one to the other.

A final tip: for debugging purposes you can use the PRINT command.
I think you need to add a LOAD instruction and then on the left side, choose print; on the right side you place the number to print.

The print instructions will output to the console while the progrma is running.
So if you run the program and open R+ Terminal you will see the output of the program.
I think R+ Task also has an option to view the output of the program in real time without the need to bring up R+ Terminal.

Regards
Pedro.
hi

I had a look at your code and I couldn't quite figure everything out.

However one suggestion that I would like to give you is that you replace all the calls of WAIT_FOR something with a simpler instruction:

It's the "CONDTIONAL STAND" and you can find it under the Loop in the instruction list.
This will make the program halt while the condition is ture
So something like a STAND WHILE(MotionPage != 0) will halt the program while the motion is playing.

In addition, I can really understand why it's not trivial porting programs from BCP to R+.
R+ is a functional language based in C like constructs like functions and loops (while/for). BCP on its turn is much more basic working only off GOTOs/JUMPs so it's really not trivial to port a program from one to the other.

A final tip: for debugging purposes you can use the PRINT command.
I think you need to add a LOAD instruction and then on the left side, choose print; on the right side you place the number to print.

The print instructions will output to the console while the progrma is running.
So if you run the program and open R+ Terminal you will see the output of the program.
I think R+ Task also has an option to view the output of the program in real time without the need to bring up R+ Terminal.

Regards
Pedro.
PedroR
Savvy Roboteer
Savvy Roboteer
Posts: 1199
Joined: Mon Jun 16, 2008 11:07 pm

Post by billyzelsnack » Fri Nov 06, 2009 4:46 pm

Post by billyzelsnack
Fri Nov 06, 2009 4:46 pm

I tried various forms of looping including the STAND WHILE, but none of them seemed to do what I needed.

The code was less ported than fixed up from the automatic conversion. I imported the .bcp into R+ and saved out a .tsk. The humanoid won't run as it is due to a bunch of errors. I wrote a program to convert the .tsk to a text file that I could edit by hand. After I make changes to the text file I run another program to convert it back into a .tsk and load that back into R+.

When I have time tonight I'll write a minimal program to see if I can get motion status working. As a guess I think there just might be something wrong with motion status on looping motions. Maybe it's a firmware issue that the newest version with fix. Dunno.
I tried various forms of looping including the STAND WHILE, but none of them seemed to do what I needed.

The code was less ported than fixed up from the automatic conversion. I imported the .bcp into R+ and saved out a .tsk. The humanoid won't run as it is due to a bunch of errors. I wrote a program to convert the .tsk to a text file that I could edit by hand. After I make changes to the text file I run another program to convert it back into a .tsk and load that back into R+.

When I have time tonight I'll write a minimal program to see if I can get motion status working. As a guess I think there just might be something wrong with motion status on looping motions. Maybe it's a firmware issue that the newest version with fix. Dunno.
billyzelsnack
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 618
Joined: Sat Dec 30, 2006 1:00 am

Post by PedroR » Fri Nov 06, 2009 4:55 pm

Post by PedroR
Fri Nov 06, 2009 4:55 pm

Hi

I would not be inclined towards a firmware bug.

The latest releases have not brought any news on the firmware side; only the PC part has been receiving improvements.

Also their implementation seems very well done. They convert all the instructions into some sort of P-code then run on the micro controller.

Their P code is very much like assembly and they use very well structured constructs (for example CONDITIONS seem to be handled by the same code in all constructs - IFs, WHILE, etc. - so if it works for an IF it will work for a WHILE).
If you start R+ task with the "debug" argument you can see the syntax tree and all the tech output) and it looks very mature at this stage.

Also bear in mind that all bugs detected so far were on the GUI; never the firmware. There were even occasions were we suspected firmware bugs but after some thought it was clear it was doing what it was supposed to do; the error was done by the human ;)

Pedro
Hi

I would not be inclined towards a firmware bug.

The latest releases have not brought any news on the firmware side; only the PC part has been receiving improvements.

Also their implementation seems very well done. They convert all the instructions into some sort of P-code then run on the micro controller.

Their P code is very much like assembly and they use very well structured constructs (for example CONDITIONS seem to be handled by the same code in all constructs - IFs, WHILE, etc. - so if it works for an IF it will work for a WHILE).
If you start R+ task with the "debug" argument you can see the syntax tree and all the tech output) and it looks very mature at this stage.

Also bear in mind that all bugs detected so far were on the GUI; never the firmware. There were even occasions were we suspected firmware bugs but after some thought it was clear it was doing what it was supposed to do; the error was done by the human ;)

Pedro
PedroR
Savvy Roboteer
Savvy Roboteer
Posts: 1199
Joined: Mon Jun 16, 2008 11:07 pm

Post by billyzelsnack » Fri Nov 06, 2009 6:50 pm

Post by billyzelsnack
Fri Nov 06, 2009 6:50 pm

I installed the new version and played around with it for a bit. You can now choose a number for the motion status value instead of just a bool. Still the same result. I poked around the Robitis website and found the premium humanoid examples in the the Korean section. I mimicked the way they handled status ( though I'd already tried it before ) and it still is not working as expected. Oh well. I'll put together a minimal example and see if I can track this down.
I installed the new version and played around with it for a bit. You can now choose a number for the motion status value instead of just a bool. Still the same result. I poked around the Robitis website and found the premium humanoid examples in the the Korean section. I mimicked the way they handled status ( though I'd already tried it before ) and it still is not working as expected. Oh well. I'll put together a minimal example and see if I can track this down.
billyzelsnack
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 618
Joined: Sat Dec 30, 2006 1:00 am

Post by billyzelsnack » Sat Nov 07, 2009 5:35 am

Post by billyzelsnack
Sat Nov 07, 2009 5:35 am

So I built a minimal test and I'm not really any further. If a motion does not have its "next" set then waiting on motion status works fine. If instead I set a timer after I start a motion the timer will expire just fine and allow me to do something else while current motion is running, but the only motion that seemed to interrupt a currently running motion is motion page 0. Also.. Looking at the humanoid example motion for the premium kit it has plenty of "next"'s set.

Anyway.. I'm out of ideas at this point other than the new CM-5 firmware is not quite fully baked at this point.

btw. Here's the links to my two little programs including source. These were just quickly hacked together so don't expect much. The executables are built with the VS2010 beta so it might have a goofy runtime requirement. I dunno.

http://www.mediafire.com/file/mzomnmjdznm/tsk2txt.cpp
http://www.mediafire.com/file/hdmkzmnn2qg/tsk2txt.exe

http://www.mediafire.com/file/2hqlinmjj2m/txt2tsk.cpp
http://www.mediafire.com/file/iajlyimj42j/txt2tsk.exe
So I built a minimal test and I'm not really any further. If a motion does not have its "next" set then waiting on motion status works fine. If instead I set a timer after I start a motion the timer will expire just fine and allow me to do something else while current motion is running, but the only motion that seemed to interrupt a currently running motion is motion page 0. Also.. Looking at the humanoid example motion for the premium kit it has plenty of "next"'s set.

Anyway.. I'm out of ideas at this point other than the new CM-5 firmware is not quite fully baked at this point.

btw. Here's the links to my two little programs including source. These were just quickly hacked together so don't expect much. The executables are built with the VS2010 beta so it might have a goofy runtime requirement. I dunno.

http://www.mediafire.com/file/mzomnmjdznm/tsk2txt.cpp
http://www.mediafire.com/file/hdmkzmnn2qg/tsk2txt.exe

http://www.mediafire.com/file/2hqlinmjj2m/txt2tsk.cpp
http://www.mediafire.com/file/iajlyimj42j/txt2tsk.exe
billyzelsnack
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 618
Joined: Sat Dec 30, 2006 1:00 am

Post by altwolf » Tue Nov 10, 2009 3:25 am

Post by altwolf
Tue Nov 10, 2009 3:25 am

Hello! Was on vacation away from my computer for a while. Here is how I translated the Demo_humanoid program:

http://www.mediafire.com/file/0c1ikzzjcjg/Hum_test_02.tsk

I can't remember where I left off exactly... I think it was mostly working, except possibly the count the claps part...
Hello! Was on vacation away from my computer for a while. Here is how I translated the Demo_humanoid program:

http://www.mediafire.com/file/0c1ikzzjcjg/Hum_test_02.tsk

I can't remember where I left off exactly... I think it was mostly working, except possibly the count the claps part...
altwolf
Savvy Roboteer
Savvy Roboteer
Posts: 50
Joined: Thu Jan 29, 2009 9:11 pm

Post by billyzelsnack » Tue Nov 10, 2009 4:45 am

Post by billyzelsnack
Tue Nov 10, 2009 4:45 am

Seems like..

Code: Select all
FUNCTION Wait_motion_done
{
LOOP WHILE (Motion Status == TRUE )
{
RETURN
}
}


would return immediately regardless of the value of Motion Status. Still.. I'll give it a try tomorrow.
Seems like..

Code: Select all
FUNCTION Wait_motion_done
{
LOOP WHILE (Motion Status == TRUE )
{
RETURN
}
}


would return immediately regardless of the value of Motion Status. Still.. I'll give it a try tomorrow.
billyzelsnack
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 618
Joined: Sat Dec 30, 2006 1:00 am

Post by altwolf » Tue Nov 10, 2009 6:29 am

Post by altwolf
Tue Nov 10, 2009 6:29 am

billyzelsnack wrote:Seems like..

Code: Select all
FUNCTION Wait_motion_done
{
LOOP WHILE (Motion Status == TRUE )
{
RETURN
}
}


would return immediately regardless of the value of Motion Status. Still.. I'll give it a try tomorrow.


Yah, I was sort of making it up as I went along. I'm not sure if I have done it correctly or very efficiently. I was having trouble with my loops working...putting in the "returns" in the functions seemed to help.
billyzelsnack wrote:Seems like..

Code: Select all
FUNCTION Wait_motion_done
{
LOOP WHILE (Motion Status == TRUE )
{
RETURN
}
}


would return immediately regardless of the value of Motion Status. Still.. I'll give it a try tomorrow.


Yah, I was sort of making it up as I went along. I'm not sure if I have done it correctly or very efficiently. I was having trouble with my loops working...putting in the "returns" in the functions seemed to help.
altwolf
Savvy Roboteer
Savvy Roboteer
Posts: 50
Joined: Thu Jan 29, 2009 9:11 pm

Post by billyzelsnack » Tue Nov 10, 2009 10:05 pm

Post by billyzelsnack
Tue Nov 10, 2009 10:05 pm

Your version worked much better for walking than my version. Comparing my version to yours I noticed that I never got around to fixing the automated conversion on several of the functions. Doh! Though I did need to remove that RETURN from the Wait_motion_done loop.

I think maybe my minimal test failed because apparently you need to set the motion page to 0 to stop a motion that references other motion. Just a guess though.

Anyway. Here's my current version. Everything appears to be working.
http://www.mediafire.com/?gjmmcekz1iw
Your version worked much better for walking than my version. Comparing my version to yours I noticed that I never got around to fixing the automated conversion on several of the functions. Doh! Though I did need to remove that RETURN from the Wait_motion_done loop.

I think maybe my minimal test failed because apparently you need to set the motion page to 0 to stop a motion that references other motion. Just a guess though.

Anyway. Here's my current version. Everything appears to be working.
http://www.mediafire.com/?gjmmcekz1iw
billyzelsnack
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 618
Joined: Sat Dec 30, 2006 1:00 am

tsk2txt

Post by UncleBob » Sat Aug 04, 2012 4:55 am

Post by UncleBob
Sat Aug 04, 2012 4:55 am

Hi

the link to tsk2txt is gone. can you please reupload pls? need to put them on notepad to fully understand some code.

Many thanks in advance.
Hi

the link to tsk2txt is gone. can you please reupload pls? need to put them on notepad to fully understand some code.

Many thanks in advance.
UncleBob
Savvy Roboteer
Savvy Roboteer
Posts: 398
Joined: Sun Dec 27, 2009 5:25 am


14 postsPage 1 of 1
14 postsPage 1 of 1