Menu

Topic-icon setcancommand not working

More
10 months 2 weeks ago - 10 months 2 weeks ago #29533694 by vannem

The goal was to modify the pulse input mechanism to match the motion of the controller stick with the motion of the robot base.

Here is the script I am trying to work:

top: 
 ' Correcting the steering

 pulse1 = getvalue(_PI,1)
 pulse2 = getvalue(_PI,2)

 min_forward_pulse1 = 1510 
 min_backward_pulse1 = 1470
 min_forward_pulse1 = 1514 
 min_backward_pulse2 = 1474

 factor = 1/20

 if(pulse1 > min_forward_pulse1) then
	 setCANcommand(1, _G, 1, factor*(pulse1-min_forward_pulse1))
	 setCANcommand(1, _G, 2, factor*(pulse1-min_forward_pulse1))
	 setCANcommand(2, _G, 1, -factor*(pulse1-min_forward_pulse1))
	 setCANcommand(2, _G, 2, -factor*(pulse1-min_forward_pulse1))

 elseif(pulse1 < min_backward_pulse1) then
	 setCANcommand(1, _G, 1, -factor*(pulse1-min_forward_pulse1))
	 setCANcommand(1, _G, 2, -factor*(pulse1-min_forward_pulse1))
	 setCANcommand(2, _G, 1, factor*(pulse1-min_forward_pulse1))
	 setCANcommand(2, _G, 2, factor*(pulse1-min_forward_pulse1))

 elseif(pulse2 > min_forward_pulse2) then
	 setCANcommand(1, _G, 1, factor*(pulse2-min_forward_pulse2))
	 setCANcommand(1, _G, 2, factor*(pulse2-min_forward_pulse2))
	 setCANcommand(2, _G, 1, factor*(pulse2-min_forward_pulse2))
	 setCANcommand(2, _G, 2, factor*(pulse2-min_forward_pulse2))

 elseif(pulse2 < min_backward_pulse2) then
	 setCANcommand(1, _G, 1, -factor*(pulse2-min_forward_pulse2))
	 setCANcommand(1, _G, 2, -factor*(pulse2-min_forward_pulse2))
	 setCANcommand(2, _G, 1, -factor*(pulse2-min_forward_pulse2))
	 setCANcommand(2, _G, 2, -factor*(pulse2-min_forward_pulse2))

 else
	 setCANcommand(1, _G, 1, 0)
	 setCANcommand(1, _G, 2, 0)
	 setCANcommand(2, _G, 1, 0)
	 setCANcommand(2, _G, 2, 0)

 end if

 goto top

This is the error i am getting when i am trying to simulate it in Roborun:

File Attachment:

File Name: error1_2018-05-10.zip
File Size:163 KB

File Attachment:

File Name: error1_2018-05-10.zip
File Size:163 KB


What am i doing wrong?

Attachments:

Please Log in or Create an account to join the conversation.

More
10 months 2 weeks ago #29533695 by Gabriel_Isko

Hey Vannem,

I haven't looked at your script in depth or at the error you get yet, but the first recommendation I want to make is to use the wait() function at the end of your loop in order to give the control some time where it doesn't have to run the script during operation.

Please Log in or Create an account to join the conversation.

More
10 months 2 weeks ago #29533696 by Gabriel_Isko

The first recommendation is to use the wait() function at the end of your loop in order to give the control some time where it doesn't have to run the script during operation.

Our simulator doesn't have CAN built into it, so unfortunately you will not be able to simulate CAN commands. It will work when it runs on the controller however.

Please Log in or Create an account to join the conversation.

More
10 months 2 weeks ago - 10 months 2 weeks ago #29533698 by vannem

I tried running it on the system. It didn't work. Is my usage of setcancommand correct?

Please Log in or Create an account to join the conversation.

More
10 months 2 weeks ago #29533699 by Gabriel_Isko

I can build it. Looks like it should run.

Can you clarify what the error is in your system? If it is not properly sending commands over can, please ensure that your wiring and CANID set up is correct.

Please Log in or Create an account to join the conversation.

More
10 months 2 weeks ago #29533700 by vannem

The nodes are alive. My second node is another hdc2450. Am i supposed to run any script on that?

Please Log in or Create an account to join the conversation.

More
10 months 2 weeks ago #29533702 by Gabriel_Isko

No, additional scripting on the slave node should not be necessary. Do you think you can show a picture of how you have them wired together and also post your configuration profiles?

Please Log in or Create an account to join the conversation.

More
10 months 2 weeks ago - 10 months 2 weeks ago #29533703 by vannem

This is the wiring setup.

File Attachment:

File Name: wiring.jpg...5-10.zip
File Size:185 KB



I did ICL(is can node alive) and it worked(see below). I used robocan thru ros( ros ) as well.



I tried " !CG <cc> <nn> " and " !G <cc> <nn> " in the console and the results are a bit odd. Only the front 2 motors would move for both of those commands.

I also tried uploading a basic test script which didn't work at all either. Here it is. {Simulation worked fine}
top: 
 ' Correcting the steering


setcommand(_G, 1, 25)



 end if
wait(50)
 goto top

I am not sure what to do to solve this issue.

Attachments:

Please Log in or Create an account to join the conversation.

More
10 months 1 week ago #29533708 by Gabriel_Isko

Are your nodes configured to use Robocan?

Please Log in or Create an account to join the conversation.

More
10 months 1 week ago #29533710 by vannem

Yes. I did set up robocan in the config and set the node id and listen node id for both master and slave controllers.

Please Log in or Create an account to join the conversation.

Time to create page: 0.209 seconds
Go to top